From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 0AC7C382AB71 for ; Wed, 14 Dec 2022 15:35:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0AC7C382AB71 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 62D261E112; Wed, 14 Dec 2022 10:35:15 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1671032115; bh=kAImSfx8Ky4Z2pWOjnSPmRa9Z7nbj/atzAfHIum7cFw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Rsn0biVIfM6bfA+oQRI0TbkdEbqTNLcwnFfY5zAxZ/jDDmaC5z6NZZSxCIUfA6Bzt fR6fpIYuIQi4EElIOfYvwbDGXBENZgEQQRsnH09cu7ogCiuQuan8sG3bEPRAY56woz 2cvhrhty+WPPYPEKgR+8xGCBifB+I2MsdWNU9Ztk= Message-ID: <86f0e86b-21cc-6d21-2ead-48d33d0837d1@simark.ca> Date: Wed, 14 Dec 2022 10:35:15 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH] gdb: fix command lookup in execute_command () commands" Content-Language: en-US To: Jan Vrany , gdb-patches@sourceware.org Cc: tom@tromey.com, luis.machado@arm.com References: <4dc13e01-2fd8-a63e-24f2-a1f7c7650d3b@simark.ca> <20221214110747.1150349-1-jan.vrany@labware.com> From: Simon Marchi In-Reply-To: <20221214110747.1150349-1-jan.vrany@labware.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > Hmm. I do not see these failures. When I run tests with second patch applied > atop of dc3fb44540 ("gdb/testsuite: avoid creating temp file in gdb/testsuite/ directory") > using command: > > make -C gdb check RUNTESTFLAGS='TRANSCRIPT=y gdb.base/*.exp' > > Then I do not see them: > > $ grep UNRESOLVED gdb.sum.with-second-patch > UNRESOLVED: gdb.base/gdb-sigterm.exp: 50 SIGTERM passes > $ grep DUPLICATE gdb.sum.with-second-patch > $ Can you try builing with ASan, or run the test under Valgrind? This is the kind of failures I see ASan reporting: ================================================================= ==2304586==ERROR: AddressSanitizer: heap-use-after-free on address 0x60300005d340 at pc 0x564a4ec9220a bp 0x7ffd634643f0 sp 0x7ffd634643e0 READ of size 1 at 0x60300005d340 thread T0 #0 0x564a4ec92209 in lookup_cmd_1(char const**, cmd_list_element*, cmd_list_element**, std::__cxx11::basic_string, std::allocator >*, int, bool) /home/smarchi/src/binutils-gdb/gdb/cli/cli-decode.c:1990 #1 0x564a4ec9338e in lookup_cmd(char const**, cmd_list_element*, char const*, std::__cxx11::basic_string, std::allocator >*, int, int) /home/smarchi/src/binutils-gdb/gdb/cli/cli-decode.c:2147 #2 0x564a50c8e3b2 in execute_command(char const*, int) /home/smarchi/src/binutils-gdb/gdb/top.c:701 #3 0x564a4f67dc89 in command_handler(char const*) /home/smarchi/src/binutils-gdb/gdb/event-top.c:616 #4 0x564a50c8c1d6 in read_command_file(_IO_FILE*) /home/smarchi/src/binutils-gdb/gdb/top.c:461 #5 0x564a4ed1ea61 in script_from_file(_IO_FILE*, char const*) /home/smarchi/src/binutils-gdb/gdb/cli/cli-script.c:1638 #6 0x564a4ec4cff3 in source_script_from_stream /home/smarchi/src/binutils-gdb/gdb/cli/cli-cmds.c:728 #7 0x564a4ec4d43b in source_script_with_search /home/smarchi/src/binutils-gdb/gdb/cli/cli-cmds.c:773 #8 0x564a4ec4da65 in source_command /home/smarchi/src/binutils-gdb/gdb/cli/cli-cmds.c:831 #9 0x564a4ec82cbc in do_simple_func /home/smarchi/src/binutils-gdb/gdb/cli/cli-decode.c:95 #10 0x564a4ec99059 in cmd_func(cmd_list_element*, char const*, int) /home/smarchi/src/binutils-gdb/gdb/cli/cli-decode.c:2543 #11 0x564a50c8e30d in execute_command(char const*, int) /home/smarchi/src/binutils-gdb/gdb/top.c:692 #12 0x564a4f67dc89 in command_handler(char const*) /home/smarchi/src/binutils-gdb/gdb/event-top.c:616 #13 0x564a4f67ed39 in command_line_handler(std::unique_ptr >&&) /home/smarchi/src/binutils-gdb/gdb/event-top.c:860 #14 0x564a50ddec69 in tui_command_line_handler /home/smarchi/src/binutils-gdb/gdb/tui/tui-interp.c:104 #15 0x564a4f67baef in gdb_rl_callback_handler /home/smarchi/src/binutils-gdb/gdb/event-top.c:246 #16 0x564a512a5683 in rl_callback_read_char /home/smarchi/src/binutils-gdb/readline/readline/callback.c:290 #17 0x564a4f67b4d9 in gdb_rl_callback_read_char_wrapper_noexcept /home/smarchi/src/binutils-gdb/gdb/event-top.c:188 #18 0x564a4f67b735 in gdb_rl_callback_read_char_wrapper /home/smarchi/src/binutils-gdb/gdb/event-top.c:221 #19 0x564a4f67d180 in stdin_event_handler /home/smarchi/src/binutils-gdb/gdb/event-top.c:541 #20 0x564a51682d64 in handle_file_event /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:573 #21 0x564a516836a3 in gdb_wait_for_event /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:694 #22 0x564a5168133c in gdb_do_one_event(int) /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:264 #23 0x564a4fdc136a in start_event_loop /home/smarchi/src/binutils-gdb/gdb/main.c:411 #24 0x564a4fdc17b0 in captured_command_loop /home/smarchi/src/binutils-gdb/gdb/main.c:471 #25 0x564a4fdc6bfb in captured_main /home/smarchi/src/binutils-gdb/gdb/main.c:1330 #26 0x564a4fdc6ce4 in gdb_main(captured_main_args*) /home/smarchi/src/binutils-gdb/gdb/main.c:1345 #27 0x564a4e35e33c in main /home/smarchi/src/binutils-gdb/gdb/gdb.c:32 #28 0x7f3fb381cd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 #29 0x7f3fb381ce3f in __libc_start_main_impl ../csu/libc-start.c:392 #30 0x564a4e35e114 in _start (/home/smarchi/build/binutils-gdb/gdb/gdb+0xa896114) 0x60300005d340 is located 0 bytes inside of 32-byte region [0x60300005d340,0x60300005d360) freed by thread T0 here: #0 0x7f3fb515bc18 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164 #1 0x564a4e603a29 in xrealloc /home/smarchi/src/binutils-gdb/gdb/alloc.c:75 #2 0x564a51669289 in buffer_grow(buffer*, char const*, unsigned long) /home/smarchi/src/binutils-gdb/gdbsupport/buffer.cc:40 #3 0x564a4f67de58 in command_line_append_input_line /home/smarchi/src/binutils-gdb/gdb/event-top.c:647 #4 0x564a4f67e0ce in handle_line_of_input(buffer*, char const*, int, char const*) /home/smarchi/src/binutils-gdb/gdb/event-top.c:686 #5 0x564a50c93555 in command_line_input(char const*, char const*) /home/smarchi/src/binutils-gdb/gdb/top.c:1421 #6 0x564a4ed0cc32 in read_next_line /home/smarchi/src/binutils-gdb/gdb/cli/cli-script.c:920 #7 0x564a4ed286f6 in gdb::function_view::bind(char const* (*)())::{lambda(gdb::fv_detail::erased_callable)#1}::operator()(gdb::fv_detail::erased_callable) const /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/function-view.h:326 #8 0x564a4ed28772 in gdb::function_view::bind(char const* (*)())::{lambda(gdb::fv_detail::erased_callable)#1}::_FUN(gdb::fv_detail::erased_callable) /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/function-view.h:320 #9 0x564a4ed25288 in gdb::function_view::operator()() const /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/function-view.h:289 #10 0x564a4ed1adf2 in read_command_lines_1(gdb::function_view, int, gdb::function_view) /home/smarchi/src/binutils-gdb/gdb/cli/cli-script.c:1234 #11 0x564a4ed1a997 in read_command_lines(char const*, int, int, gdb::function_view) /home/smarchi/src/binutils-gdb/gdb/cli/cli-script.c:1202 #12 0x564a4ed1c8e6 in do_define_command /home/smarchi/src/binutils-gdb/gdb/cli/cli-script.c:1450 #13 0x564a4ed1d2bc in define_command /home/smarchi/src/binutils-gdb/gdb/cli/cli-script.c:1500 #14 0x564a4ec82cbc in do_simple_func /home/smarchi/src/binutils-gdb/gdb/cli/cli-decode.c:95 #15 0x564a4ec99059 in cmd_func(cmd_list_element*, char const*, int) /home/smarchi/src/binutils-gdb/gdb/cli/cli-decode.c:2543 #16 0x564a50c8e30d in execute_command(char const*, int) /home/smarchi/src/binutils-gdb/gdb/top.c:692 #17 0x564a4f67dc89 in command_handler(char const*) /home/smarchi/src/binutils-gdb/gdb/event-top.c:616 #18 0x564a50c8c1d6 in read_command_file(_IO_FILE*) /home/smarchi/src/binutils-gdb/gdb/top.c:461 #19 0x564a4ed1ea61 in script_from_file(_IO_FILE*, char const*) /home/smarchi/src/binutils-gdb/gdb/cli/cli-script.c:1638 #20 0x564a4ec4cff3 in source_script_from_stream /home/smarchi/src/binutils-gdb/gdb/cli/cli-cmds.c:728 #21 0x564a4ec4d43b in source_script_with_search /home/smarchi/src/binutils-gdb/gdb/cli/cli-cmds.c:773 #22 0x564a4ec4da65 in source_command /home/smarchi/src/binutils-gdb/gdb/cli/cli-cmds.c:831 #23 0x564a4ec82cbc in do_simple_func /home/smarchi/src/binutils-gdb/gdb/cli/cli-decode.c:95 #24 0x564a4ec99059 in cmd_func(cmd_list_element*, char const*, int) /home/smarchi/src/binutils-gdb/gdb/cli/cli-decode.c:2543 #25 0x564a50c8e30d in execute_command(char const*, int) /home/smarchi/src/binutils-gdb/gdb/top.c:692 #26 0x564a4f67dc89 in command_handler(char const*) /home/smarchi/src/binutils-gdb/gdb/event-top.c:616 #27 0x564a4f67ed39 in command_line_handler(std::unique_ptr >&&) /home/smarchi/src/binutils-gdb/gdb/event-top.c:860 #28 0x564a50ddec69 in tui_command_line_handler /home/smarchi/src/binutils-gdb/gdb/tui/tui-interp.c:104 #29 0x564a4f67baef in gdb_rl_callback_handler /home/smarchi/src/binutils-gdb/gdb/event-top.c:246 previously allocated by thread T0 here: #0 0x7f3fb515b867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145 #1 0x564a4e603a3b in xrealloc /home/smarchi/src/binutils-gdb/gdb/alloc.c:77 #2 0x564a51669289 in buffer_grow(buffer*, char const*, unsigned long) /home/smarchi/src/binutils-gdb/gdbsupport/buffer.cc:40 #3 0x564a4f67de58 in command_line_append_input_line /home/smarchi/src/binutils-gdb/gdb/event-top.c:647 #4 0x564a4f67e0ce in handle_line_of_input(buffer*, char const*, int, char const*) /home/smarchi/src/binutils-gdb/gdb/event-top.c:686 #5 0x564a50c93555 in command_line_input(char const*, char const*) /home/smarchi/src/binutils-gdb/gdb/top.c:1421 #6 0x564a50c8c1b2 in read_command_file(_IO_FILE*) /home/smarchi/src/binutils-gdb/gdb/top.c:458 #7 0x564a4ed1ea61 in script_from_file(_IO_FILE*, char const*) /home/smarchi/src/binutils-gdb/gdb/cli/cli-script.c:1638 #8 0x564a4ec4cff3 in source_script_from_stream /home/smarchi/src/binutils-gdb/gdb/cli/cli-cmds.c:728 #9 0x564a4ec4d43b in source_script_with_search /home/smarchi/src/binutils-gdb/gdb/cli/cli-cmds.c:773 #10 0x564a4ec4da65 in source_command /home/smarchi/src/binutils-gdb/gdb/cli/cli-cmds.c:831 #11 0x564a4ec82cbc in do_simple_func /home/smarchi/src/binutils-gdb/gdb/cli/cli-decode.c:95 #12 0x564a4ec99059 in cmd_func(cmd_list_element*, char const*, int) /home/smarchi/src/binutils-gdb/gdb/cli/cli-decode.c:2543 #13 0x564a50c8e30d in execute_command(char const*, int) /home/smarchi/src/binutils-gdb/gdb/top.c:692 #14 0x564a4f67dc89 in command_handler(char const*) /home/smarchi/src/binutils-gdb/gdb/event-top.c:616 #15 0x564a4f67ed39 in command_line_handler(std::unique_ptr >&&) /home/smarchi/src/binutils-gdb/gdb/event-top.c:860 #16 0x564a50ddec69 in tui_command_line_handler /home/smarchi/src/binutils-gdb/gdb/tui/tui-interp.c:104 #17 0x564a4f67baef in gdb_rl_callback_handler /home/smarchi/src/binutils-gdb/gdb/event-top.c:246 #18 0x564a512a5683 in rl_callback_read_char /home/smarchi/src/binutils-gdb/readline/readline/callback.c:290 #19 0x564a4f67b4d9 in gdb_rl_callback_read_char_wrapper_noexcept /home/smarchi/src/binutils-gdb/gdb/event-top.c:188 #20 0x564a4f67b735 in gdb_rl_callback_read_char_wrapper /home/smarchi/src/binutils-gdb/gdb/event-top.c:221 #21 0x564a4f67d180 in stdin_event_handler /home/smarchi/src/binutils-gdb/gdb/event-top.c:541 #22 0x564a51682d64 in handle_file_event /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:573 #23 0x564a516836a3 in gdb_wait_for_event /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:694 #24 0x564a5168133c in gdb_do_one_event(int) /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:264 #25 0x564a4fdc136a in start_event_loop /home/smarchi/src/binutils-gdb/gdb/main.c:411 #26 0x564a4fdc17b0 in captured_command_loop /home/smarchi/src/binutils-gdb/gdb/main.c:471 #27 0x564a4fdc6bfb in captured_main /home/smarchi/src/binutils-gdb/gdb/main.c:1330 #28 0x564a4fdc6ce4 in gdb_main(captured_main_args*) /home/smarchi/src/binutils-gdb/gdb/main.c:1345 #29 0x564a4e35e33c in main /home/smarchi/src/binutils-gdb/gdb/gdb.c:32 Simon