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

[SR-14158] Nondeterminism on macOS for C struct identity #56537

Open
swift-ci opened this issue Feb 5, 2021 · 0 comments
Open

[SR-14158] Nondeterminism on macOS for C struct identity #56537

swift-ci opened this issue Feb 5, 2021 · 0 comments

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Feb 5, 2021

Previous ID SR-14158
Radar None
Original Reporter george (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: c5751a191ee27027a9454fdb6641ece3

Issue Description:

Update: it seems like removing any references to the `MlirDialectRegistrationHooks` is an effective workaround for this issue. This is just speculation, but this seems to imply that the issue is the hashing strategy which seems like it is used to determine C struct identity has a nondeterminism on macOS. For more discussion, consult this forum thread: https://llvm.discourse.group/t/strange-swift-issues-with-dialect-registration-hooks/2759/4

The project where this occurred is open source, and the GitHub Action output can be found here: https://github.com/GeorgeLyon/MLIRSwift/runs/1840955527?check_suite_focus=true

Basically, I have a project with three system library targets, each of which ends up including a C header file "Registration.h". When building a target that depends on more than one of these libraries, compilation fails on macOS but not Linux reporting the following error:

Registration.h:64:31: error: 'MlirDialectRegistrationHooks' has different definitions in different modules; first difference is definition in module 'CSCF' found field 'getNamespaceHook' with type 'MlirDialectGetNamespaceHook' (aka 'struct MlirStringRef ()')
36
MlirDialectGetNamespaceHook getNamespaceHook;
37
^
38
Registration.h:64:31: note: but in 'CMLIR' found field 'getNamespaceHook' with type 'MlirDialectGetNamespaceHook' (aka 'struct MlirStringRef ()')
39
MlirDialectGetNamespaceHook getNamespaceHook;

Curiously, there are other `structs` defined in header files that are imported by both (the typedefs in IR.h are a good example) and these work fine, it is just `MlirDialectRegistrationHooks` that causes the problem. Removing references to `MlirDialectRegistrationHooks` in the Swift code fixes the issue.

Update: Running a few more tests revealed that the failure indeed is intermittent. I have been able to successfully build using both Xcode and Swift Package Manager on macOS (I have not been able to get it to fail on Linux), and I have been able to cause both to fail with the error above. This makes me believe this is a race condition. Perhaps there is some code which unifies definitions imported from different C libraries, but isn't properly synchronized.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant