-
Notifications
You must be signed in to change notification settings - Fork 10
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
OutOfBounds
error with openzeppelin ERC20 example
#195
Comments
Spent a moment debugging this. The error we observe happens in How this works in the contract: Before returning from the constructor, the contract loads the immutable data size global value. If it is non-zero, it sets the immutable data accordingly. In this case, the immutable data size was nonzero. The recompiler collects immutable values during the LLVM translation, so we only know the count of immutable variables at the end of the translation but not necessarily while emitting the constructor code - so I implemented it such that it loads the value from an uninitialized global variable and after the translation - when the amount of immutables is known - a module is finally linked in which defines this global variable with the final immutable data size. When debugging the recompiler I can observe that the recompiler indeed thinks the amount of immutable variable is 0 and sets it accordingly. Inspecting the shared object, I can confirm that the immutable data size global lands in
Up to this point, everything seems correct to me. The variable should be zero initialized and thus lands in some Note: Disabling the PVM optimizer does not fix this. The |
Smells like a linker bug indeed. @koute can we have a release so we can bump |
Ah sorry I forgot to mention, I already tried PVM with this patch but the bug is still reproducible (FWIW I'm seeing a |
@aman4150 Can you download the object file above and check if the linker is doing the right thing? |
We have internally confirmed that this is a compiler issue and not the linker. TL;DR - Relocations are correct but the compiler emits 32-bit indirect load instead of 64-bit. |
The code snippet below was reported to generate an OOB memory access during
_mint()
in the constructor.Openzeppelin version: 5.2.0
The text was updated successfully, but these errors were encountered: