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

Implicit struct _GUID on Windows crashes DeclRewriter::detectInlineStruct #448

Closed
mattmccutchen-cci opened this issue Feb 25, 2021 · 2 comments · Fixed by #458
Closed

Implicit struct _GUID on Windows crashes DeclRewriter::detectInlineStruct #448

mattmccutchen-cci opened this issue Feb 25, 2021 · 2 comments · Fixed by #458

Comments

@mattmccutchen-cci
Copy link
Member

By default on Windows, Clang 11 injects an implicit struct _GUID declaration into every translation unit; this is new since Clang 9. This declaration has an invalid source location, so it causes an assertion failure in DeclRewriter::detectInlineStruct in 129 of our regression tests. We should probably just skip inline struct detection if the struct source location is invalid.

While the struct _GUID injection is enabled by default only on Windows, we can enable it on other OSes for testing purposes using the -fms-extensions compiler option. Thus, 3c ms-extensions.c -- -fms-extensions reproduces the problem if ms-extensions.c contains:

int *x;

Some options for testing:

  1. Just add the above as a regression test.
  2. Add an -fms-extensions regression test containing a manually curated wider variety of constructs.
  3. Develop a convenient way to run the entire regression test with -fms-extensions (likely easier with Refactor test RUN commands into a separate tool #355) and do that occasionally (we probably don't want to spend the time to run it on every change).
  4. Just rely on real testing on Windows to catch issues with -fms-extensions and anything else that differs on Windows.

I'm not sure which one offers the best trade-off between value and work.

@mattmccutchen-cci mattmccutchen-cci added the windows failure A bug causing a Windows-specific failure in the regression tests label Feb 25, 2021
@kyleheadley
Copy link
Member

I don't know any more than you've written here, so I vote 1. Maybe 2 with some structs if you have further reason to believe there will be a conflict with code. But 3 is too expensive and 4 catches problems too late.

@mattmccutchen-cci
Copy link
Member Author

Option 1 sounds good. Thanks Kyle. PR coming soon.

mattmccutchen-cci added a commit that referenced this issue Feb 26, 2021
locations.

Avoids a crash when an implicit `struct _GUID` is injected with an
invalid source location on Windows (fixes #448).
mattmccutchen-cci added a commit that referenced this issue Feb 26, 2021
…cations. (#458)

Avoids a crash when an implicit `struct _GUID` is injected with an
invalid source location on Windows (fixes #448).
@mattmccutchen-cci mattmccutchen-cci removed the windows failure A bug causing a Windows-specific failure in the regression tests label Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants