Fixed module importing using require().
Previously, require() did not make a mutable copy of imported module.
As a result, cloned VMs could change a shared module object making
Before 04d7a5d93ae6, the problem manifested itself only in "PROP GET"
operations, for example, using "require('fs').renameSync", because
njs_value_property() makes a mutable copy of shared methods in
After 04d7a5d93ae6, "METHOD CALL" operations, such as
"require('fs').renameSync()", now have the same problem as in "PROP
Importing modules using "import" statement is not affected, because
for it "OBJECT COPY" instruction is generated, which makes a mutable
copy of imported module object.
The fix is to make a mutable copy of a shared module in require().
This closes #206 issue on Github.
2 files changed