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.
My first guess is that this is a stack overflow.
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-speedand--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:
#514Last edit: 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.
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!
To be able to create a regression test for this bug it would help if there was a pragma to set no_side_channels.
There is.
Thanks, I will add a regression test using
#pragma nosidechannels.I have added the regression test in [patches:#514].
It is based on the same switch statements from
gcc-torture-execute-20011109-1.c, withI tested it without the
notInJumpTable()change, and the test failed.With the fix applied, the test passed.
Thanks!
Related
Patches:
#514Fixed in [r16836] by applying [patches:#514].
Related
Commit: [r16836]
Patches:
#514