From: Ian Scott <ian.scott@st...> - 2004-05-27 20:51:09
Nice catch. This is a serious bug, and I'm very surprised we haven't =
come across it before. We must not be using doing IO on any null =
Your second solution would indeed work, but I would prefer to fix it =
another way. I would like to deal with the null pointer explicitly. =
Since the serial id for a real item can never be 0, I plan to use that =
to indicate a null pointer, and leave the functions early.=20
Even though it isn't necessary, I'll increment the smart_ptr's io =
version number - just to be safe.
The one downside with this solution is that it won't allow you to load =
old files that were stored with multiple null pointers. Because you have =
never been able to load them, I presume this isn't a problem for you.
I'll commit my fix in the next few hours unless you have a problem with =
it. I'll commit a similar fix to vil_io_smart_ptr.
Sorry about the bug (Although it is only the second flaw to be found the =
whole IO system, and it can be handled without breaking any existing =
> -----Original Message-----
> From: vxl-maintainers-admin@...
> [mailto:vxl-maintainers-admin@...]On Behalf=20
> Of Matthew
> Sent: Thursday, May 27, 2004 8:51 PM
> To: vxl-maintainers@...
> Subject: [Vxl-maintainers] Bug in vbl_io_smart_ptr.txx
> There seems to be a bug in vbl_io_smart_ptr.txx. The serialization
> does not work properly if multiple NULL smart pointers are read.=20
> vbl_io_smart_ptr does not handle this case separately and therefore
> assigns a serial number to NULL. Writing succeeds under these
> conditions. However, is.get_serialisation_pointer returns a NULL
> pointer if an object has not yet been loaded. This is=20
> ambiguous in the
> case where you are actually reading a NULL pointer. Thus,=20
> the following
> check fails:
> if (first_time !=3D (pointer =3D=3D 0))
> // This checks that the saving stream and reading stream
> // both agree on whether or not this is the first time they
> // have seen this object.
> vcl_cerr << "I/O ERROR: vsl_b_read(vsl_b_istream&,=20
> << " De-serialisation failure\n";
> is.is().clear(vcl_ios::badbit); // Set an unrecoverable IO=20
> error on stream
> It seems that if this check is removed and the following conditional
> statement 'if(pointer =3D=3D 0)' (line 121) is replaced with
> 'if(first_time)' then everything works fine.
> Another solution is to modify get_serialisation_pointer so that it
> returns a boolean and also returns the pointer by reference. This
> solution involves more changes but is probably a better way to fix
> this. =20
> Has anyone else had this problem or am I missing something? =20
> Is it safe
> to make one of these changes (probably the second one)? I don't think
> either will break existing binary files. =20
> -Matt Leotta
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market...=20
> Oracle 10g.=20
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> Vxl-maintainers mailing list