quickjs-emscripten
quickjs-emscripten copied to clipboard
Determinism of the library
Hey! Is it possible to create fully deterministic sandbox from this library? (So that same code will always give same result with same input, even if code authors try to get different results). Assuming exposing only asyncified function (no callbacks or promises) and not exposing any non-deterministic functions, would there be some other ways to produce non-determinism?
I don't think the Javascript bits of the library introduce non-determinism into the VM. You should double-check the Emscripten module initialization code for your preferred variant.
As far as behavior of the upstream quickjs
interpreter, I don't understand the underlying code enough to give a confident answer. You can try asking folks at quickjs-ng quickjs-ng issues, the upstream bellard/quickjs issues or the mailing list
Thank you! Will do.
@angrymouse I think just for the fact that all numbers in javascript are IEEE-754 float, I don't think is possible to guarantee determinism across different machines without emulate all numbers (which can make it very slow): https://gafferongames.com/post/floating_point_determinism/