Bug 18303 - Assertation: -breakpoint-insert with windows paths of file in non-current directory
Summary: Assertation: -breakpoint-insert with windows paths of file in non-current dir...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: breakpoints (show other bugs)
Version: 7.9
: P2 normal
Target Milestone: 7.12
Assignee: Don Breazeal
URL:
Keywords:
: 21829 27183 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-04-22 22:59 UTC by RedSkotina
Modified: 2024-07-06 13:04 UTC (History)
7 users (show)

See Also:
Host: i686-w64-mingw32
Target: i686-w64-mingw32
Build: i686-w64-mingw32
Last reconfirmed:


Attachments
patch for fix problem with update childrens of dynamic varobj (454 bytes, patch)
2015-05-02 07:38 UTC, RedSkotina
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description RedSkotina 2015-04-22 22:59:55 UTC
Overview: 

gdb crashed while trying insert breakpoint at file with windows paths if file not exist in current directory

Steps to Reproduce:

gdb --batch --interpreter=mi2 -q -nx  -x mintest.mi

# mintest.mi
interpreter-exec mi "-file-exec-and-symbols --thread-group i1 pretty_printing_test.exe"
interpreter-exec mi "-break-insert -f -t main"
interpreter-exec mi "-exec-run"
interpreter-exec mi "-break-insert -f \"c:/uu.cpp:13\""

Actual Results:

c:\gdb79\bin>gdb --batch --interpreter=mi2 -q -nx  -x mintest.mi  
=thread-group-added,id="i1"
~"^done\n"
~"^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"0x00401545\",func=\"main(int, char**)\",file=\"D:/code/testx/testx/pretty_printing_test/main.cpp\",fullname=\"D:\\\\code\\\\testx\\\\testx\\\\pretty_printing_test\\\\main.cpp\",line=\"15\",thread-groups=[\"i1\"],times=\"0\",original-location=\"main\"}\n"
=thread-group-started,id="i1",pid="1992"
=thread-created,id="1",group-id="i1"
~"~\"[New Thread 1992.0x1830]\\n\"\n"
~"^running\n"
~"*running,thread-id=\"all\"\n"
~"(gdb) \n"
=library-loaded,id="C:\\Windows\\SysWOW64\\ntdll.dll",target-name="C:\\Windows\\SysWOW64\\ntdll.dll",host-name="C:\\Windows\\SysWOW64\\ntdll.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\kernel32.dll",target-name="C:\\Windows\\syswow64\\kernel32.dll",host-name="C:\\Windows\\syswow64\\kernel32.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\KernelBase.dll",target-name="C:\\Windows\\syswow64\\KernelBase.dll",host-name="C:\\Windows\\syswow64\\KernelBase.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\msvcrt.dll",target-name="C:\\Windows\\syswow64\\msvcrt.dll",host-name="C:\\Windows\\syswow64\\msvcrt.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="c:\\gdb79\\opt\\bin\\libgcc_s_sjlj-1.dll",target-name="c:\\gdb79\\opt\\bin\\libgcc_s_sjlj-1.dll",host-name="c:\\gdb79\\opt\\bin\\libgcc_s_sjlj-1.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="c:\\gdb79\\opt\\bin\\libwinpthread-1.dll",target-name="c:\\gdb79\\opt\\bin\\libwinpthread-1.dll",host-name="c:\\gdb79\\opt\\bin\\libwinpthread-1.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\TDM-GCC-64\\bin\\libstdc++-6.dll",target-name="C:\\TDM-GCC-64\\bin\\libstdc++-6.dll",host-name="C:\\TDM-GCC-64\\bin\\libstdc++-6.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\user32.dll",target-name="C:\\Windows\\syswow64\\user32.dll",host-name="C:\\Windows\\syswow64\\user32.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\gdi32.dll",target-name="C:\\Windows\\syswow64\\gdi32.dll",host-name="C:\\Windows\\syswow64\\gdi32.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\lpk.dll",target-name="C:\\Windows\\syswow64\\lpk.dll",host-name="C:\\Windows\\syswow64\\lpk.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\usp10.dll",target-name="C:\\Windows\\syswow64\\usp10.dll",host-name="C:\\Windows\\syswow64\\usp10.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\advapi32.dll",target-name="C:\\Windows\\syswow64\\advapi32.dll",host-name="C:\\Windows\\syswow64\\advapi32.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\SysWOW64\\sechost.dll",target-name="C:\\Windows\\SysWOW64\\sechost.dll",host-name="C:\\Windows\\SysWOW64\\sechost.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\rpcrt4.dll",target-name="C:\\Windows\\syswow64\\rpcrt4.dll",host-name="C:\\Windows\\syswow64\\rpcrt4.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\sspicli.dll",target-name="C:\\Windows\\syswow64\\sspicli.dll",host-name="C:\\Windows\\syswow64\\sspicli.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\cryptbase.dll",target-name="C:\\Windows\\syswow64\\cryptbase.dll",host-name="C:\\Windows\\syswow64\\cryptbase.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\SysWOW64\\imm32.dll",target-name="C:\\Windows\\SysWOW64\\imm32.dll",host-name="C:\\Windows\\SysWOW64\\imm32.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="C:\\Windows\\syswow64\\msctf.dll",target-name="C:\\Windows\\syswow64\\msctf.dll",host-name="C:\\Windows\\syswow64\\msctf.dll",symbols-loaded="0",thread-group="i1"
=library-loaded,id="c:\\ansicon\\ANSI32.dll",target-name="c:\\ansicon\\ANSI32.dll",host-name="c:\\ansicon\\ANSI32.dll",symbols-loaded="0",thread-group="i1"
=breakpoint-modified,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x00401545",func="main(int, char**)",file="D:/code/testx/testx/pretty_printing_test/main.cpp",fullname="D:\\code\\testx\\testx\\pretty_printing_test\\main.cpp",line="15",thread-groups=["i1"],times="1",original-location="main"}
~"*stopped,reason=\"breakpoint-hit\",disp=\"del\",bkptno=\"1\",frame={addr=\"0x00401545\",func=\"main\",args=[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\"0x602c58\"}],file=\"D:/code/testx/testx/pretty_printing_test/main.cpp\",fullname=\"D:\\\\code\\\\testx\\\\testx\\\\pretty_printing_test\\\\main.cpp\",line=\"15\"},thread-id=\"1\",stopped-threads=\"all\"\n"
=breakpoint-deleted,id="1"
~"~\"cp-namespace.c:341: internal-error: cp_search_static_and_baseclasses: Assertion `name[prefix_len + 1] == ':'' failed.\\nA problem internal to GDB has been detected,\\nfurther debugging may prove unreliable.\\nQuit this debugging session? \"\n"
~"~\"(y or n) [answered Y; input not from terminal]\\n\"\n"
~"&\"\\nThis is a bug, please report it.\"\n"
~"&\"  For instructions, see:\\n<http://www.gnu.org/software/gdb/bugs/>.\"\n"
~"&\"\\n\\n\"\n"
~"~\"cp-namespace.c:341: internal-error: cp_search_static_and_baseclasses: Assertion `name[prefix_len + 1] == ':'' failed.\\nA problem internal to GDB has been detected,\\nfurther debugging may prove unreliable.\\nCreate a core file of GDB? \"\n"
~"~\"(y or n) [answered Y; input not from terminal]\\n\"\n"
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Expected Results:
 
