#800 SIGSEGV on one liner function call

closed-fixed
5
2013-05-25
2004-08-20
No

The following code give me a SIGSEGV.

Run with : sdcc -c test.c

SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
2.4.3 #800 (Aug 13 2004) (UNIX)

[code]
unsigned char inc(unsigned char value)
{
return value + 1;
}

static unsigned char c = 0;

void foo()
{
c = inc(c);
}
[/code]

Discussion

  • Yee_Keat Phuah

    Yee_Keat Phuah - 2004-08-20

    Logged In: YES
    user_id=940150

    The culprit seems to be in mcs51/ralloc.c, line 2379

    [code]
    /* now check if it is the return from
    a function call */
    if (dic->op == CALL || dic->op == PCALL)
    {
    if (ic->op != SEND && ic->op != RETURN &&
    !POINTER_SET(ic) && !POINTER_GET(ic))
    {
    OP_SYMBOL (op)->ruonly = 1;
    return dic;
    }
    dic = dic->next;
    }
    [/code]

    dic->next is null, and the access of IC_LEFT(dic) below that
    function segfaults.

    I tested commenting out the dic=dic->next, it does not
    segfaults anymore, and all the regression tests still
    passes. Not sure if the fix should be commenting it out or
    returning of dic==NULL.

     
  • Erik Petrich

    Erik Petrich - 2004-08-21
    • status: open --> closed
     
  • Erik Petrich

    Erik Petrich - 2004-08-21

    Logged In: YES
    user_id=635249

    Fixed in src/mcs51/ralloc.c 1.130

     
  • Erik Petrich

    Erik Petrich - 2004-08-21
    • labels: --> mcs51(8051) target
    • milestone: --> fixed
    • assigned_to: nobody --> epetrich
    • status: closed --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks