File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -1225,7 +1225,8 @@ looks as follows:
1225
1225
if (t.size() != 2)
1226
1226
throw std::runtime_error("Invalid state!");
1227
1227
1228
- /* Invoke the constructor (need to use in-place version) */
1228
+ /* Invoke the in-place constructor. Note that this is needed even
1229
+ when the object just has a trivial default constructor */
1229
1230
new (&p) Pickleable(t[0].cast<std::string>());
1230
1231
1231
1232
/* Assign any additional state */
@@ -1247,7 +1248,9 @@ An instance can now be pickled as follows:
1247
1248
1248
1249
Note that only the cPickle module is supported on Python 2.7. It is also
1249
1250
important to request usage of the highest protocol version using the ``-1 ``
1250
- argument to ``dumps ``.
1251
+ argument to ``dumps ``. Failure to follow these two steps will lead to important
1252
+ pybind11 memory allocation routines to be skipped during unpickling, which will
1253
+ likely cause memory corruption and/or segmentation faults.
1251
1254
1252
1255
.. seealso ::
1253
1256
You can’t perform that action at this time.
0 commit comments