Opened 8 years ago
Closed 8 years ago
#10084 closed Bugs (fixed)
void_upcast should throw an unregistered_cast exception when it can't find a way to upcast
Reported by: | Owned by: | Robert Ramey | |
---|---|---|---|
Milestone: | To Be Determined | Component: | serialization |
Version: | Boost 1.55.0 | Severity: | Problem |
Keywords: | Cc: |
Description
It is possible for the void_caster_register to not include information on how to upcast between types. In version 1.55, void_upcast(lines 314-334) in void_cast.cpp searches the void_caster_register for this information and, if it finds none, returns NULL. If this happens when doing deserialization, it means that all of the deserialized data is thrown away (event though it may have been successfully completed) and the user gets a null pointer back instead. At a minimum, this results in mysterious behavior when deserializing derived classes through a base class pointer. At worst, this may result in a memory leak (haven't investigated this). It seems to me that rather than surprising the user like this, failures to find appropriate cast info in the void_caster_register should cause an unregistered_cast exception (or something similar) so the user will at least know where the problem is. This can happen even though void_upcast the appropriate type information for both the base and derived class.
This problem occurs when the void_caster_register is empty, which has happened when both Boost.Serialize and the library of classes to be serialized are created as DLLs on Windows 7 when building using VS2012.
Could it be that the problem here is related to this: http://stackoverflow.com/questions/12991581/using-static-members-across-static-lib-and-dll-member-value-is-resetting
For the problem to occur, the library containing my serializable classes was a DLL but it was linked to other static libraries and the EXE.