-
Notifications
You must be signed in to change notification settings - Fork 349
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
A Miri extern function for library-defined warnings? #2757
Comments
I like this. We should probably make sure it's only emitted once though, even if the same warning command gets executed multiple times. |
We should really figure out some kind of Miri utils crate if we're going to keep incentivizing library authors to do stuff like this. As-written, this is ugly to use and also the mechanism that this hooks into makes me uncomfortable because it's so permissive. An easy follow-on to this to ask if we have warnings, why not custom errors? Why not have a |
isn't that just |
I'm thinking of something that is only checked under But yes, one could just do
But by that same logic, we don't need As far as I understand, @dtolnay you want this supported properly in Miri so that it looks pretty and official, right? The deduplication that Oli is suggesting is the only aspect of this that I think in principle you can't do yourself in your own library. |
I don't care about "official" and I care only a little about "pretty". I primarily want "useful". Notably, printing the call stack and the source code snippet of the caller's code where the warning originates, which are not reasonable for my own code to perform atop eprintln. |
Yeah, sounds reasonable to provide a |
#2497 is relevant w.r.t. |
FWIW, if there is broad interest in making Miri able to detect library UB, I'm not fundamentally opposed to that. I'm just worried that
|
Do library authors need any special support from Miri to detect library UB? Based on what @dtolnay says above, the value in |
Afaict this warning scheme is not for library UB, but for "we've detected we're running under miri, so now things may get weird because we can't really emulate what would happen on the OS" |
I am thinking about what to do with dtolnay/linkme#62.
My library has a finicky platform-specific behavior that isn't necessarily reasonable for Miri to emulate, based on extern statics and
link_name
/link_section
attributes. Miri currently aborts when coming across it.I'm potentially interested in using
cfg(miri)
to provide a stub implementation so that Miri users can still run the rest of their program. However I'm a little hesitant about doing that silently.What's your impression of augmenting the set of Miri extern functions to include this signature?—
It would emit a warning in the same style as what you currently get for isolation warnings under
-Zmiri-isolation-error=warn
.I could use this to inform the user and then fall back to my stub implementation which returns a default value (empty slice in my library's case).
The text was updated successfully, but these errors were encountered: