Stream: wamr

Topic: wamrc SIG 7 error


view this post on Zulip Binh Phan (Jul 09 2024 at 21:48):

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;
}

view this post on Zulip Christof Petig (Jul 10 2024 at 20:43):

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.

view this post on Zulip Binh Phan (Jul 10 2024 at 20:58):

also another thing is i compile wasm with the following flags "-pthread --target=wasm32-wasi-threads"

view this post on Zulip Binh Phan (Jul 10 2024 at 20:58):

without -pthread, i don't get SIG 7 error either


Last updated: Nov 22 2024 at 17:03 UTC