[orbitcpp-list] Re: passing a reference to another process
Status: Beta
Brought to you by:
philipd
From: <MHL...@t-...> - 2000-11-23 20:47:27
|
On 11/22/2000, 03:11:36 Phil Dawes wrote: > Hi Martin, > > Glad you solved your problem - sorry about my reply arriving too > late. > > I agree that it`s unfortunate that this sort of mistake results in > such a nebulus error - can you think of a way we could trap this in > orbitcpp?. > The problem is that all variables xxx_ptr that get initialized from the same reference xxx_var point to a "profile_list". This profile_list is freed when xxx_var is destroyed (unless the reference is duplicated, of course). Now can you look at a xxx_ptr and say whether profile_list still points to a valid memory block or not ? I found my bug because "next" in profile_list was 0x0 but that doesn't necessarily have to be the case. Hmm, perhaps we could define a macro like #ifdef DEBUG #define REFERENCE_IS_VALID(obj) \ if(obj->profile_list) obj->profile_list->data->profile_type = \ obj->profile_list->data->profile_type; #else #define REFERENCE_IS_VALID(obj) #endif and use it in the cpp-stubs before passing obj to the c-stub which in turn passes it to liborbit where the segfault happens. I think this macro should a segfault?! If yes the users attendence should be drawn on the right track! Anyway I think it would be good to add a few comments to client.cc in the test everything. People that start using a new library will first have a look at the examples. Maybe you could modify the program a little so that it stores a refence to a Factory and use it later in another function. Cheers, Martin. |