When I run the following script in GDB: <pre> import sys import os import zmq c = zmq.Context.instance() s = c.socket(zmq.ROUTER) print(s) s.bind_to_random_port("tcp://127.0.0.1") print("works") sys.exit(0) </pre> with arm-none-eabi-gdb --command test.py GDB crashes with a core dump: I cloned the Git repository: commit 5e8bf44f4c94d430ac21257a1a953cfccd2ce79b crashes I have done a binary search over the git repository: commit 5809899dad253e2fefcb6f7ae57a6f43cfa4e3c5 and onwards crashes commit 3e25a500a1ba05587389737e7c617e5ae6dd2bcf and before work gdb was configured as follows: This GDB was configured as follows: configure --host=x86_64-pc-linux-gnu --target=arm-none-eabi --with-auto-load-dir=$debugdir:$datadir/auto-load --with-auto-load-safe-path=$debugdir:$datadir/auto-load --with-expat --with-gdb-datadir=/usr/special/tmp/share/gdb (relocatable) --with-jit-reader-dir=/usr/special/tmp/lib/gdb (relocatable) --without-libunwind-ia64 --with-lzma --with-python=/opt/conda/envs/gdb_ipykernel --without-guile --with-separate-debug-dir=/usr/special/tmp/lib/debug (relocatable) --without-babeltrace My build command: cd binutils-gdb && export LDFLAGS=-L/opt/conda/envs/gdb_ipykernel/lib/ && ./configure --target=arm-none-eabi --prefix=/usr/special/tmp --with-python=/opt/conda/envs/gdb_ipykernel/bin/ python && make && make tooldir=/usr/special/tmp install python version is python 3.5.2 ZMQ: python -c 'import zmq; print(zmq.zmq_version(), zmq.__version__)' 4.1.6 16.0.2
Thanks for the bug report. Could you please recompile GDB using '-O0 -g3' as CFLAGS/CXXFLAGS, and then let us know more information about the core dump being generated? A backtrace would be really helpful.
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `/usr/special/tmp/bin/arm-none-eabi-gdb --command test_error.py'. (test_error.py is the following program: import sys import os import zmq c = zmq.Context.instance() s = c.socket(zmq.ROUTER) print(s) s.bind_to_random_port("tcp://127.0.0.1") print("works") sys.exit(0) ) Program terminated with signal SIGABRT, Aborted. The backtrace of commit 5809899dad253e2fefcb6f7ae57a6f43cfa4e3c5: #0 0x00007f3d64eeb067 in raise () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x00007f3d64eec448 in abort () from /lib/x86_64-linux-gnu/libc.so.6 #2 0x00007f3d6349ef78 in _Unwind_SetGR (context=<optimized out>, index=<optimized out>, val=<optimized out>) at /gcc-build/libgcc/unwind-dw2.c:271 #3 0x00007f3d63734c62 in __gxx_personality_v0 () from /opt/conda/envs/gdb_ipykernel/lib/libstdc++.so.6 #4 0x00000000008bd653 in _Unwind_RaiseException_Phase2 () #5 0x00000000008bde97 in _Unwind_Resume () #6 0x0000000000892b0a in std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_int<unsigned long>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, unsigned long) const () #7 0x0000000000892b1d in std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, unsigned long) const () #8 0x00007f3d637b18ea in std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long) () from /opt/conda/envs/gdb_ipykernel/lib/libstdc++.so.6 #9 0x00007f3d63aab1e9 in operator<< (__n=0, this=<optimized out>) at /usr/include/c++/4.9/ostream:185 #10 zmq::tcp_address_t::to_string (this=this@entry=0x16b5f60, addr_=...) at src/tcp_address.cpp:523 #11 0x00007f3d63aae04d in zmq::tcp_listener_t::set_address (this=this@entry=0x16b5c20, addr_=<optimized out>) at src/tcp_listener.cpp:222 #12 0x00007f3d63aa0680 in zmq::socket_base_t::bind (this=0x16b55b0, addr_=addr_@entry=0x7f3d64ab13d0 "tcp://127.0.0.1:*") at src/socket_base.cpp:407 #13 0x00007f3d63ab34c9 in zmq_bind (s_=<optimized out>, addr_=addr_@entry=0x7f3d64ab13d0 "tcp://127.0.0.1:*") at src/zmq.cpp:305 #14 0x00007f3d62c4e864 in __pyx_pf_3zmq_7backend_6cython_6socket_6Socket_12bind (__pyx_v_addr=0x7f3d64ab13b0, __pyx_v_self=0x7f3d62c0ffa8) at zmq/backend/cython/socket.c:5433 #15 __pyx_pw_3zmq_7backend_6cython_6socket_6Socket_13bind (__pyx_v_self=0x7f3d62c0ffa8, __pyx_v_addr=<optimized out>) at zmq/backend/cython/socket.c:5294 #16 0x00007f3d6328d696 in __Pyx_CyFunction_CallMethod (kw=<optimized out>, arg=0x7f3d64d10c18, self=0x7f3d62c0ffa8, func=0x7f3d649ebb10) at zmq/backend/cython/error.c:1965 #17 __Pyx_CyFunction_CallAsMethod (func=0x7f3d649ebb10, args=<optimized out>, kw=<optimized out>) at zmq/backend/cython/error.c:2004 #18 0x00007f3d65a04236 in PyObject_Call (func=0x7f3d649ebb10, arg=<optimized out>, kw=<optimized out>) at Objects/abstract.c:2165 #19 0x00007f3d65ade314 in do_call (nk=<optimized out>, na=2, pp_stack=0x7ffcbc5fe2e8, func=0x7f3d649ebb10) at Python/ceval.c:4936 #20 call_function (oparg=<optimized out>, pp_stack=0x7ffcbc5fe2e8) at Python/ceval.c:4732 #21 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3236 #22 0x00007f3d65ae1b49 in _PyEval_EvalCodeWithName (_co=<optimized out>, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=2, kws=0x7f3d64db6ba8, kwcount=0, defs=0x7f3d62c394e0, defcount=3, kwdefs=0x0, closure=0x0, name=0x7f3d64a5d348, qualname=0x7f3d62c29df0) at Python/ceval.c:4018 #23 0x00007f3d65ae0df5 in fast_function (nk=<optimized out>, na=2, n=<optimized out>, pp_stack=0x7ffcbc5fe508, func=0x7f3d62c3c0d0) at Python/ceval.c:4813 #24 call_function (oparg=<optimized out>, pp_stack=0x7ffcbc5fe508) at Python/ceval.c:4730 #25 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3236 #26 0x00007f3d65ae1b49 in _PyEval_EvalCodeWithName (_co=<optimized out>, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0, name=0x0, qualname=0x0) at Python/ceval.c:4018 #27 0x00007f3d65ae1cd8 in PyEval_EvalCodeEx (_co=<optimized out>, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kws=<optimized out>, kwcount=0, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0) at Python/ceval.c:4039 #28 0x00007f3d65ae1d1b in PyEval_EvalCode (co=<optimized out>, globals=<optimized out>, locals=<optimized out>) at Python/ceval.c:777 #29 0x00007f3d65b07020 in run_mod (arena=0x15bcfb0, flags=0x0, locals=0x7f3d64e63248, globals=0x7f3d64e63248, filename=0x7f3d6499b3b0, mod=0x15f73f0) at Python/pythonrun.c:976 #30 PyRun_FileExFlags (fp=0x15bcd10, filename_str=<optimized out>, start=<optimized out>, globals=0x7f3d64e63248, locals=0x7f3d64e63248, closeit=<optimized out>, flags=0x0) at Python/pythonrun.c:929 #31 0x00007f3d65b08623 in PyRun_SimpleFileExFlags (fp=0x15bcd10, filename=<optimized out>, closeit=0, flags=0x0) at Python/pythonrun.c:396 #32 0x000000000049192e in python_run_simple_file (file=0x15bcd10, filename=0x7ffcbc60090e "test_error.py") at ./python/python.c:379 #33 0x0000000000492b50 in gdbpy_source_script (extlang=0x8df9c0 <extension_language_python>, file=0x15bcd10, filename=0x7ffcbc60090e "test_error.py") at ./python/python.c:911 #34 0x000000000046d5f5 in source_script_from_stream (stream=0x15bcd10, file=0x7ffcbc60090e "test_error.py", file_to_open=0x7ffcbc60090e "test_error.py") at ./cli/cli-cmds.c:577 #35 0x000000000046d6e8 in source_script_with_search (file=0x7ffcbc60090e "test_error.py", from_tty=1, search_path=0) at ./cli/cli-cmds.c:630 #36 0x000000000046d71b in source_script (file=0x7ffcbc60090e "test_error.py", from_tty=1) at ./cli/cli-cmds.c:640 #37 0x00000000005a9de5 in catch_command_errors_const (command=0x46d6f6 <source_script(char const*, int)>, arg=0x7ffcbc60090e "test_error.py", from_tty=1) at main.c:402 #38 0x00000000005ab142 in captured_main (data=0x7ffcbc5feaa0) at main.c:1124 #39 0x00000000005ab206 in gdb_main (args=0x7ffcbc5feaa0) at main.c:1161 #40 0x000000000040d43d in main (argc=3, argv=0x7ffcbc5feba8) at gdb.c:32
The diff between the working and next non working commit: git diff 3e25a500a1ba05587389737e7c617e5ae6dd2bcf..5809899dad253e2fefcb6f7ae57a6f43cfa4e3c5 diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fe3ea42..8c8b18a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2016-09-23 Tom Tromey <tom@tromey.com> + * break-catch-sig.c: Include <string>. + (signal_catchpoint_print_one): Use std::string. + +2016-09-23 Tom Tromey <tom@tromey.com> + * utils.c (struct restore_ui_out_closure): Remove. * objfiles.h (terminate_minimal_symbol_table): Don't declare. diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c index 06ee44c..296f900 100644 --- a/gdb/break-catch-sig.c +++ b/gdb/break-catch-sig.c @@ -28,7 +28,8 @@ #include "valprint.h" #include "cli/cli-utils.h" #include "completer.h" -#include "gdb_obstack.h" + +#include <string> #define INTERNAL_SIGNAL(x) ((x) == GDB_SIGNAL_TRAP || (x) == GDB_SIGNAL_INT) @@ -265,11 +266,7 @@ signal_catchpoint_print_one (struct breakpoint *b, { int i; gdb_signal_type iter; - struct obstack text; - struct cleanup *cleanup; - - obstack_init (&text); - cleanup = make_cleanup_obstack_free (&text); + std::string text; for (i = 0; VEC_iterate (gdb_signal_type, c->signals_to_be_caught, i, iter); @@ -278,12 +275,10 @@ signal_catchpoint_print_one (struct breakpoint *b, const char *name = signal_to_name_or_int (iter); if (i > 0) - obstack_grow (&text, " ", 1); - obstack_grow (&text, name, strlen (name)); + text += " "; + text += name; } - obstack_grow (&text, "", 1); - do_cleanups (cleanup);iout, "what", (const char *) obstack_base (&text));--More-- + ui_out_field_string (uiout, "what", text.c_str ()); } else ui_out_field_string (uiout, "what", The changes seem minor. So in the non working version I started undoing changes to see if the modified GDB would work. At the end the change that made the difference is just the declaration of std::string text;
Can you submit the patch, following the posting guidelines, to the gdb-patches@ list?