~"&\"No source file named uu.cpp.\\n\"\n"
~"^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=
\"<PENDING>\",pending=\"uu.cpp:13\",times=\"0\",original-location=\"c:/uu.cpp:13\"}
\n"

Build Date & Hardware: 
Build 2015-22-04 on Windows 7 x64 (i686-mingw-w64)

Additional Information:
Probably gdb consider breakpoint argument be namespace instead file
Comment 1 RedSkotina 2015-04-25 14:03:51 UTC
problem in linespec.c:2288
       else
	{
	  /* No symtabs found -- discard user_filename.  */
	  xfree (user_filename);

	  /* A NULL entry means to use GLOBAL_DEFAULT_SYMTAB.  */
	  VEC_safe_push (symtab_ptr, PARSER_RESULT (parser)->file_symtabs, NULL);
	}

need consume token for parse the rest of linespec or rethrow error. i dont so familiar with code of gdb for choose best solution. 
//replace 
//linespec.c:2288
else
{
    /* No symtabs found -- discard user_filename.  */
    xfree (user_filename);

   /* A NULL entry means to use GLOBAL_DEFAULT_SYMTAB.  */
   VEC_safe_push (symtab_ptr, PARSER_RESULT (parser)->file_symtabs, NULL);
  
   /* Get the next token.  */
   token = linespec_lexer_consume_token (parser);

   /* This is LSTOKEN_COLON; consume it.  */
   linespec_lexer_consume_token (parser);
}

