valgrind ./gdb -nx -ex 'python gdb.decode_line("")' First it wrongly detects IS_QUOTED == 1, one should check the code more for it. ==19361== Invalid read of size 1 ==19361== at 0x6A9628: locate_first_half (linespec.c:1146) ==19361== by 0x6A8C3A: decode_line_1 (linespec.c:871) ==19361== by 0x628404: gdbpy_decode_line (python.c:457) ==19361== by 0x5E15DCC: PyEval_EvalFrameEx (ceval.c:4072) ==19361== by 0x5E1799C: PyEval_EvalCodeEx (ceval.c:3312) ==19361== by 0x5E17AD1: PyEval_EvalCode (ceval.c:671) ==19361== by 0x5E31BDB: run_mod (pythonrun.c:1354) ==19361== by 0x5E327FC: PyRun_StringFlags (pythonrun.c:1317) ==19361== by 0x5E3333A: PyRun_SimpleStringFlags (pythonrun.c:970) ==19361== by 0x627BA3: python_command (python.c:205) ==19361== by 0x604DE4: do_cfunc (cli-decode.c:67) ==19361== by 0x607F69: cmd_func (cli-decode.c:1777) ==19361== by 0x48D2C5: execute_command (top.c:428) ==19361== by 0x6CB967: catch_command_errors (exceptions.c:537) ==19361== by 0x4836F4: captured_main (main.c:909) ==19361== by 0x6CB8CC: catch_errors (exceptions.c:521) ==19361== by 0x483789: gdb_main (main.c:942) ==19361== by 0x4823C2: main (gdb.c:35) ==19361== Address 0xd692ce1 is 0 bytes after a block of size 1 alloc'd ==19361== at 0x4C2840D: malloc (vg_replace_malloc.c:236) ==19361== by 0x490F47: xmalloc (utils.c:1475) ==19361== by 0xDE2455: xstrdup (xstrdup.c:34) ==19361== by 0x6283C0: gdbpy_decode_line (python.c:454) ==19361== by 0x5E15DCC: PyEval_EvalFrameEx (ceval.c:4072) ==19361== by 0x5E1799C: PyEval_EvalCodeEx (ceval.c:3312) ==19361== by 0x5E17AD1: PyEval_EvalCode (ceval.c:671) ==19361== by 0x5E31BDB: run_mod (pythonrun.c:1354) ==19361== by 0x5E327FC: PyRun_StringFlags (pythonrun.c:1317) ==19361== by 0x5E3333A: PyRun_SimpleStringFlags (pythonrun.c:970) ==19361== by 0x627BA3: python_command (python.c:205) ==19361== by 0x604DE4: do_cfunc (cli-decode.c:67) ==19361== by 0x607F69: cmd_func (cli-decode.c:1777) ==19361== by 0x48D2C5: execute_command (top.c:428) ==19361== by 0x6CB967: catch_command_errors (exceptions.c:537) ==19361== by 0x4836F4: captured_main (main.c:909) ==19361== by 0x6CB8CC: catch_errors (exceptions.c:521) ==19361== by 0x483789: gdb_main (main.c:942) ==19361== by 0x4823C2: main (gdb.c:35) ==19361==
Sending a patch.
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ff47f4f06d296b672337e2c7363a745cd2725f58 commit ff47f4f06d296b672337e2c7363a745cd2725f58 Author: Tom Tromey <tom@tromey.com> Date: Sat Dec 21 09:51:05 2019 -0700 Fix valgrind error from gdb.decode_line PR symtab/12535 points out that gdb.decode_line("") will cause a valgrind report. I think the empty linespec does not really make sense. So, this patch changes gdb.decode_line to treat a whitespace-only linespec the same as a non-existing argument. gdb/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> PR symtab/12535: * python/python.c (gdbpy_decode_line): Treat empty string the same as no argument. gdb/testsuite/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> PR symtab/12535: * gdb.python/python.exp: Test decode_line with empty string argument. Change-Id: I1d95812b4b7a21d69a3e9afd05b9e3141a931897
Fixed.