-
Notifications
You must be signed in to change notification settings - Fork 173
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
Add tracef to native runtime #599
Conversation
ef3d8d5
to
3f92563
Compare
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.
Thanks!
In general what do you feel like should be our strategy with respect to buffer overruns, when users pass in a pointer that doesn't end in a null character? This goes for trace
, the %s
param of tracef
, and text
.
I guess we have 3 options.
- Consider these cases undefined behavior.
- Define that the cart will always crash immediately when an overrun occurs.
- Cap all reads to the end of the 64 KB memory (perhaps implemented by padding the 64 KB memory with an extra zero byte)
Now that I think about it, we might also want to standardize overrun behavior for blit
/blitSub
as well?
Hmm... I want to say option 2 is the best, since crashes are often better than silent weird behavior. This code currently does option 3 since that's what the web runtime does. Perhaps we can split overruns into a separate issue and solve them all at the same time? Pretty much all pointers sent from WASM will have to be bounds- and null-terminator-checked. I'd avoid defining things as undefined behavior since that will make things runtime dependent.
Agreed! If we decide on BSOD for strings, we should do it for sprites as well. |
Using vprintf directly would segfault on %s because it would try to read the pointer from host memory rather than WASM memory.
I changed For buffer overruns, I will open a separate issue. |
Thanks! |
Updated 2024-04-18!
Using
vprintf
directly would segfault on%s
because it would try to read the pointer from host memory rather than WASM memory.Code is mostly ported from web runtime.
Test code:
Results
The web runtime was also modified to show unrecognized specifiers as they are rather than remove them (see
%u
).