Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spirit Classic Codegen Bug with GCC in Release Builds #737

Open
cmazakas opened this issue Sep 23, 2022 · 3 comments
Open

Spirit Classic Codegen Bug with GCC in Release Builds #737

cmazakas opened this issue Sep 23, 2022 · 3 comments

Comments

@cmazakas
Copy link
Member

I've been working with @pdimov on some quickbook CI failures and I believe the cause of the issue is a codegen bug in gcc that seems to manifest in Spirit Classic. Namely, section IDs aren't being correctly produced when the qbk file contains:

[include:foo include-inc.quickbook]

More can be seen here: https://github.com/boostorg/quickbook/actions/runs/3046704503

This seems to be because of a codegen bug caused by certain versions of gcc (seemingly 9 through 12.1) with -O2 and higher.

I can replicate the issue here: https://godbolt.org/z/oa5b6j6Pd

Under -O1 and lower, the output is:

Current iterator range: foo

but with -O2 and higher,

Current iterator range: :foo

This is incorrect and is what is causing quickbook to generate incorrect output, which causes the test to fail.

I know that Classic is likely not under maintenance anymore but because quickbook is such an integral part of Boost and its toolchain, this might be worth fixing.

Let me know if any more information is required! The code in the Compiler Explorer example is a close copy-paste of the code used by quickbook today but can probably be simplified.

@Kojoley
Copy link
Collaborator

Kojoley commented Sep 23, 2022

Thanks for a reproducer, but I don't think I can offer any help beyond telling that it seems to be fixed in GCC 12.2, what you most likely already know? I poked the reproducer in CE and affected GCC versions are 9.2-12.1, and it is also vanishes when sanitization is enabled. I can report to GCC on your behalf that they had and issue which might be fixed by accident.

@Lastique
Copy link
Member

Lastique commented Sep 24, 2022

Is there a workaround possible on Boost.Spirit side? Or QuickBook?

@Kojoley
Copy link
Collaborator

Kojoley commented Sep 24, 2022

Massaging the parser helps avoid the bug for reproducer, so might be done something to Quickbook too https://godbolt.org/z/oGeqrP937

Lastique added a commit to Lastique/quickbook that referenced this issue Sep 24, 2022
gcc 9.2 through 12.1 has a code generation bug that result in incorrect
link ids for some sections in the generated XML.

This commit applies a workaround as suggested by Nikita Kniazev in:

boostorg/spirit#737 (comment)

Fixes boostorg#11.
Lastique added a commit to Lastique/quickbook that referenced this issue Sep 24, 2022
gcc 9.2 through 12.1 has a code generation bug that result in incorrect
link ids for some sections in the generated XML.

This commit applies a workaround as suggested by Nikita Kniazev in:

boostorg/spirit#737 (comment)

Fixes boostorg#11.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants