Skip to content

Instantly share code, notes, and snippets.

@rwgk
Created December 11, 2020 14:48
Show Gist options
  • Save rwgk/4fe600fad45442a5d790b53195a4da51 to your computer and use it in GitHub Desktop.
Save rwgk/4fe600fad45442a5d790b53195a4da51 to your computer and use it in GitHub Desktop.
holder_shared_make_unique_gdb_stack.txt posted 2020-12-11
2020-12-07
based on
pybind11 master 028812ae7eee307dca5f8f69d467af7b92cc41c8
with a few experimental changes, but not changing core behavior
inline std::unique_ptr<pointee> make_unique_pointee() {
return std::unique_ptr<pointee>(new pointee);
}
py::class_<pointee, std::shared_ptr<pointee>>(m, "pointee")
m.def("make_unique_pointee", make_unique_pointee);
INTENTIONAL SEGFAULT inserted in cast.h value_and_holder::holder
pytest + gdb output below
gdb output manually edited to make it easier to read:
upper-cased some names
### SHARED #### = std::shared_ptr
### UNIQUE #### = std::unique_ptr
pybind11::DETAIL::VALUE_AND_HOLDER::xxx_holder is originally pybind11::detail::value_and_holder::holder
-------------------------------------------------------------------------------
../pybind11/tests/test_holder_shared_ptr.py
make_unique_pointee
pointee::pointee()
xxx_holder<St10shared_ptrIN14pybind11_tests17holder_shared_ptr7pointeeEE>
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6685a1f in pybind11::DETAIL::VALUE_AND_HOLDER::xxx_holder<### SHARED ####<pybind11_tests::holder_shared_ptr::pointee> > (this=0x7fffffff7150)
at /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/cast.h:238
238 std::cout << *BAD;
(gdb) where
#0 0x00007ffff6685a1f in DETAIL::VALUE_AND_HOLDER::xxx_holder<### SHARED ####<pybind11_tests::holder_shared_ptr::pointee> > (this=0x7fffffff7150)
at
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/cast.h:238
#1 0x00007ffff6685879 in CLASS_<pybind11_tests::holder_shared_ptr::pointee, ### SHARED ####<pybind11_tests::holder_shared_ptr::pointee> >::init_holder_from_existing (
v_h=..., holder_ptr=0x7fffffff7528)
at
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/pybind11.h:1475
#2 0x00007ffff66857d0 in CLASS_<pybind11_tests::holder_shared_ptr::pointee, ### SHARED ####<pybind11_tests::holder_shared_ptr::pointee> >::init_holder (
inst=0x7ffff49f4170, v_h=..., holder_ptr=0x7fffffff7528)
at
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/pybind11.h:1487
#3 0x00007ffff6685681 in CLASS_<pybind11_tests::holder_shared_ptr::pointee, ### SHARED ####<pybind11_tests::holder_shared_ptr::pointee> >::init_instance (
inst=0x7ffff49f4170, holder_ptr=0x7fffffff7528)
at
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/pybind11.h:1505
#4 0x00007ffff64391df in DETAIL::TYPE_CASTER_GENERIC::CAST (_src=0xf4ac20, policy=pybind11::return_value_policy::take_ownership, parent=..., tinfo=0xc25710,
copy_constructor=0x0, move_constructor=0x0, existing_holder=0x7fffffff7528)
at
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/cast.h:594
#5 0x00007ffff6686eea in DETAIL::TYPE_CASTER_BASE<pybind11_tests::holder_shared_ptr::pointee>::cast_holder (src=0xf4ac20, holder=0x7fffffff7528)
at
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/cast.h:923
#6 0x00007ffff6686dd1 in detail::MOVE_ONLY_HOLDER_CASTER<pybind11_tests::holder_shared_ptr::pointee, ### UNIQUE ####<pybind11_tests::holder_shared_ptr::pointee, std::default_delete<pybind11_tests::holder_shared_ptr::pointee> > >::cast (src=...)
at
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/cast.h:1590
#7 0x00007ffff6686d0b in CPP_FUNCTION::INITIALIZE<### UNIQUE ####<pybind11_tests::holder_shared_ptr::pointee, std::default_delete<pybind11_tests::holder_shared_ptr::pointee> > (*&)(), ### UNIQUE ####<pybind11_tests::holder_shared_ptr::pointee, std::default_delete<pybind11_tests::holder_shared_ptr::pointee> >, , pybind11::name, pybind11::scope, pybind11::sibling>(### UNIQUE ####<pybind11_tests::holder_shared_ptr::pointee, std::default_delete<pybind11_tests::holder_shared_ptr::pointee> > (*&)(), ### UNIQUE ####<pybind11_tests::holder_shared_ptr::pointee, std::default_delete<pybind11_tests::holder_shared_ptr::pointee> > (*)(), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&)::{lambda(pybind11::detail::function_call&)#1}::operator()(pybind11::detail::function_call&) const (this=0x7fffffff7ca8, call=...)
at
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/pybind11.h:183
#8 0x00007ffff6686c45 in CPP_FUNCTION::INITIALIZE<### UNIQUE ####<pybind11_tests::holder_shared_ptr::pointee, std::default_delete<pybind11_tests::holder_shared_ptr::pointee> > (*&)(), ### UNIQUE ####<pybind11_tests::holder_shared_ptr::pointee, std::default_delete<pybind11_tests::holder_shared_ptr::pointee> >, , pybind11::name, pybind11::scope, pybind11::sibling>(### UNIQUE ####<pybind11_tests::holder_shared_ptr::pointee, std::default_delete<pybind11_tests::holder_shared_ptr::pointee> > (*&)(), ### UNIQUE ####<pybind11_tests::holder_shared_ptr::pointee, std::default_delete<pybind11_tests::holder_shared_ptr::pointee> > (*)(), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&)::{lambda(pybind11::detail::function_call&)#1}::__invoke(pybind11::detail::function_call&) (call=...)
at
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/pybind11.h:161
#9 0x00007ffff640feb2 in CPP_FUNCTION::DISPATCHER (self=0x7ffff6ee11b0, args_in=0x7ffff78fb040, kwargs_in=0x0)
at
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/pybind11.h:717
#10 0x0000000000520e4c in PyCFunction_Call ()
#11 0x0000000000510393 in _PyObject_MakeTpCall ()
#12 0x000000000050a967 in _PyEval_EvalFrameDefault ()
#13 0x000000000051aaff in _PyFunction_Vectorcall ()
#14 0x000000000052c4c1 in PyVectorcall_Call ()
#15 0x0000000000506e5e in _PyEval_EvalFrameDefault ()
#16 0x00000000005045d3 in _PyEval_EvalCodeWithName ()
#17 0x000000000051ab9a in _PyFunction_Vectorcall ()
#18 0x000000000052c4c1 in PyVectorcall_Call ()
#19 0x0000000000506e5e in _PyEval_EvalFrameDefault ()
#20 0x00000000005045d3 in _PyEval_EvalCodeWithName ()
#21 0x000000000051ab9a in _PyFunction_Vectorcall ()
#22 0x000000000050688a in _PyEval_EvalFrameDefault ()
#23 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#24 0x000000000051ab9a in _PyFunction_Vectorcall ()
#25 0x000000000050a3a6 in _PyEval_EvalFrameDefault ()
--Type <RET> for more, q to quit, c to continue without paging--
#26 0x000000000052befe in ?? ()
#27 0x000000000050a3a6 in _PyEval_EvalFrameDefault ()
#28 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#29 0x000000000051ab9a in _PyFunction_Vectorcall ()
#30 0x000000000050f92c in _PyObject_FastCallDict ()
#31 0x000000000052722d in _PyObject_Call_Prepend ()
#32 0x000000000059bd07 in ?? ()
#33 0x0000000000510393 in _PyObject_MakeTpCall ()
#34 0x000000000050ad25 in _PyEval_EvalFrameDefault ()
#35 0x000000000051aaff in _PyFunction_Vectorcall ()
#36 0x00000000005058bc in _PyEval_EvalFrameDefault ()
#37 0x000000000051aaff in _PyFunction_Vectorcall ()
#38 0x000000000052c4c1 in PyVectorcall_Call ()
#39 0x0000000000506e5e in _PyEval_EvalFrameDefault ()
#40 0x00000000005045d3 in _PyEval_EvalCodeWithName ()
#41 0x000000000051ab9a in _PyFunction_Vectorcall ()
#42 0x000000000050688a in _PyEval_EvalFrameDefault ()
#43 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#44 0x000000000051ab9a in _PyFunction_Vectorcall ()
#45 0x000000000050a3a6 in _PyEval_EvalFrameDefault ()
#46 0x000000000052befe in ?? ()
#47 0x000000000050a3a6 in _PyEval_EvalFrameDefault ()
#48 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#49 0x000000000051ab9a in _PyFunction_Vectorcall ()
#50 0x000000000050f92c in _PyObject_FastCallDict ()
#51 0x000000000052722d in _PyObject_Call_Prepend ()
#52 0x000000000059bd07 in ?? ()
#53 0x0000000000531125 in PyObject_Call ()
#54 0x0000000000506e5e in _PyEval_EvalFrameDefault ()
#55 0x00000000005045d3 in _PyEval_EvalCodeWithName ()
#56 0x000000000051ab9a in _PyFunction_Vectorcall ()
#57 0x00000000005056f4 in _PyEval_EvalFrameDefault ()
#58 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#59 0x000000000052c0d1 in ?? ()
#60 0x000000000050688a in _PyEval_EvalFrameDefault ()
#61 0x00000000005045d3 in _PyEval_EvalCodeWithName ()
#62 0x000000000051ab9a in _PyFunction_Vectorcall ()
#63 0x000000000052c4c1 in PyVectorcall_Call ()
#64 0x0000000000506e5e in _PyEval_EvalFrameDefault ()
#65 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#66 0x000000000051ab9a in _PyFunction_Vectorcall ()
#67 0x00000000005056f4 in _PyEval_EvalFrameDefault ()
#68 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
--Type <RET> for more, q to quit, c to continue without paging--
#69 0x000000000051ab9a in _PyFunction_Vectorcall ()
#70 0x000000000050688a in _PyEval_EvalFrameDefault ()
#71 0x000000000051aaff in _PyFunction_Vectorcall ()
#72 0x000000000052c4c1 in PyVectorcall_Call ()
#73 0x0000000000506e5e in _PyEval_EvalFrameDefault ()
#74 0x00000000005045d3 in _PyEval_EvalCodeWithName ()
#75 0x000000000051ab9a in _PyFunction_Vectorcall ()
#76 0x000000000050688a in _PyEval_EvalFrameDefault ()
#77 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#78 0x000000000051ab9a in _PyFunction_Vectorcall ()
#79 0x000000000050a3a6 in _PyEval_EvalFrameDefault ()
#80 0x000000000052befe in ?? ()
#81 0x000000000050a3a6 in _PyEval_EvalFrameDefault ()
#82 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#83 0x000000000051ab9a in _PyFunction_Vectorcall ()
#84 0x000000000050f92c in _PyObject_FastCallDict ()
#85 0x000000000052722d in _PyObject_Call_Prepend ()
#86 0x000000000059bd07 in ?? ()
#87 0x0000000000510393 in _PyObject_MakeTpCall ()
#88 0x000000000050ad25 in _PyEval_EvalFrameDefault ()
#89 0x000000000051aaff in _PyFunction_Vectorcall ()
#90 0x000000000052c4c1 in PyVectorcall_Call ()
#91 0x0000000000506e5e in _PyEval_EvalFrameDefault ()
#92 0x00000000005045d3 in _PyEval_EvalCodeWithName ()
#93 0x000000000051ab9a in _PyFunction_Vectorcall ()
#94 0x000000000050688a in _PyEval_EvalFrameDefault ()
#95 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#96 0x000000000051ab9a in _PyFunction_Vectorcall ()
#97 0x000000000050a3a6 in _PyEval_EvalFrameDefault ()
#98 0x000000000052befe in ?? ()
#99 0x000000000050a3a6 in _PyEval_EvalFrameDefault ()
#100 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#101 0x000000000051ab9a in _PyFunction_Vectorcall ()
#102 0x000000000050f92c in _PyObject_FastCallDict ()
#103 0x000000000052722d in _PyObject_Call_Prepend ()
#104 0x000000000059bd07 in ?? ()
#105 0x0000000000510393 in _PyObject_MakeTpCall ()
#106 0x000000000050ad25 in _PyEval_EvalFrameDefault ()
#107 0x000000000051aaff in _PyFunction_Vectorcall ()
#108 0x00000000005056f4 in _PyEval_EvalFrameDefault ()
#109 0x000000000051aaff in _PyFunction_Vectorcall ()
#110 0x00000000005056f4 in _PyEval_EvalFrameDefault ()
#111 0x000000000051aaff in _PyFunction_Vectorcall ()
--Type <RET> for more, q to quit, c to continue without paging--
#112 0x000000000052c4c1 in PyVectorcall_Call ()
#113 0x0000000000506e5e in _PyEval_EvalFrameDefault ()
#114 0x00000000005045d3 in _PyEval_EvalCodeWithName ()
#115 0x000000000051ab9a in _PyFunction_Vectorcall ()
#116 0x000000000050688a in _PyEval_EvalFrameDefault ()
#117 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#118 0x000000000051ab9a in _PyFunction_Vectorcall ()
#119 0x000000000050a3a6 in _PyEval_EvalFrameDefault ()
#120 0x000000000052befe in ?? ()
#121 0x000000000050a3a6 in _PyEval_EvalFrameDefault ()
#122 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#123 0x000000000051ab9a in _PyFunction_Vectorcall ()
#124 0x000000000050f92c in _PyObject_FastCallDict ()
#125 0x000000000052722d in _PyObject_Call_Prepend ()
#126 0x000000000059bd07 in ?? ()
#127 0x0000000000510393 in _PyObject_MakeTpCall ()
#128 0x000000000050ad25 in _PyEval_EvalFrameDefault ()
#129 0x00000000005cf8e8 in ?? ()
#130 0x000000000050a3a6 in _PyEval_EvalFrameDefault ()
#131 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#132 0x00000000005cf293 in PyEval_EvalCode ()
#133 0x00000000005d2a10 in ?? ()
#134 0x000000000051b599 in ?? ()
#135 0x00000000005056f4 in _PyEval_EvalFrameDefault ()
#136 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#137 0x000000000051ab9a in _PyFunction_Vectorcall ()
#138 0x00000000005056f4 in _PyEval_EvalFrameDefault ()
#139 0x0000000000503c45 in _PyEval_EvalCodeWithName ()
#140 0x000000000051ab9a in _PyFunction_Vectorcall ()
#141 0x000000000052c4c1 in PyVectorcall_Call ()
#142 0x00000000005e6e08 in ?? ()
#143 0x00000000005e602c in Py_RunMain ()
#144 0x00000000005c4619 in Py_BytesMain ()
#145 0x00007ffff7c4acca in __libc_start_main (main=0x5c45e0 <main>, argc=8, argv=0x7fffffffd638, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
stack_end=0x7fffffffd628) at ../csu/libc-start.c:308
#146 0x00000000005c451a in _start ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment