Open cryptonerdcn opened 6 days ago
Relative issue: https://github.com/starkware-libs/cairo/issues/6171
Moving to a newer salsa version was required for making the language server viable for normal user usage.
Having a wasm build for a fork of the compiler wasn't part of the considerations.
@ArielElp
Having a wasm build for a fork of the compiler wasn't part of the considerations.
Thanks for your reply! @orizi Yes I know, so I did it alone for a long time. Maybe it's salsa's bug(because it is pre-release?), and WASM-Cairo users don't require language server features, I think I can make an old salsa version for it. Do you have any advice for it?
In any case - from looking at the failure stack - it seems like a salsa issue.
have you tried rebasing over the latest on main?
@cryptonerdcn you could give https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html a try to forcefully compile with a stable salsa release, but I recall there were some source-wise differences in cycles handling (and there are definitely breaking changes regarding cancellation, but that one is scoped to LS only)
I am currently trying to debug this also
Do you have any advice for it?
Well - you can see in the PR the adaptations we did to handle the changes, so the opposite will be required for a revert, but do note we needed to do some logical adaptations to handle the difference between these (their cycle handling logic is somewhat different) - which i assume you really won't want to do.
@cryptonerdcn to me it looks like one of the unwraps here is failing: https://github.com/starkware-libs/cairo/commit/e7d5aa90ba7910bd4009580ed860f45aa8218ded#diff-04d31e27b9f6f114064562aa726da3f89794fc84843b002862ead0d5832a25ecR255-R267
I have analysed the stack trace you got vs the actual source that is built, and it looks like some stuff was aggressively inlined by Rust between these two frames:
8: 0xdb4f6e - cairo_compile-c6d1fb3c515bbdf8.wasm!core::option::unwrap_failed::hd2c54ff58c095093
9: 0xd2d54b - cairo_compile-c6d1fb3c515bbdf8.wasm!<cairo_lang_filesystem::db::PrivRawFileContentQuery as salsa::plumbing::QueryFunction>::execute::h6a4ba9a620df9e8f
The <cairo_lang_filesystem::db::PrivRawFileContentQuery as salsa::plumbing::QueryFunction>::execute
function directly calls priv_raw_file_content
function that provides implementation for that query, and it appears that it was fully inlined along with your read_file_on_disk_or_wasm
that it calls (which explains why they're not visible in stack trace).
@mkaput Thank you! Because wasm can not really read a file from disk, the read_file_on_disk_or_wasm
is used to read the files embedded into the wasm package(Basically, the .cairo
files in the corelib
).
So maybe the problem is salsa needs to access sth. in the disk but it can't?
So maybe the problem is salsa needs to access sth. in the disk but it can't?
Nope, Salsa shouldn't be doing any I/O. Instead, my guess is that it changes some order of operations or smth, that is causing read_file_on_disk_or_wasm
to fail. I suggest putting some logs & replacing these unwraps
with expect
with distinct messages to investigate which call precisely is failing, as there are many there.
Good news: As @mkaput said, "there are definitely breaking changes regarding cancellation, but that one is scoped to LS only".
If I use salsa = "0.16.1"
and revert other changes of PR(https://github.com/starkware-libs/cairo/pull/6173), at least the compiler can work fine (Based on Cairo 2.8.2, sha: 6679166d823395a8bf54a592be192b92dc8a3fcd).
Cause @orizi said "it seems like a salsa issue.", I will temporarily use this solution to release a new version of WASM-Cairo to support Cairo 2.8.2 because Shinigami needs it (https://github.com/keep-starknet-strange/shinigami/issues/240).
Thanks for your help again! @orizi @mkaput
Bug Report
Cairo version:
2.8.0
Current behavior:
I am cryptonerdcn, author of WASM-Cairo. After this PR(https://github.com/starkware-libs/cairo/pull/6173/), the WASM-Cairo version Cairo compiler will crash when the code uses
println!
.Expected behavior:
Steps to reproduce:
Checkout this branch: https://github.com/cryptonerdcn/cairo/tree/tmp/test_PR6173
Build:
Then run:
The code will run normally.
But if you run:
Will crash with this output:
Related code:
The previous PR https://github.com/starkware-libs/cairo/pull/6245/ (fb3d11c7ebf4dfeb04cf86e94da0d3a4867c5ba9 ) works normally. So I am sure the problem is from https://github.com/starkware-libs/cairo/pull/6173/ (3be48966e2b710888c0075dd642630c755e8f12f).
Other information: