You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My experiments with Script.Clone method give unexpected results. After cloning Compiled object, the global map and arrays values has been copied to origin Compiled object. Your code doesn't make new copy array values and map values, just simply copy globals array and your code of Clone doesn't make safe copy of Compiled object. Global mutable maps and arrays should be copied deeply to make safe-concurrent copy of state.
The text was updated successfully, but these errors were encountered:
First of all, thank you for the great works and contributions in Tengo.
I just start experimenting with Tengo and found this issue. I think the following example script shows what @matszpk means.
// A script with two global variables assigned by host// 1. `round` an integer type// 2. `data` a map type// 1. overwrite primitive type, saferound=1000last_key:=""forkey, valindata {
last_key=key
}
// 2. delete an entry from data (map type) is not safe in `cloned` bytecode// the value in original compiled bytecode is being modifieddelete(data, last_key)
I verified the behaviour, and propose a patch at ipsusila@14bfd45.
My experiments with Script.Clone method give unexpected results. After cloning Compiled object, the global map and arrays values has been copied to origin Compiled object. Your code doesn't make new copy array values and map values, just simply copy globals array and your code of Clone doesn't make safe copy of Compiled object. Global mutable maps and arrays should be copied deeply to make safe-concurrent copy of state.
The text was updated successfully, but these errors were encountered: