-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Precompile statement emitter sometimes emits invalid statements #28808
Comments
As already mentioned in #32574 I also stumbled upon this recently. As of now I am aware of three cases in which the output is not correct. Case 1Types with symbols as parameters which need to be escaped, e.g. contain a backslash (this is the case you mention) foo(::T) where T = 1
struct A{B} end
foo(A{Symbol("a\\b")}) Output:
I have already fixed this case in tehrengruber@0fed122 (will open a pull request at some point) Case 2Types with symbols as parameters generated via
Output:
Case 3Types with a
Output:
The origin of the problem is in Line 986 in faefe2a
Char (4 bytes) is traversed bytewise in reverse order, hence resulting in 0x56000000 instead of 0x00000056 . I have no clue whats the reason for this ordering. @JeffBezanson you wrote this piece of code, any reason for the ordering that I'm overlooking here?
Edit One thought further I recognized that the reason for the reverse byte ordering is endianess. |
…c_show_x_ (partially fixes JuliaLang#28808)
…c_show_x_ (partially fixes JuliaLang#28808)
…c_show_x_ (partially fixes JuliaLang#28808)
…c_show_x_ (partially fixes JuliaLang#28808)
For implementing special syntax it's useful for typed comprehension to lower to `collect(T, gen)`. This changes typed comprehensions to use the same lowering pattern as normal comprehensions. Needed to tweak the precompile workaround from #28808 Co-authored-by: Andy Ferris <[email protected]>
- move the place where --trace-compile outputs precompile statement to a location that catches more cases - tweak the REPL code to be more amenable to precompilation in light of - instead of trying to encode all the rules where the precompile emitter fails (#28808) just try to precompile and do nothing if it fails.
- move the place where --trace-compile outputs precompile statement to a location that catches more cases - tweak the REPL code to be more amenable to precompilation in light of - instead of trying to encode all the rules where the precompile emitter fails (#28808) just try to precompile and do nothing if it fails.
- move the place where --trace-compile outputs precompile statement to a location that catches more cases - tweak the REPL code to be more amenable to precompilation in light of - instead of trying to encode all the rules where the precompile emitter fails (#28808) just try to precompile and do nothing if it fails. (cherry picked from commit c0478d8)
We also sometimes generate code with invalid |
- move the place where --trace-compile outputs precompile statement to a location that catches more cases - tweak the REPL code to be more amenable to precompilation in light of - instead of trying to encode all the rules where the precompile emitter fails (#28808) just try to precompile and do nothing if it fails. (cherry picked from commit c0478d8)
Regarding
This is now addressable thanks to the cool So i think we just need to find whatever code is dumping the This would be a very similar exercise to that taken in #34888. |
I'm working on addressing It's fixed on that branch, and now i'm just following up with a couple other small improvements to |
Via the logging added to PackageCompiler in JuliaLang/PackageCompiler.jl#457, I've identified two more classes of failures. One of them might just need to be fixed in PackageCompiler, but I think the other one needs to be fixed in julia: Case 4 - Incorrectly emitting
|
For your case 4, these are likely due to partial inference (e.g., from being called by a But I do think Julia should not complain about precompiling that signature. |
Oh interesting, thanks!
Yeah, agreed! this seems like it might be a bug. I've checked, and these statements are emitted again when re-running my snoop file with the resulting sysimg, so I do not believe they are being statically compiled. Thanks for the context, @timholy |
Yeah, indeed I think |
(okay and indeed Case 5 was related to PackageCompiler; i've opened a PR here: JuliaLang/PackageCompiler.jl#463) |
Alright, and finally Class 6:
|
Could Case 6 be from invalidations or type piracy? Have you tried the "double sysimage" trick (JuliaLang/PackageCompiler.jl#429)? Basically, you compile a sysimage, and then using that sysimage as the base, you compile the sysimage again. At that point, all invalidations should have been resolved. |
Oh, wow! Thanks for the link; I hadn't seen that. That's very fascinating. Could it explain a very simple case like the one I show above, where we're literally just precompiling the one single function? Is the idea that i should then run PackageCompiler starting from the sysimg and compile a new sysimg? |
This is also an issue for printf statements. As @KristofferC helped me debug on slack: julia> precompile(Tuple{typeof(Printf.format), Base.TTY, Printf.Format{Base.CodeUnits{UInt8, String}, Tuple{Printf.Spec{Base.Val{Char(0x67000000)}}, Printf.Spec{Base.Val{Char(0x67000000)}}, Printf.Spec{Base.Val{Char(0x67000000)}}, Printf.Spec{Base.Val{Char(0x67000000)}}}}, Float64, Float64, Vararg{Float64, N} where N})
ERROR: Base.CodePointError{UInt32}(0x67000000)
Stacktrace:
[1] code_point_err(u::UInt32)
@ Base ./char.jl:86
[2] Char(u::UInt32)
@ Base ./char.jl:160
[3] top-level scope
@ REPL[3]:1 |
I think that is Case 3 in #28808 (comment). |
Our printing for precompile statements is not 100% reliable (JuliaLang#28808) and can fail. I introduced the extra `parse` call in the Varargs change, but because of JuliaLang#28808, it needs to go inside the try/catch.
Our printing for precompile statements is not 100% reliable (JuliaLang#28808) and can fail. I introduced the extra `parse` call in the Varargs change, but because of JuliaLang#28808, it needs to go inside the try/catch.
I think this is happening on master currently?
|
That looks like something is concurrently corrupting your tmpfiles while executing them |
That happening on both my ubuntu and macos setup. Two separate machines. Is it not happening for other people? |
@ararslan reported on slack to also be seeing it on MacOS and Ubuntu. Different failures on each |
Did it start recently? If so, a bisect could be useful. |
on Arch, with a80afe5 |
A bisect indicated the latest issue started at 3f6abcf which was part of #43415 edit: My impression is that commit just uncovered the underlying bug, it didn't introduce whatever's messing up the temp file |
A few things appear wrong here with the error message too.
It seems the Lines 596 to 597 in 0a91e71
|
The latest issue here is fixed by making the process that emits precompile statements before the sysimage generation single-threaded #44281 |
isn't |
True. Just clarified my comment |
Not sure if what I am observing is exactly due to this issue but I am having a similar behavior to what NHDaly describes here. Basically I create a system image with a
Tried with the double system image trick with no avail. It happens both on 1.8.5 and 1.9.0-rc1. @KristofferC is there a way to check if this is due to invalidations or type piracy as you mentioned here @NHDaly did you managed to find a solution to this issue? |
Doesn't look like those statements have invalid syntax so seems like a different issue. |
This is OK:
But running with
trace-compile=stderr
we can see the following precompile statement being generatedwhich contains an unescaped
\
in theDateFormat
type. Encountering such a type in precompilation gathering means it will fail.The text was updated successfully, but these errors were encountered: