Shard effected:
mainly shard3, but all shards are affected in theory
Things went wrong:
My compiled WebAssembly code can only be loaded randomly by randomly changing code. (Source code is in: https://github.com/astro-angelfish/chocomint/blob/main/natives/flowfield.c and other C files in the natives/libs directory.)
I compiled the C code in my submitting script by using command (Can be found in https://github.com/astro-angelfish/chocomint/blob/main/commit.py#L40-L53)
Note that I'm using emscripten v3.1.24 and Python v3.10.8
emcc -s WASM=1 -s SIDE_MODULE=1 -O3 "files" -o "output.wasm"
What I have done:
- the type of
distance_map
in parameters ofgenerate_distance_map
wasu_int8_t
. I performed an invalid comparison with value-1
. The module was successfully loaded. - I changed the
-1
to0xff
, then the module was unable to be loaded. - I have changed the type of
distance_map
toint
, and changed0xff
to-1
, it still could not be loaded. - I have changed the first assignment of
node_to_visit
. This line was changed fromint node_to_visit[2500] = {0};
toint * node_to_visit = malloc(sizeof(int) * 2500);
. The module was successfully loaded but reports there is no anything likemalloc
ormemcpy
. - I copied a malloc implementation and memcpy implemention from github and glibc, pasting them into one file called
flowfield.c
. It was successfully loaded and was ready to run. - I moved the library code into separate files and made some header files. the WebAssembly was unable to load.
All error occurred in things I've done above is just WebAssembly.Module(): Wasm decoding failed: mutable globals cannot be imported @+119
.
And I've tested in newer nodejs after v12 LTS, it can be loaded normally and nothing went wrong. So I guess it's the problem of nodejs and Screeps are running on nodejs 10 which I'm unable to put my code on. So I wonder is there any plan to upgrade nodejs? Maybe most player don't need to upgrade it but I do need.
It might be something wrong deep in nodejs and WebAssembly internals. I don't have enough knowledge about it and tried to download the source code but failed to build an analysis environment. If someone know why this happens I would appreciate to know about.
The second one is that the object destruction like creep's death and structure destruction, the latter can only be logged when it is triggered by a creep attack or dismantle. I've already opened this issue in github (https://github.com/screeps/engine/issues/139) but I didn't receive any response. I need event log to save my CPU ;w;