Menu

#3270 SDCDB SegFault on 4.1.0

open
nobody
Tools
5
2023-09-17
2021-07-30
Elliot
No

sdcdb appears to be broken on 4.1.0 #12072 (Linux). SDCDB 0.9.
I compiled the attached trivial program with the following:
sdcc --debug -mmcs51 LedBlink.c

Upon running the debugger and setting a breakpoint I see a segfault:
elliot@P95xER:~/projects/test$ sdcdb LedBlink.cdb
file "LedBlink.ihx"
SDCDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for SDCDB; type "show warranty" for details.
SDCDB 0.9. Copyright (C) 1999 Sandeep Dutta (sandeep.dutta@usa.net)
Type ? for help
WARNING: SDCDB is EXPERIMENTAL.
(sdcdb) break main
Segmentation fault (core dumped)

After recompiling the latest and debugging the core file with gdb I see a NULL dereference at debugger/mcs51/cmd.c:396. mod struct is NULL.

396 if (srcMode == SRC_CMODE && line > mod->ncLines)

(gdb) bt
#0  0x0000564d0a9bf6a8 in setBPatModLine (mod=0x0, line=0, bpType=bpType@entry=4 '\004')
    at ../../../debugger/mcs51/cmd.c:396
#1  0x0000564d0a9bff0e in commonSetUserBp (s=0x564d0a9da3c6 <cmdbuff+6> "main", cctxt=0x564d0b9f74f0,
    bpType=<optimized out>) at ../../../debugger/mcs51/cmd.c:1163
#2  0x0000564d0a9ba8a8 in interpretCmd (s=s@entry=0x564d0a9da3c0 <cmdbuff> "break main")
    at ../../../debugger/mcs51/sdcdb.c:1036
#3  0x0000564d0a9baaee in commandLoop (cmdfile=0x7fbc410a19a0 <_IO_2_1_stdin_>) at ../../../debugger/mcs51/sdcdb.c:1650
#4  0x0000564d0a9b8b6e in main (argc=<optimized out>, argv=<optimized out>) at ../../../debugger/mcs51/sdcdb.c:2121
1 Attachments

Discussion

  • Elliot

    Elliot - 2021-08-05

    Another potentially interesting item to note is running sdcdb with -d=0xF I can see that the main function has no entry or exit.
    sdcdb: func 'main' has entry '0x0' exit '0x0'
    sdcdb: func '_main' has entry '0x0' exit '0x2f'
    sdcdb: function '_main' has the following C exePoints
    sdcdb: and the following ASM exePoints
    simi: openSimulator

    I'm wondering if the problem is actually symbol generation. I know sdcdb is experimental but is nobody else using it?

     
  • Mark Symonds

    Mark Symonds - 2022-08-31

    I believe I have been struggling with the same problem after upgrading from 3.6.0 to 4.2.0 running on Windows 10. Looking at the cdb file I see:

    M:main
    F:G$main$0_0$0({2}DF,SI:S),Z,0,0,0,0,0
    S:G$buff$0_0$0({20}DA20d,SC:U),E,0,0
    S:G$memcpy$0_0$0({2}DF,DG,SV:S),C,0,0
    S:G$memmove$0_0$0({2}DF,DG,SV:S),C,0,0
    ... etc

    Note the 0_0 in the scope level. This does not seem valid accoding to https://github.com/roybaer/sdcc-wiki/wiki/CDB-File-Format#41_Basic_Record_Format.
    Version 3.6.0 does not have these underscores.

    Minimal c source is

    #include "main.h"
    
    #include <string.h>
    
    char buff[20];
    
    int main(void)
    {
        strcpy(buff, "Hello world");
    
        return 0;
    }
    

    I manually modified the .cdb file to remove the underscore zero on all the the scope levels and sdcdb then stopped crashing when running and trying to set a break on main.

     
  • Loke

    Loke - 2023-09-17

    Hi. I am facing a similar problem. After the first step sdcdb crashes with Segmentation Fault.
    System: Debian
    Version: 4.2.0.

     

Log in to post a comment.

MongoDB Logo MongoDB