#1450 Crash in peephole optimizer

closed-fixed
5
2013-05-25
2008-04-20
No

I observe a crash (signal 11) in the peephole optimizer.

To reproduce:
Replace the content of src/z80/peeph.def by

replace restart {
pop %1
push %2
} by {
}

sdcc crashes when building asincosf from the library.

Philipp

Discussion

  • fullmetalcoder

    fullmetalcoder - 2009-07-29

    Proposed fix :

    SDCCpeep.c in static void replaceRule (lineNode ** shead, lineNode * stail, peepRule * pr) at line 2149 replace

    if (lhead)

    with

    if (lhead && cl)

    rationale : the segfault occurs only when the rule insert a new comment and no code, which leads to lhead being non-NULL and cl still being NULL at that point, thus IC-reassociation is attempted and the fourth parameter passed to reassociate_ic is NULL : KABOOOM!

    it should be possible to just check for the non-NULLity of cl but you can hardly be too careful...

     
  • Philipp Klaus Krause

    Fixed in rev #5486.

     
  • Philipp Klaus Krause

    • milestone: --> fixed
    • assigned_to: nobody --> spth
    • status: open --> closed-fixed
     

Log in to post a comment.