OR
//linespec.c:2288
else
{
   size_t MAX_PATH = 260;
   char user_filename_temp_copy[MAX_PATH];
   snprintf(user_filename_temp_copy,MAX_PATH,"%s",user_filename);
   throw_error (NOT_FOUND_ERROR, _("No source file named %s."), user_filename_temp_copy);
}
Comment 2 RedSkotina 2015-04-25 14:07:45 UTC
i miss free user_filename

//linespec.c:2288
else
{
      size_t MAX_PATH = 260;
      char user_filename_temp_copy[MAX_PATH];
      snprintf(user_filename_temp_copy,MAX_PATH,"%s",user_filename);
      /* No symtabs found -- discard user_filename.  */
	  xfree (user_filename);
      throw_error (NOT_FOUND_ERROR, _("No source file named %s."), user_filename_temp_copy);
}
Comment 3 RedSkotina 2015-05-02 07:38:38 UTC
Created attachment 8297 [details]
patch for fix problem with update childrens of dynamic varobj

experienced gdb developers must test this patch
(warning: nonfullverified, brutforce method)
Comment 4 RedSkotina 2015-05-02 12:57:58 UTC
sor for missclick. this patch for bug #18332
Comment 5 Cezary Śliwa 2015-08-06 18:01:06 UTC
This occurs also on x86_64-w64-mingw32 (Windows 7 64-bit) with gdb 7.9.1.
Comment 6 Keith Seitz 2016-02-25 18:13:31 UTC
Proposed upstream patch: https://sourceware.org/ml/gdb-patches/2016-01/msg00715.html
Comment 7 Sourceware Commits 2016-03-15 22:27:21 UTC
The master branch has been updated by Don Breazeal <donb@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1cafadb4e4eb329dea01355c6632b3077113d80c

commit 1cafadb4e4eb329dea01355c6632b3077113d80c
Author: Don Breazeal <donb@codesourcery.com>
Date:   Tue Mar 15 15:18:28 2016 -0700

    PR 18303, Tolerate malformed input for lookup_symbol-called functions
    
    lookup_symbol is often called with user input.  Consequently, any
    function called from lookup_symbol{,_in_language} should attempt to
    deal with malformed input gracefully.  After all, malformed user
    input is not a programming/API error.
    
    This patch does not attempt to find/correct all instances of this.  It
    only fixes locations in the code that trigger test suite failures.
    
    This patch fixes PR breakpoints/18303, "Assertion: -breakpoint-insert
    with windows paths of file in non-current directory".
    
    The patch includes three new tests related to this.  One is just
    gdb.linespec/ls-errs.exp copied and converted to use C++ instead of C, and
    to add a case using a file name containing a Windows-style logical drive
    specifier.  The others include an MI test to provide a regression test for
    the specific case reported in PR 18303, and a C++ test for proper error
    handling of access to a program variable when using a file scope specifier
    that refers to a non-existent file.
    
    Tested on x86_64 native Linux.
    
    gdb/ChangeLog
    2016-01-28  Keith Seitz  <keiths@redhat.com>
    
    	PR breakpoints/18303
    	* cp-namespace.c (cp_lookup_bare_symbol): Change assertion to
    	look for "::" instead of simply ":".
    	(cp_search_static_and_baseclasses): Return null_block_symbol for
    	malformed input.
    	Remove assertions.
    	* cp-support.c (cp_find_first_component_aux): Do not return
    	a prefix length for ':' unless the next character is also ':'.
    
    gdb/testsuite/ChangeLog
    2016-01-28  Don Breazeal  <donb@codesourcery.com>
    
    	* gdb.cp/scope-err.cc: New test program.
    	* gdb.cp/scope-err.exp: New test script.
    	* gdb.linespec/ls-errs.c (myfunction): Expanded to have multiple
    	lines and "set breakpoint here" comment.
    	* gdb.linespec/ls-errs.exp: Added C++ testing and new test case.
    	Fixed some whitespace and format issues.
    	* gdb.mi/mi-linespec-err-cp.cc: New test program.
    	* gdb.mi/mi-linespec-err-cp.exp: New test script.
Comment 8 Don Breazeal 2016-03-15 22:51:46 UTC
Resolved per GDB commit listed here.
Comment 9 Keith Seitz 2017-07-28 16:45:41 UTC
*** Bug 21829 has been marked as a duplicate of this bug. ***
Comment 10 Hannes Domani 2024-07-06 13:04:00 UTC
*** Bug 27183 has been marked as a duplicate of this bug. ***