Hi guys, question: why is it when compile and run this as AOT. I get a Sig 7 erorr
#include <vector>
struct T {
std::vector<int> updates;
};
T t;
__attribute__((export_name("Init"))) int Init() {
int size = t.updates.size();
t.updates.push_back(1);
size = t.updates.size();
return 0;
}
This works fine
#include <vector>
struct T {
std::vector<int> updates;
};
__attribute__((export_name("Init"))) int Init() {
T t;
int size = t.updates.size();
t.updates.push_back(1);
size = t.updates.size();
return 0;
}
I can tell that the difference is: t
outside the function requires a static initializer to run while t
inside the function will initialize t
(call the constructor) at function entry. But I would guess that the default initialization of all zeros is valid for g++'s vector implementation.
also another thing is i compile wasm with the following flags "-pthread --target=wasm32-wasi-threads"
without -pthread, i don't get SIG 7 error either
Last updated: Nov 22 2024 at 17:03 UTC