Opened 13 years ago

Closed 13 years ago

#3957 closed Bugs (fixed)

De-serialization of shared_ptrs derived from enable_shared_from_this fail

Reported by: Carus V. (Bud) Clarke <carus.v.clarke@…> Owned by: Robert Ramey
Milestone: Boost 1.43.0 Component: serialization
Version: Boost 1.42.0 Severity: Problem
Keywords: Cc:

Description

De-serialization of shared_ptrs derived from enable_shared_from_this fails to initialize the base enable_shared_from_this objects, which causes a program crash when shared_from_this() is called. The root cause seems to be that a shared_pointer<void> is created inside file shared_ptr_helper.cpp, instead of a shared_ptr<T>, with T being the original class. This causes the non-enable_shared_from_this constructor to be called. I worked around this by moving the initial construction of the shared_ptr to file shared_ptr_helper.hpp.

A patch file is attached and also a test program, modified from one originally written by Alexander Gutenev.

Thanks,

Bud Clarke

Attachments (4)

patchfile.patch (2.2 KB ) - added by Carus V. (Bud) Clarke <carus.v.clarke@…> 13 years ago.
Patch file
test_weak_ptr_serialization.tgz (3.0 KB ) - added by Carus V. (Bud) Clarke <carus.v.clarke@…> 13 years ago.
Test program
patchfile-2.patch (2.7 KB ) - added by Carus V. (Bud) Clarke <carus.v.clarke@…> 13 years ago.
Corrected patch file
weak_ptr_serialization.zip (3.9 KB ) - added by Carus V. (Bud) Clarke <carus.v.clarke@…> 13 years ago.
Zip file containing test program and VC 9.0 project files

Download all attachments as: .zip

Change History (7)

by Carus V. (Bud) Clarke <carus.v.clarke@…>, 13 years ago

Attachment: patchfile.patch added

Patch file

by Carus V. (Bud) Clarke <carus.v.clarke@…>, 13 years ago

Test program

by Carus V. (Bud) Clarke <carus.v.clarke@…>, 13 years ago

Attachment: patchfile-2.patch added

Corrected patch file

comment:1 by Robert Ramey, 13 years ago

I'm having problems with test_weak_ptr_serialization.tgz - could you send a *.zip file version?

Robert Ramey

by Carus V. (Bud) Clarke <carus.v.clarke@…>, 13 years ago

Attachment: weak_ptr_serialization.zip added

Zip file containing test program and VC 9.0 project files

comment:2 by Robert Ramey, 13 years ago

Status: newassigned

I've run you example and found it to fail. Then I included your patches and the example ran. I confess, I really didn't analyze your code carefully. I just assumed that anyone who goes into that area knows what he's doing. Could I ask you one more favor? Could you tweak the test so that I can add it to our test set? That is, it should return success if it passes. Also it would be nice if it did some BOOST_TEST_? macros to document what the expected results are. Look at the other tests to see how this is done.

Thanks for this.

Robert Ramey

comment:3 by Robert Ramey, 13 years ago

Resolution: fixed
Status: assignedclosed

patch incorporated in trunk and release

Note: See TracTickets for help on using tickets.