From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25943 invoked by alias); 7 Feb 2008 22:26:25 -0000 Received: (qmail 25798 invoked by uid 22791); 7 Feb 2008 22:25:21 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 07 Feb 2008 22:25:04 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 50B712AAE87 for ; Thu, 7 Feb 2008 17:25:02 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id VxHc6GKk0tPc for ; Thu, 7 Feb 2008 17:25:02 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id DF29E2AAE86 for ; Thu, 7 Feb 2008 17:25:01 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id C4294E7ACB; Thu, 7 Feb 2008 14:24:59 -0800 (PST) Date: Thu, 07 Feb 2008 22:26:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFA/commit(Ada)] SEGV during symbol completion - VEC usage issue Message-ID: <20080207222459.GF3907@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="OBd5C1Lgu00Gd/Tn" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i 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-02/txt/msg00139.txt.bz2 --OBd5C1Lgu00Gd/Tn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1149 It's weird that I didn't spot this problem earlier: When the number of possible completions exceeds 128 (the initial size of the VEC we use to store all completions), the debugger segfaults. The problem, I think, is that I didn't understand how VEC_safe_push works underneath. I didn't realize that this routine would change the value of the given VEC*, I thought it would only change the underlying record. I used to have: procedure bla (VEC(char_ptr) *sv, ...) { ... VEC_safe_push (char_ptr, sv, some_string); } When SV had to be expanded, the value of SV ended up being changed, but this new address was never propagated back to the caller. So I fixed the problem by turning parameter SV into a VEC**. 2008-02-07 Joel Brobecker * ada-lang.c (symbol_completion_add): Make SV parameter a VEC** instead of just a VEC*. Update use of SV. (ada_make_symbol_completion_list): Update symbol_completion_add calls. Tested on x86-linux, no regression. I'll commit now because it cures a SEGV that is easy to hit, but I'd appreciate a second pair of eyes... Thanks, -- Joel --OBd5C1Lgu00Gd/Tn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="VEC.diff" Content-length: 3106 Index: ada-lang.c =================================================================== --- ada-lang.c (revision 167) +++ ada-lang.c (revision 168) @@ -5498,7 +5498,7 @@ DEF_VEC_P (char_ptr); encoded). */ static void -symbol_completion_add (VEC(char_ptr) *sv, +symbol_completion_add (VEC(char_ptr) **sv, const char *sym_name, const char *text, int text_len, const char *orig_text, const char *word, @@ -5534,7 +5534,7 @@ symbol_completion_add (VEC(char_ptr) *sv strcat (completion, match); } - VEC_safe_push (char_ptr, sv, completion); + VEC_safe_push (char_ptr, *sv, completion); } /* Return a list of possible symbol names completing TEXT0. The list @@ -5597,7 +5597,7 @@ ada_make_symbol_completion_list (char *t + ps->n_global_syms); psym++) { QUIT; - symbol_completion_add (completions, SYMBOL_LINKAGE_NAME (*psym), + symbol_completion_add (&completions, SYMBOL_LINKAGE_NAME (*psym), text, text_len, text0, word, wild_match, encoded); } @@ -5607,7 +5607,7 @@ ada_make_symbol_completion_list (char *t + ps->n_static_syms); psym++) { QUIT; - symbol_completion_add (completions, SYMBOL_LINKAGE_NAME (*psym), + symbol_completion_add (&completions, SYMBOL_LINKAGE_NAME (*psym), text, text_len, text0, word, wild_match, encoded); } @@ -5621,7 +5621,7 @@ ada_make_symbol_completion_list (char *t ALL_MSYMBOLS (objfile, msymbol) { QUIT; - symbol_completion_add (completions, SYMBOL_LINKAGE_NAME (msymbol), + symbol_completion_add (&completions, SYMBOL_LINKAGE_NAME (msymbol), text, text_len, text0, word, wild_match, encoded); } @@ -5635,7 +5635,7 @@ ada_make_symbol_completion_list (char *t ALL_BLOCK_SYMBOLS (b, iter, sym) { - symbol_completion_add (completions, SYMBOL_LINKAGE_NAME (sym), + symbol_completion_add (&completions, SYMBOL_LINKAGE_NAME (sym), text, text_len, text0, word, wild_match, encoded); } @@ -5650,7 +5650,7 @@ ada_make_symbol_completion_list (char *t b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); ALL_BLOCK_SYMBOLS (b, iter, sym) { - symbol_completion_add (completions, SYMBOL_LINKAGE_NAME (sym), + symbol_completion_add (&completions, SYMBOL_LINKAGE_NAME (sym), text, text_len, text0, word, wild_match, encoded); } @@ -5665,7 +5665,7 @@ ada_make_symbol_completion_list (char *t continue; ALL_BLOCK_SYMBOLS (b, iter, sym) { - symbol_completion_add (completions, SYMBOL_LINKAGE_NAME (sym), + symbol_completion_add (&completions, SYMBOL_LINKAGE_NAME (sym), text, text_len, text0, word, wild_match, encoded); } --OBd5C1Lgu00Gd/Tn--