-
Notifications
You must be signed in to change notification settings - Fork 42
Conflicting defs and clobbers lead to panic rather than clean error from allocator #222
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
Hi @MaxVerevkin -- this is an invalid input program: it is requesting Where did you get this input program from -- constructed by hand or your own frontend? Or did it come out of fuzzing somehow? In any case, this is not a bug in the core allocator. It is probably better that we check for this and return a clean error upfront, though, so I'll change the issue title. |
But the docs say:
After adjusting clobbers to not include the definitions, I'm no longer able to reproduce this panic. Using a to-be-clobbed register is fine, this does not panic:
But this does:
My own frontend, but I'm still learning how to use this library.
Yeah, definitely. Are panics on invalid inputs considered bugs (with validation turned on)? I've found at least one more (assertion error, but the input is more obviously broken). |
Ah, sorry, the docs are out of date then -- this has been the interface for a while now. I'll update that as well. Ideally we would catch and return clean errors for all invalid input, but we're not quite "panic-clean" yet. In practice regalloc2 is developed in tandem with Cranelift, and the realistic definition of valid input is "exactly what Cranelift generates". Getting beyond that will require more effort to define all of the semantic edge-cases properly (as we see here!). I do want to support other users as much as time allows; sorry for the rough edges! |
Thanks for the explanation :) And thanks for making this a stand-alone crate usable from other projects! |
This arose in bytecodealliance#222. It has been the case for a while that we do not permit clobbers and defs to name the same physical register; this is because clobbers become defs internally. Unfortunately the doc-comment on the relevant part of the `Function` trait was out-of-date. Ideally we would also detect this during validation or liverange construction rather than panic'ing later, but that is a separate concern (panic-cleanliness). Note that this doesn't affect Cranelift; this is a concern mainly for docs correctness and for third-party users.
This arose in #222. It has been the case for a while that we do not permit clobbers and defs to name the same physical register; this is because clobbers become defs internally. Unfortunately the doc-comment on the relevant part of the `Function` trait was out-of-date. Ideally we would also detect this during validation or liverange construction rather than panic'ing later, but that is a separate concern (panic-cleanliness). Note that this doesn't affect Cranelift; this is a concern mainly for docs correctness and for third-party users.
regalloc2 v0.12.0
Function which causes a panic:
Debug repr
JSON repr
The text was updated successfully, but these errors were encountered: