MarcoFalke
commented at 2:19 pm on May 6, 2019:
member
The gcc compiler creates “optimized” code (-finline-small-functions) that modifies in a second time after it has been initialized with random bits.
Working around the bug can be achieved in different ways: Moving in into a new const array, rearranging the loop to break the optimization, or moving the array into the outer scope, …
This fix is needed to release 0.18.1 on 32 bit platforms, thus needs backport.
test: Work around gcc compiler bug 90348faa924a942
MarcoFalke added the label
Refactoring
on May 6, 2019
MarcoFalke added the label
Tests
on May 6, 2019
MarcoFalke added the label
Needs backport
on May 6, 2019
MarcoFalke added this to the milestone 0.18.1
on May 6, 2019
luke-jr
commented at 2:23 pm on May 6, 2019:
member
Wouldn’t it be better to just add -fno-inline-small-functions when a broken compiler version is detected? (Isn’t this bug liable to affect other random bits of code?)
laanwj
commented at 2:31 pm on May 6, 2019:
member
Wouldn’t it be better to just add -fno-inline-small-functions when a broken compiler version is detected? (Isn’t this bug liable to affect other random bits of code?)
The one doesn’t rule out the other, though I would personally feel more comfortable with that solution. It’s unclear to me what else this bug might potentially affect.
practicalswift
commented at 2:54 pm on May 6, 2019:
contributor
Concept ACK on working around the GCC issue but I agree with @luke-jr and @laanwj that introducing -fno-inline-small-functions would be good.
I think we should add -fno-inline-small-functions when building with GCC and keep the code unchanged: that way we will notice if -fno-inline-small-functions is removed prematurely in the future (that is: before these GCC versions have died out).
MarcoFalke
commented at 2:58 pm on May 6, 2019:
member
Ok, marking up for grabs for someone to change the build system.
MarcoFalke added the label
Up for grabs
on May 6, 2019
MarcoFalke removed the label
Needs backport
on May 6, 2019
MarcoFalke removed this from the milestone 0.18.1
on May 6, 2019
gmaxwell
commented at 6:54 pm on May 7, 2019:
contributor
I would expect -fno-inline-small-functions to be devastating for performance and I also believe would not completely work around the bug. I believe -fstack-reuse=none would be a more correct, and less impacting, workaround.
luke-jr
commented at 8:42 pm on May 7, 2019:
member
I wonder if there’s a reliable compile test we could have configure run to detect the actual bug?
MarcoFalke
commented at 8:44 pm on May 7, 2019:
member
The test case from the gcc bug wouldn’t work? And if disabling fstack-reuse isn’t too expensive, we might just do it unconditionally?
I would also expect that -fstack-reuse=none has less impact than -fno-inline-small-functions, but benchmarks would be nice.
I’ll PR the reproduction bug as a unit test.
gmaxwell
commented at 9:30 pm on May 7, 2019:
contributor
stack-reuse=none also has the advantage of turning some lifetime management bugs into less-bugs (which is AFAICT why the option exists). I would expect it to increase stack usage, which right now we’re not currently particularly careful with.
gmaxwell
commented at 9:32 pm on May 7, 2019:
contributor
@luke-jr on reliability, I think we’d be better off detecting versions than trying to use the test case. Unfortunately, it’s unclear what versions this will be fixed in: (so far) it appears that this is actually hard for GCC to fix without severely gimping optimization.
FWIW, the test case does not fail on PPC but I am moderately confident that bug exists there (it might be just that the larger redzone on PPC results in a different stack layout).
laanwj
commented at 9:51 am on May 8, 2019:
member
Yes, -fstack-reuse=none would be better. Could do it unconditionally for gcc, at least for now. Then when there are versions that patch it, add exceptions.
MarcoFalke
commented at 6:22 pm on May 8, 2019:
member
Thanks everyone for the input, closing in favour of
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2024-11-17 15:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me