This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Leaks in gdb readline (old) version 6.2, fixed in readline 7


Valgrind detects leaks in readline library in several tests
(see stacktrace below, from the test gdb.linespec/cpls-ops.exp).

After investigation, the leak originates from readline/xfree.c:
void
xfree (string)
     PTR_T string;
{
  /* Leak a bit.  */
  if (RL_ISSTATE(RL_STATE_SIGHANDLER))
    return;

  if (string)
    free (string);
}

It took me a while to understand this leak, as it was
not very clear to me I had to step inside xfree to investigate
it :).

This 'by design' leak is fixed in readline 7, while
the GDB readline version is 6.2 according to the last
'import' message in readline ChangeLog.gdb.

On my system (debian 9.6), the leaks are fixed by using
   --with-system-readline=yes
with the system readline version being 7.0-3

Switching to this readline version causes the following checks to fail:
FAIL: gdb.gdb/selftest.exp: send SIGINT signal to child process (timeout)
FAIL: gdb.gdb/selftest.exp: thread 1 (timeout)
FAIL: gdb.gdb/selftest.exp: backtrace through signal handler (timeout)

Apart of that, no problem seen.

Philippe


==18242== 554,058 (66,624 direct, 487,434 indirect) bytes in 2,082 blocks are definitely lost in loss record 2,880 of 2,880
==18242==    at 0x4C2BE6D: malloc (vg_replace_malloc.c:309)
==18242==    by 0x409C27: xmalloc (common-utils.c:44)
==18242==    by 0x6B294E: alloc_undo_entry (undo.c:79)
==18242==    by 0x6B294E: rl_add_undo (undo.c:99)
==18242==    by 0x6B4DC5: rl_insert_text (text.c:111)
==18242==    by 0x6A5219: append_to_match (complete.c:1746)
==18242==    by 0x6A731F: rl_complete_internal (complete.c:1935)
==18242==    by 0x69F66A: _rl_dispatch_subseq (readline.c:774)
==18242==    by 0x69F975: _rl_dispatch (readline.c:724)
==18242==    by 0x69F975: readline_internal_char (readline.c:552)
==18242==    by 0x6B3F64: rl_callback_read_char (callback.c:201)
==18242==    by 0x4A2C2D: gdb_rl_callback_read_char_wrapper_noexcept() (event-top.c:175)
==18242==    by 0x4A2C98: gdb_rl_callback_read_char_wrapper(void*) (event-top.c:192)
==18242==    by 0x4A31BF: stdin_event_handler(int, void*) (event-top.c:511)
==18242==    by 0x4A200C: gdb_wait_for_event(int) (event-loop.c:859)
==18242==    by 0x4A2116: gdb_do_one_event() [clone .part.4] (event-loop.c:322)
==18242==    by 0x4A22D4: gdb_do_one_event (common-exceptions.h:219)
==18242==    by 0x4A22D4: start_event_loop() (event-loop.c:371)
==18242==    by 0x53F907: captured_command_loop() (main.c:330)
==18242==    by 0x5408FC: captured_main (main.c:1177)
==18242==    by 0x5408FC: gdb_main(captured_main_args*) (main.c:1193)
==18242==    by 0x289CA7: main (gdb.c:32)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]