react-native-bignumber
react-native-bignumber copied to clipboard
Insta crash on Hermes but works with JSC
Hey friends 👋,
I recently enabled this library in a project. Everything seemingly went through until I enabled Hermes engine. The app crashes immediately after launching with error:
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x0).
The process has been returned to the state before expression evaluation.
I found out that the issue happens in either of these methods BN_bn2lebinpad
, BN_bn2binpad
:
https://github.com/margelo/react-native-bignumber/blob/56873d9930f47379233edd183eec4454c6d97db3/cpp/MGBigNumberHostObject.cpp#L138-L145
Here's value of ab
:
What I tried so far:
- I commented out
toArrayLike
(insidecommonjs/BigNumber.js
) below here but weirdly the issue is still there. I wasn't able to find any toArrayLike invocations anywhere else
https://github.com/margelo/react-native-bignumber/blob/56873d9930f47379233edd183eec4454c6d97db3/src/BigNumber.ts#L247-L252
- If I wrap
if(ab.data(runtime) != NULL)
the issue goes away but application doesn't behave correctly.
I would appreciate any suggestions. Thanks!
oh weird, maybe we use ArrayBuffer wrong, Hermes should have native support for that.... cc @Szymon20000
Hermes doesn't allocate any memory for an ArraysBuffer's dataBuffer if the size is 0. It's a nullpointer.. The code also doesn't check if the ArrayBuffer size is sufficiently large to carry the BigNumber's data and potentially overflows.
Any news on this? I would be excited to implement this library into my app. But this exact same issue is causing my app to insta-crash as well.
Hello guys, do you guys have plans for fixing this bug? I am having an insta-crash like this:
I'm having the same crash as above as well with @solana/web3.js
To everyone struggling with this issue. I recommend migrating to BigInt