From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21966 invoked by alias); 16 Sep 2008 17:50:38 -0000 Received: (qmail 21957 invoked by uid 22791); 16 Sep 2008 17:50:36 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 16 Sep 2008 17:49:48 +0000 Received: from wpaz33.hot.corp.google.com (wpaz33.hot.corp.google.com [172.24.198.97]) by smtp-out.google.com with ESMTP id m8GHnfPn002157 for ; Tue, 16 Sep 2008 18:49:41 +0100 Received: from wa-out-1112.google.com (wagn7.prod.google.com [10.114.215.7]) by wpaz33.hot.corp.google.com with ESMTP id m8GHndwM019151 for ; Tue, 16 Sep 2008 10:49:40 -0700 Received: by wa-out-1112.google.com with SMTP id n7so1764842wag.13 for ; Tue, 16 Sep 2008 10:49:39 -0700 (PDT) Received: by 10.114.27.14 with SMTP id a14mr1140384waa.209.1221587379269; Tue, 16 Sep 2008 10:49:39 -0700 (PDT) Received: by 10.114.78.12 with HTTP; Tue, 16 Sep 2008 10:49:39 -0700 (PDT) Message-ID: <8ac60eac0809161049t6bd917bbk8127317a7d8b42cb@mail.gmail.com> Date: Tue, 16 Sep 2008 17:50:00 -0000 From: "Paul Pluzhnikov" To: gdb-patches@sourceware.org Subject: GDB aborts on missing command args. Which way to fix? MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-09/txt/msg00355.txt.bz2 Greetings, There are many instances of calls to buildargv() which aren't protected by 'if (args != NULL)', and cause gdb to abort. For example: (gdb) remote del # missing argument to del. Program received signal SIGABRT, Aborted. 0x00002aaaab5cac75 in *__GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig); (gdb-top) bt #0 0x00002aaaab5cac75 in *__GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #1 0x00002aaaab5cc620 in *__GI_abort () at ../sysdeps/generic/abort.c:88 #2 0x000000000044f1a5 in internal_vproblem (problem=0x9ad3c0, file=0x6454db "../../src/gdb/utils.c", line=1002, fmt=, ap=) at ../../src/gdb/utils.c:874 #3 0x000000000044c3c9 in internal_verror (file=0x32a
, line=6, fmt=0xffffffffffffffff
, ap=0x0) at ../../src/gdb/utils.c:889 #4 0x000000000044c461 in internal_error (file=0x32a
, line=810, string=0x6
) at ../../src/gdb/utils.c:898 #5 0x000000000044cf66 in nomem (size=0) at ../../src/gdb/utils.c:1002 #6 0x0000000000472db1 in remote_delete_command (args=, from_tty=0) at ../../src/gdb/remote.c:7231 #7 0x000000000044b323 in execute_command (p=0x9d91ca "", from_tty=0) at ../../src/gdb/top.c:457 #8 0x00000000004e9617 in command_handler (command=0x9d91c0 "remote del") at ../../src/gdb/event-top.c:514 #9 0x00000000004ea190 in command_line_handler (rl=) at ../../src/gdb/event-top.c:739 #10 0x0000000000597303 in rl_callback_read_char () at ../../src/readline/callback.c:205 #11 0x00000000004e9749 in rl_callback_read_char_wrapper (client_data=0x32a) at ../../src/gdb/event-top.c:178 #12 0x00000000004e83a3 in process_event () at ../../src/gdb/event-loop.c:341 #13 0x00000000004e8cb8 in gdb_do_one_event (data=) at ../../src/gdb/event-loop.c:378 #14 0x00000000004e54db in catch_errors (func=0x4e8b00 , func_args=0x0, errstring=0x64d064 "", mask=) at ../../src/gdb/exceptions.c:516 #15 0x0000000000490276 in tui_command_loop (data=) at ../../src/gdb/tui/tui-interp.c:153 #16 0x0000000000444139 in captured_command_loop (data=0x32a) at ../../src/gdb/main.c:99 #17 0x00000000004e54db in catch_errors (func=0x444130 , func_args=0x0, errstring=0x64d064 "", mask=) at ../../src/gdb/exceptions.c:516 #18 0x00000000004448de in captured_main (data=) at ../../src/gdb/main.c:831 #19 0x00000000004e54db in catch_errors (func=0x444170 , func_args=0x7fffffffe620, errstring=0x64d064 "", mask=) at ../../src/gdb/exceptions.c:516 #20 0x0000000000444124 in gdb_main (args=0x32a) at ../../src/gdb/main.c:840 #21 0x00000000004440f6 in main (argc=, argv=0x32a) at ../../src/gdb/gdb.c:33 I can fix this by adding the 'if (args != NULL)' checks everywhere, or by switching to 'buildargv_not_null(args, "appropriate missing argument error")' Which way is preferred? (I prefer the second way). Thanks, -- Paul Pluzhnikov