-
Notifications
You must be signed in to change notification settings - Fork 38
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
UB in OperandStack #583
Labels
bug
Something isn't working
Comments
I'd try to avoid (2) as that makes it worse for people writing host functions. I'd also try to avoid branching, so would vouch for (3). |
What is the rationale for that? |
Wait a second, this is only done once in the constructor? If so, fine with branching. |
chfast
added a commit
that referenced
this issue
Nov 2, 2020
gumb0
pushed a commit
that referenced
this issue
Jan 20, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is potential undefined behavior in OperandStack when no locals. Then the stack top pointer is set to
m_bottom - 1
. This is undefined behavior because you are allowed to move pointer within the array or to the element after the array (not before).Possible solutions
m_bottom
). This may negatively affect unary op, becausem_top - 1
must be used instead ofm_top
being used currently.m_top = m_bottom + max_stack_size
(i.e. the "end"). Push is
*m_top-- = value`. This will work, but pointer arithmetic will be confusing.m_bottom[0]
is always allocated but should never be used. Initm_top = m_bottom
. This works good, but requires more memory.[[unlikely]]
.3 and 4 have additional property that you can assign execution result value unconditionally because you can always safely access
stack.top()
, although in may contain garbage value.The text was updated successfully, but these errors were encountered: