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

Unrelated changes make multiple-definitions test fail spuriously #87084

Closed
fee1-dead opened this issue Jul 12, 2021 · 5 comments · Fixed by #87092
Closed

Unrelated changes make multiple-definitions test fail spuriously #87084

fee1-dead opened this issue Jul 12, 2021 · 5 comments · Fixed by #87092
Assignees
Labels
A-spurious Area: Spurious failures in builds (spuriously == for no apparent reason) C-bug Category: This is a bug. F-raw_dylib `#![feature(raw_dylib)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fee1-dead
Copy link
Member

fee1-dead commented Jul 12, 2021

The test was originally added in #86419, see the comments under that for more discussion.

#86922 and #86857 fails with this diff:

10 error: multiple definitions of external function `f` from library `foo.dll` have different calling conventions
-   --> $DIR/multiple-definitions.rs:8:5
12    |
12    |
- LL |     fn f(x: i32);
-    |     ^^^^^^^^^^^^^
+ LL |         fn f(x: i32);

#87075 was opened, removing the ^^^ and adding indentation (I did not see that it suggested removing --> $DIR/...). It fails with this diff:

10 error: multiple definitions of external function `f` from library `foo.dll` have different calling conventions
12    |
12    |
- LL |         fn f(x: i32);
+ LL |     fn f(x: i32);
14 
15 error: aborting due to previous error; 1 warning emitted

I just want to say that I don't think there was some nondeterministic code causing the span to be different (at least in the file that emitted the diagnostic), as shown on these lines, where they get sorted, deterministically:

imports.sort_unstable_by_key(|x: &DllImport| x.name.as_str());
(lib_name, imports)
})
.collect::<Vec<_>>();
result.sort_unstable_by(|a: &(String, Vec<DllImport>), b: &(String, Vec<DllImport>)| {

@rustbot label A-spurious C-bug T-compiler

@rustbot rustbot added A-spurious Area: Spurious failures in builds (spuriously == for no apparent reason) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 12, 2021
@joshtriplett
Copy link
Member

At this point I think we may want to revert the addition of the test until this issue can be debugged, to avoid spuriously breaking other PRs.

@fee1-dead
Copy link
Member Author

fee1-dead commented Jul 12, 2021

They are being removed in #87087.

@rustbot label F-raw_dylib

@rustbot rustbot added the F-raw_dylib `#![feature(raw_dylib)]` label Jul 12, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 12, 2021
Remove `multiple-definitions` test

r? `@joshtriplett`

Temporary solution to rust-lang#87084.
@ricobbe
Copy link
Contributor

ricobbe commented Jul 12, 2021

@rustbot claim

@RalfJung
Copy link
Member

where they get sorted, deterministically:

Could the use of sort_unstable be the problem here?

@ricobbe
Copy link
Contributor

ricobbe commented Jul 13, 2021

Could the use of sort_unstable be the problem here?

I don't think so, no. The problem is that the error message only occurs when we have multiple DllImports in the same FxHashSet that have the same name. So sorting the elements of an FxHashSet<DllImport> based solely on their names, as is the case on master, isn't sufficient to guarantee a unique result when we select the second DllImport that has a duplicate name. Just using a stable sort wouldn't help either, IIUC, since the original order in the hash set is effectively nondeterministic.

Sorting the DllImport values based on all of their fields instead of just the name, as in the linked PR, should remove this nondeterminism.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jul 17, 2021
…nitions, r=petrochenkov

Remove nondeterminism in multiple-definitions test

Compare all fields in `DllImport` when sorting to avoid nondeterminism in the error for multiple inconsistent definitions of an extern function.  Restore the multiple-definitions test.

Resolves rust-lang#87084.
@bors bors closed this as completed in 81d0b70 Jul 18, 2021
bjorn3 pushed a commit to bjorn3/rust that referenced this issue Aug 6, 2021
…nitions, r=petrochenkov

Remove nondeterminism in multiple-definitions test

Compare all fields in `DllImport` when sorting to avoid nondeterminism in the error for multiple inconsistent definitions of an extern function.  Restore the multiple-definitions test.

Resolves rust-lang#87084.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-spurious Area: Spurious failures in builds (spuriously == for no apparent reason) C-bug Category: This is a bug. F-raw_dylib `#![feature(raw_dylib)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants