-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
non-deterministic resolving of packages leads to build failures #13662
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
Comments
I need to look at the project structure more closely to confirm, but skimming through the details, this seems like a case of an issue I identified where the compiler will currently trip up on any case where a single file is imported from multiple packages, since it basically gets analysed as part of the package of whichever file AstGen reached first. It was probably hard to reduce this further since it's a race condition so changes which don't "resolve" the issue might nevertheless randomly stop it happening. I spoke to Andrew about this on Discord a while back, and we agreed it makes sense to try and enforce that every file is a part of exactly one package. It turns out a good implementation of this (with consistent errors) is surprisingly irritating, but I do have some local work on it which I'll try and get back to soon. |
Okay yeah, that is indeed what's going on. The package
So if AstGen happens to hit the first part first (it's a race condition because AstGen is run on a thread pool), you get the error (since it's assumed that |
I need more time to investigate more details on this. I looked at this yesterday with @mikdusan for 1-2 hours or so.
It was tricky, but @mikdusan managed to get 100% failure rate with the following patch: diff --git a/Intermittent_Success/major/src/alpha.zig b/Intermittent_Success/major/src/alpha.zig
index 034e191..504143c 100644
--- a/Intermittent_Success/major/src/alpha.zig
+++ b/Intermittent_Success/major/src/alpha.zig
@@ -1,5 +1,5 @@
const std = @import("std");
-pub const major = @import("major");
+//pub const major = @import("major");
test "alpha foo" {
const result = true; One can have faster iteration time (without external script, without nuking cache, without build.zig providided by @mikdusan ) with He also found out that Unfortunately the logs dont contain the full relative path from cwd, but one can see with
|
Previously, if a source file was referenced from multiple packages, it just became owned by the first one AstGen happened to reach; this was a problem, because it could lead to inconsistent behaviour in the compiler based on a race condition. This could be fixed by just analyzing such files multiple times - however, it was pointed out by Andrew that it might make more sense to enforce files being part of at most a single package. Having a file in multiple packages would not only impact compile times (due to Sema having to run multiple times on potentially a lot of code) but is also a confusing anti-pattern which more often than not is a mistake on the part of the user. Resolves: ziglang#13662
Previously, if a source file was referenced from multiple packages, it just became owned by the first one AstGen happened to reach; this was a problem, because it could lead to inconsistent behaviour in the compiler based on a race condition. This could be fixed by just analyzing such files multiple times - however, it was pointed out by Andrew that it might make more sense to enforce files being part of at most a single package. Having a file in multiple packages would not only impact compile times (due to Sema having to run multiple times on potentially a lot of code) but is also a confusing anti-pattern which more often than not is a mistake on the part of the user. Resolves: ziglang#13662
Previously, if a source file was referenced from multiple packages, it just became owned by the first one AstGen happened to reach; this was a problem, because it could lead to inconsistent behaviour in the compiler based on a race condition. This could be fixed by just analyzing such files multiple times - however, it was pointed out by Andrew that it might make more sense to enforce files being part of at most a single package. Having a file in multiple packages would not only impact compile times (due to Sema having to run multiple times on potentially a lot of code) but is also a confusing anti-pattern which more often than not is a mistake on the part of the user. Resolves: ziglang#13662
Previously, if a source file was referenced from multiple packages, it just became owned by the first one AstGen happened to reach; this was a problem, because it could lead to inconsistent behaviour in the compiler based on a race condition. This could be fixed by just analyzing such files multiple times - however, it was pointed out by Andrew that it might make more sense to enforce files being part of at most a single package. Having a file in multiple packages would not only impact compile times (due to Sema having to run multiple times on potentially a lot of code) but is also a confusing anti-pattern which more often than not is a mistake on the part of the user. Resolves: ziglang#13662
Previously, if a source file was referenced from multiple packages, it just became owned by the first one AstGen happened to reach; this was a problem, because it could lead to inconsistent behaviour in the compiler based on a race condition. This could be fixed by just analyzing such files multiple times - however, it was pointed out by Andrew that it might make more sense to enforce files being part of at most a single package. Having a file in multiple packages would not only impact compile times (due to Sema having to run multiple times on potentially a lot of code) but is also a confusing anti-pattern which more often than not is a mistake on the part of the user. Resolves: ziglang#13662
Previously, if a source file was referenced from multiple packages, it just became owned by the first one AstGen happened to reach; this was a problem, because it could lead to inconsistent behaviour in the compiler based on a race condition. This could be fixed by just analyzing such files multiple times - however, it was pointed out by Andrew that it might make more sense to enforce files being part of at most a single package. Having a file in multiple packages would not only impact compile times (due to Sema having to run multiple times on potentially a lot of code) but is also a confusing anti-pattern which more often than not is a mistake on the part of the user. Resolves: ziglang#13662
Previously, if a source file was referenced from multiple packages, it just became owned by the first one AstGen happened to reach; this was a problem, because it could lead to inconsistent behaviour in the compiler based on a race condition. This could be fixed by just analyzing such files multiple times - however, it was pointed out by Andrew that it might make more sense to enforce files being part of at most a single package. Having a file in multiple packages would not only impact compile times (due to Sema having to run multiple times on potentially a lot of code) but is also a confusing anti-pattern which more often than not is a mistake on the part of the user. Resolves: ziglang#13662
Previously, if a source file was referenced from multiple packages, it just became owned by the first one AstGen happened to reach; this was a problem, because it could lead to inconsistent behaviour in the compiler based on a race condition. This could be fixed by just analyzing such files multiple times - however, it was pointed out by Andrew that it might make more sense to enforce files being part of at most a single package. Having a file in multiple packages would not only impact compile times (due to Sema having to run multiple times on potentially a lot of code) but is also a confusing anti-pattern which more often than not is a mistake on the part of the user. Resolves: ziglang#13662
Uh oh!
There was an error while loading. Please reload this page.
Zig Version
0.11.0-dev.333+d5e41bf15b
Steps to Reproduce and Observed Behavior
git clone https://github.com/matu3ba/ZigCacheIssue cd ZigCacheIssue/Intermittent_Success/major/ /usr/bin/time -v
Executing takes ca. 90 seconds to have an almost certain chance to reproduce the issue:
The sporadic failure appearing is
Dependencies are resolved in the following way for the project in directory Intermittent_Success:
For more details, look at https://github.com/matu3ba/ZigCacheIssue.
Expected Behavior
Failure to compile in all cases or successful compilation.
Note, that we still have a directed acyclic graph(DAG) of the package usage, so the resolving logic is definitely broken:
Only the file major.zig in package major includes the package minor by including file minor.zig with Foo.
What could be a bigger problem is when package usage does not form an DAG and there should be a way to check this somehow.
Also note, that only writing this up takes very long and big thanks to @BlueAlmost for providing the rough reduction.
The text was updated successfully, but these errors were encountered: