-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add debug range checks for makeSetValue #19251
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
9e8d169
to
beb3478
Compare
8770c7c
to
74b851d
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.
The finding here is good but I think maybe the assertions are excessive? It is a reasonable thing for an optimizer to do HEAP32[x] = doubleValueThatWeWantLowerBitsFrom
, that is, rather than manually mask off the lower bits, depend on the semantics of the JS operation that does it automatically.
If you want to do These assertions only apply the We can always revert if we find genuine uses for the truncating/lossy behaviour in |
(also its hard to imagine more heavy user of |
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.
Fair enough, as this is just for makeSetValue
the assertion seems reasonable, and it doesn't limit the optimizer later.
src/parseTools.js
Outdated
@@ -381,7 +392,8 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep) { | |||
if (slab == 'HEAPU64' || slab == 'HEAP64') { | |||
value = `BigInt(${value})`; | |||
} | |||
return slab + '[' + getHeapOffset(offset, type) + '] = ' + value; | |||
var rtn = slab + '[' + getHeapOffset(offset, type) + '] = ' + value; | |||
return rtn; |
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.
This change (adding rtn
) looks unnecessary?
6c9459d
to
6553053
Compare
6553053
to
129d158
Compare
Trying to store a value outside the range of the type being stored to can result in unexpected behaviour. For example, storing 256 to a u8 will end up storing 1. Adding these checks discovered real bug in out library code in `getaddrinfo`. I ran the full other and core test suite with these checks enabled at ASSERTIONS=1 before deciding to use ASSERTIONS=2, at least for now.
129d158
to
0af6c79
Compare
Trying to store a value outside the range of the type being stored to can result in unexpected behaviour. For example, storing 256 to a u8 will end up storing 1.
I decided to write this as a followup to #19239 to make it extra clear what the expected behaviour of makeSetValue is.
Adding these checks discovered real bug in out library code in
getaddrinfo
.I ran the full other and core test suite with these checks enabled at ASSERTIONS=1 before deciding to use ASSERTIONS=2 (at least for now).