-
Notifications
You must be signed in to change notification settings - Fork 647
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
getNativeState(runtime)
asserts sometimes in release builds even tho it has a NativeState
#1564
Comments
I'm sorry for not having a minimal reproduction example, but you can run Nitro Example ( This PR highlights the change required to make it work fine in release; mrousavy/nitro#321 - and without it it will just crash in release. |
Hey @mrousavy, from your description, it sounds like one possibility is that there's some uninitialised memory access happening somewhere, which would explain the unpredictable behaviour you're seeing. Two things that would be useful:
|
I'll work on dumbing down the repro to figure this one out. The only possible scenario I can think of right now is that maybe my example tried to But that doesn't explain why |
|
God dammit, I finally figured it out after hours of debugging. TL;DR: It's not a Hermes bug - it's my stupidity. Sorry for creating an issue. ContextIn the Nitro Example app, we run tests and each tests then logs the result of the test. All HybridObjects can be logged by calling The way it works is simple - it gets the This is a problem though - for HybridObjects (objects with
|
Bug Description
Hey!
I'm working on Nitro, which uses
NativeState
for every object.An object in Nitro has a proper prototype chain as well, which just consists of objects with HostFunctions, those HostFunctions unwrap the NativeState from the
this
object (which we set before).This works perfectly fine in Debug, and works also for pretty much every production app in Release.
But in the Nitro Example app (
example/
) I have one test which doesObject.getPrototypeOf(object)
and checks if the protoytpe contains a function we expect it to have.For some reason, this one test crashes in Release because
getNativeState(object)
asserts athasNativeState(object)
. But the object definitely has NativeState.Here's some interesting observations:
auto nativeState = object.getNativeState(runtime);
object.hasNativeState(runtime); auto nativeState = object.getNativeState(runtime);
So maybe the
object
is somehow flattened or lazy evaluated in a sense thatNativeState
isn't properly available?gradle clean
and confirmed this bug does not occur with JSCHermes git revision (if applicable):
React Native version: 0.76
OS: Android 9
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): arm64-v8a (Huawei P10)
Steps To Reproduce
Make sure to do this in a RELEASE Build:
getNativeState
onthisObject
(second argument)Object.create(...)
) which binds it'sthis
NativeState
on the new object which has a prototypegetNativeState
onthis
(which is the object that 100% has NativeState)code example:
The Expected Behavior
I expect it to behave the same in debug and in release.
The text was updated successfully, but these errors were encountered: