Open StefanRichterHuber opened 3 months ago
Since I am working on a German system, this problem is related to https://github.com/bellard/quickjs/issues/106 . Parsing of floats in QuickJS depends on the locale set .sigh
As workaround I use the uselocale
function from the libc
crate to temporarily modify the locale in the current thread before executing eval
.
Hmm, this is a problem, setting the locale temporarily will cause problems when used in a multi-threaded environment. Upstream seems to not be interested in supporting other locales.
Maybe we could somehow patch quickjs to bind atof to a rust implemented version using rust std string parsing? Will look into it.
Hello, This is probably out-of-scope of your work, so please close if not appropriate. I observed a strange behavior using your library in a environment sharing memory with a Java JVM. Either as JNI library (as dynamic library loaded by the Java JVM) or the project itself loading a JVM (by loading a dynamic library) using the jni invocation feature. I am completely lost, where to search for the bug. So may be you can give me some hints, were to deepen my search, anyway.
For some reasons, floats resulting from an
eval("2.34")
call are recognized as int values (including the tag value of 0) and rounded to the next lower int value (in this example2
). This happens completely reproducible for all kinds of floats generated duringeval
calls. It does not, however, happen if I set a global value and retrieve it.All other other types of values (JS Strings, Ints, Objects, Functions) don't show this behavior, they work fully reproducible as intended.
Environment: Ubuntu 23.10 64-Bit Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.2+13.1 rustc 1.76.0 cargo 1.76.0
Here is an example (full Gist including Cargo.toml https://gist.github.com/StefanRichterHuber/acd68ecb6571cac5df498c6b28f430ba )