Bug 15453 - Free Pascal and Lazarus: Internal-error TYPE_CODE_UNDEF and crash when executing command 'ptype Form1.Test'
Summary: Free Pascal and Lazarus: Internal-error TYPE_CODE_UNDEF and crash when execut...
Alias: None
Product: gdb
Classification: Unclassified
Component: pascal (show other bugs)
Version: 7.6
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2013-05-09 22:03 UTC by evvke
Modified: 2018-04-27 21:28 UTC (History)
2 users (show)

See Also:
Last reconfirmed:

Patch for libiberty/xstrdup.c to prevent SIGSEGV. (407 bytes, application/octet-stream)
2013-05-09 22:03 UTC, evvke

Note You need to log in before you can comment on or make changes to this bug.
Description evvke 2013-05-09 22:03:12 UTC
Created attachment 7019 [details]
Patch for libiberty/xstrdup.c to prevent SIGSEGV.

See http://bugs.freepascal.org/view.php?id=24401 for more information and test project.

Lazarus uses MI interface to handle debugging process. Attached patch fixes sudden crash after executing command 'ptype Form1.Test'.
Comment 1 Tom Tromey 2013-05-10 01:31:46 UTC
Could you get a stack trace from gdb?  And, ideally, some simple test
source, plus compilation instructions, that shows the failure?

The patch you sent is definitely not the right fix --
nothing should pass NULL to xstrdup.  So the bug must be elsewhere.
Also, from the comments in the upstream bug I don't see how this
could fix it anyhow...

Comment 2 evvke 2013-05-10 11:19:50 UTC
Backtrace from GDB which are built from 7.6 source. 

#0 0x767143f9 in strlen () from C:\windows\syswow64\msvcrt.dll
0000001 0x006470d7 in xstrdup (s=0x0) at ./xstrdup.c:33
0000002 0x0044db2c in mi_cmd_interpreter_exec (
    command=0x6c286a <__PRETTY_FUNCTION__.21574+3209> "-interpreter-exec",
    argv=0x2a0fc40, argc=2) at ./mi/mi-interp.c:270
0000003 0x004512e2 in captured_mi_execute_command (context=0x311c70,
    uiout=0x312740) at ./mi/mi-main.c:1923
0000004 mi_execute_command (cmd=0x6d23960 "ptype Form1.Test", from_tty=1)
    at ./mi/mi-main.c:2003
0000005 0x0044c5d4 in mi_execute_command_wrapper (
    cmd=0x6d23960 "ptype Form1.Test") at ./mi/mi-interp.c:311
0000006 mi_execute_command_input_handler (cmd=0x6d23960 "ptype Form1.Test")
    at ./mi/mi-interp.c:319
0000007 0x004eb0e4 in handle_file_event (data=...) at event-loop.c:768
0000008 0x004eb4df in process_event () at event-loop.c:342
0000009 process_event () at event-loop.c:314
0000010 0x004eb845 in gdb_do_one_event () at event-loop.c:406
0000011 0x004eb997 in start_event_loop () at event-loop.c:431
0000012 0x004e5d22 in captured_command_loop (data=0x0) at main.c:258
0000013 0x004e4a73 in catch_errors (func=0x4e5d10 <captured_command_loop>,
    func_args=0x0, errstring=0x6fe967 <__PRETTY_FUNCTION__.11251+213> "",
    mask=6) at exceptions.c:546
0000014 0x004e67e9 in captured_main (data=0x2a0feb0) at main.c:1041
0000015 0x004e4a73 in catch_errors (func=0x4e5ed0 <captured_main>,
    errstring=0x6fe967 <__PRETTY_FUNCTION__.11251+213> "", mask=6)
    at exceptions.c:546
0000016 0x004e6de0 in gdb_main (args=0x2a0feb0) at main.c:1050
0000017 0x006a3748 in main (argc=5, argv=0x318a0) at gdb.c:34

These commands were run before executing process:

"maint set internal-error quit no"
"maint set internal-warning quit no"
"maint set internal-error corefile no"
Comment 3 evvke 2014-01-24 13:22:27 UTC
I can't reproduce anymore this bug in, git master commit 5acfdbae5d2b0aaa2320ddfa3aa1f2cddce7b978.
Comment 4 Tom Tromey 2018-04-27 21:28:17 UTC
Reported as fixed.