Skip to content

Don’t crash from circular swift_name attributes #37940

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

Merged
merged 1 commit into from
Jun 17, 2021

Conversation

beccadax
Copy link
Contributor

If a swift_name attribute’s context referred to the same declaration it was attached to, or a different declaration whose own swift_name referred to the current one, we would recurse infinitely and eventually overflow the stack. This commit makes us instead detect the cycle, diagnose it with a warning, and drop the affected declaration.

Fixes rdar://79370809.

If a swift_name attribute’s context referred to the same declaration it was attached to, or a different declaration whose own swift_name referred to the current one, we would recurse infinitely and eventually overflow the stack. This commit makes us instead detect the cycle, diagnose it with a warning, and drop the affected declaration.

Fixes rdar://79370809.
@beccadax
Copy link
Contributor Author

@swift-ci please smoke test

@beccadax
Copy link
Contributor Author

@CodaFi My impression is that it would be too painful to try to start requestifying here. Do you agree?

@CodaFi
Copy link
Contributor

CodaFi commented Jun 16, 2021

‘Long as module loading doesn’t happen on these paths it’ll be gnarly but not impossible.

@beccadax beccadax merged commit 528764c into swiftlang:main Jun 17, 2021
@beccadax
Copy link
Contributor Author

I've been fiddling with the request evaluator but it's been really finicky, so I'll stick with this implementation for now.

beccadax added a commit to beccadax/swift that referenced this pull request Jul 14, 2021
…ames

Don’t crash from circular swift_name attributes
tshortli added a commit to tshortli/swift that referenced this pull request Jan 20, 2024
When building the Swift sources of the compiler many of the following warnings
are emitted:

```
.../swift-project/swift/include/swift/AST/Attr.h:3075:10: warning: cycle detected while resolving 'iterator' in swift_name attribute for 'operator=='
    bool operator==(iterator x) const { return x.attr == attr; }
         ^
```

These warnings were implemented in swiftlang#37940
and they indicate that Swift compiler is failing to import a clang decl because
of circular references. Something about the structure of some operator
declarations in C++ headers triggers this warning. I'm not sure what the
correct long term fix for this is, but in the meantime the build log for the
compiler is getting drowned in these warnings which makes it difficult to
notice and find other diagnostics. Since these declarations are getting dropped
instead of imported, we can simply hide them from the Swift compiler in the
first place by guarding the declarations with `#ifdef __swift__`.
tshortli added a commit to tshortli/swift that referenced this pull request Jan 20, 2024
When building the Swift sources of the compiler many instances of the following
warning are emitted:

```
.../swift-project/swift/include/swift/AST/Attr.h:3075:10: warning: cycle detected while resolving 'iterator' in swift_name attribute for 'operator=='
    bool operator==(iterator x) const { return x.attr == attr; }
         ^
```

These warnings were implemented in swiftlang#37940
and they indicate that Swift compiler is failing to import a clang decl because
of circular references. Something about the structure of some operator
declarations in C++ headers triggers this warning. I'm not sure what the
correct long term fix for this is, but in the meantime the build log for the
compiler is getting drowned in these warnings which makes it difficult to
notice and find other diagnostics. Since these declarations are getting dropped
instead of imported, we can simply hide them from the Swift compiler in the
first place by guarding the declarations with `#ifdef __swift__`.
carlos4242 pushed a commit to carlos4242/swift that referenced this pull request May 31, 2024
When building the Swift sources of the compiler many instances of the following
warning are emitted:

```
.../swift-project/swift/include/swift/AST/Attr.h:3075:10: warning: cycle detected while resolving 'iterator' in swift_name attribute for 'operator=='
    bool operator==(iterator x) const { return x.attr == attr; }
         ^
```

These warnings were implemented in swiftlang#37940
and they indicate that Swift compiler is failing to import a clang decl because
of circular references. Something about the structure of some operator
declarations in C++ headers triggers this warning. I'm not sure what the
correct long term fix for this is, but in the meantime the build log for the
compiler is getting drowned in these warnings which makes it difficult to
notice and find other diagnostics. Since these declarations are getting dropped
instead of imported, we can simply hide them from the Swift compiler in the
first place by guarding the declarations with `#ifdef __swift__`.
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

Successfully merging this pull request may close these issues.

2 participants