Daninet / gmp-wasm

Arbitrary-precision Integer, Rational and Float types based on the GMP and MPFR libraries
GNU Lesser General Public License v3.0
22 stars 4 forks source link

crashy behavior with Kotlin/JS #6

Open danwallach opened 2 years ago

danwallach commented 2 years ago

I've been trying on and off to get gmp-wasm to work for me, and I'm getting a variety of weird behaviors. I suspect one of my bugs can be blamed on Kotlin/JS and another might be related to gmp-wasm. I've created a minimal repository that allows the bugs to be reproduced:

https://github.com/danwallach/gmp-wasm-kotlin

The README.md documents how to run the code and has the outputs. In short, I built a Kotlin BigInteger class that speaks directly to the mpz functions, and tries to manage gmp-wasm memory using FinalizationRegistry (so when the JavaScript wrapper object is garbage collected, it will tell gmp-wasm to free the corresponding mpz object).

I'd appreciate if you could take a look at this.