-
Notifications
You must be signed in to change notification settings - Fork 830
[ctor-eval] Eval functions with params if ignoring external input #4446
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
Conversation
|
Ignoring external parameters when that flag is explicitly set makes sense, but we could also ignore external parameters that are unused even when that flag is not set. Would that be sufficient for the case of |
|
I think that would be sufficient for main, yes. It would be significantly more work, though - we'd need to track local usage. |
tlively
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps worth a TODO about ignoring unused parameters since --ignore-external-input seems extremely dangerous.
|
I'm fine with this land now but I think it would be good if we could be more specific and make this work even without I also thinks its fine if call out main explicitly if it makes sense.. and also isn't it fairly easy to see if a local is used or not? |
|
Yeah, it's fairly easy to see if a local is used statically. Dynamic checks as the interpreter runs would require more work, which is what I meant earlier. Static checks would be good enough for the case where there is no reference at all, but we'd need dynamic checks to be able to partially eval up to the first usage, to ignore local.gets in code paths that are not taken, etc. Overall I think maybe we want more than one option here. One issue is that assuming parameters are zero is actually nice for the fuzzer (it's literally what the fuzzer does when it tests, so it "just works"), where I've just been running with So yes, for now I think let's land this with a TODO, and we'll think about more refined and safer options later. |
When ignoring external input, assume params have a value of 0. This
makes it possible to eval
main(argc, argv)if one is careful and doesnot actually use those values.
This is basically a workaround for
mainalways receiving argc/argv,even if the C code has no args (in that case the compiler emits
__original_mainfor the user's main, and wraps it with amainthat adds the args, hence the problem).
This is similar to the existing support for handling
wasi_args_getwhen ignoring external input, although it just sets values of zeros for
the params. Perhaps it could check for
main()specifically and return1 for argc and a proper buffer for argv somehow, but I think if a program
wants to use
--ignore-external-inputit can avoid actually readingargc/argv.