Menu

#4066 tests/gcc-torture-execute-20011109-1.c fals for -mmcs51 --model-small --stack-auto --opt-code-speed --nolospre --nolabelopt --nosidechannels --max-allocs-per-node 512

closed-fixed
mcs51 (9)
MCS51
5
1 day ago
2026-08-24
No

To reproduce:

philipp@notebook7:~/sdcc-trunk/sdcc/support/regression$ make random-test-1594146079855823397 
Creating random-1594146079855823397 based on mcs51-small-stack-auto with additional options: --opt-code-speed --nolospre --nolabelopt --nosidechannels --max-allocs-per-node 512 
Running random-1594146079855823397 regression tests
Summary for 'random-1594146079855823397': 1 abnormal stops ( ), 0 failures, 27913 tests, 6279 test cases, 10437537 bytes, 8537655576 ticks
   abnormal stop: gcc-torture-execute-20011109-1.c

I see the bug on two Debian GNU/Linux systems: Debian testing on amd64, Debian unstable on powerpc64.

Related

Patches: #514

Discussion

  • Maarten Brock

    Maarten Brock - 4 days ago

    My first guess is that this is a stack overflow.

     
  • Li-Hsin Chien

    Li-Hsin Chien - 4 days ago

    I did some investigation on this issue.
    I removed the additional flags one by one, and the problem can be reproduced with only --opt-code-speed and --nosidechannels.

    The test mainly contains two switch statements, so I checked the generated assembly.
    Both switches use jump tables, and I noticed that peephole rules 260.i and 257.b are applied.

    Rule 260.i changes the jump table entries to 2-byte sjmp instructions.
    However, rule 257.b later changes some of them back to 3-byte ljmp instructions.
    I think this breaks the entry size of the jump table.

    I added notInJumpTable() to rule 257.b, and the original test passes with this change.

    I submitted [patches:#514] for review: https://sourceforge.net/p/sdcc/patches/514/
    Please let me know if this makes sense.

     

    Related

    Patches: #514


    Last edit: Maarten Brock 3 days ago
    • Maarten Brock

      Maarten Brock - 3 days ago

      Hi @janet-chien
      Can you please try to use [patches:#nnn] instead of a pasted URL next time? It gives the benefit of linking tracker items together.

       
      • Li-Hsin Chien

        Li-Hsin Chien - 3 days ago

        Thanks, I’ll use [patches:#nnn] next time.

        I also just noticed that you had already fixed the format for me on my previous patch.
        Sorry I didn’t notice that earlier, and thank you!

         
  • Maarten Brock

    Maarten Brock - 3 days ago

    To be able to create a regression test for this bug it would help if there was a pragma to set no_side_channels.

     
    • Philipp Klaus Krause

      There is.

      #pragma nosidechannels
      
       
    • Li-Hsin Chien

      Li-Hsin Chien - 3 days ago

      Thanks, I will add a regression test using #pragma nosidechannels.

       
    • Li-Hsin Chien

      Li-Hsin Chien - 3 days ago

      I have added the regression test in [patches:#514].

      It is based on the same switch statements from
      gcc-torture-execute-20011109-1.c, with

      #pragma opt_code_speed
      #pragma nosidechannels
      

      I tested it without the notInJumpTable() change, and the test failed.
      With the fix applied, the test passed.
      Thanks!

       

      Related

      Patches: #514

  • Maarten Brock

    Maarten Brock - 1 day ago
    • status: open --> closed-fixed
    • assigned_to: Maarten Brock
     

Log in to post a comment.