Menu

#3012 Infinite loop with "

closed-fixed
None
Front-end
5
2023-01-26
2020-06-03
No

"

This line (yes, really, just a "), results in an infinite loop with sdcc-sdcc test.c, the tested version is mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ez80_z80/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15 4.0.0 #11528 (Linux)

Related

Wiki: NGI0-Entrust-SDCC

Discussion

  • Philipp Klaus Krause

    I can reproduce the issue on my Debian GNU/Linux system using SDCC 4.0.2 #11640 compiled using flex 2.6.4.

    A closer look shows that in SDCC.lex, the code for scanning string literals assumes that flex input() return EOF at the end of the file. But gdb shows that it instead returns 0 (and calls yywrap().

    This problem is specific to flex 2.6.4, with flex 2.5.4, we get EOF, and SDCC works as expected.

    I have no idea what input() should do. The only information I found in the flex manual was in the "Lex and POSIX" section:

    If 'input()' encounters an end-of-file the normal 'yywrap()' processing is done.  A "real" end-of-file is returned by 'input()' as 'EOF'.
    

    This text is the same in both the flex 2.6.4 and 2.5.4 manuals.

    P.S.: I found this Debian bug report abut the undocumented change in flex behaviour:
    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911415

    P.P.S.: I opened an issue for flex:
    https://github.com/westes/flex/issues/448

     

    Last edit: Philipp Klaus Krause 2020-06-03
  • Philipp Klaus Krause

    • status: open --> closed-fixed
    • assigned_to: Philipp Klaus Krause
    • Category: other --> Front-end
     
  • Philipp Klaus Krause

    Looks like flex won't change back to EOF (despite their documentation today still claiming that EOF is returned). And apparently returning 0 is ok by POSIX.
    As of [r13827], SDCC should work with both EOF-returning and 0-returning lex.

     

    Related

    Commit: [r13827]


Log in to post a comment.