Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: out of bounds memory access #3504

Open
kamylee opened this issue Jun 5, 2024 · 3 comments
Open

Exception: out of bounds memory access #3504

kamylee opened this issue Jun 5, 2024 · 3 comments

Comments

@kamylee
Copy link

kamylee commented Jun 5, 2024

When i run following code in wasm.i receive an error message:Exception: out of bounds memory access

cJSON* jRoot = cJSON_CreateObject();
for (int i = 0; i < 47; i++)//Greater than 46 will prompt: out of bounds memory access
{
string strId = "id"+ std::to_string(i);
cJSON_AddStringToObject(jRoot, strId.c_str(), std::to_string(i).c_str());
}

But run this code in native is ok。
running platform:windows10

this is my setting:
image

setting in code:
static char global_heap_buf[21024 1024];
...
init_args.mem_alloc_option.pool.heap_buf = global_heap_buf;
init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf);

Increased the memory, but the problem still exists. how to solve it?

@TianlongLiang
Copy link
Contributor

TianlongLiang commented Jun 5, 2024

Hi, could you try increase -zstack-size and --max-memory?

@kamylee
Copy link
Author

kamylee commented Jun 5, 2024

Yes. I hava already tried to increasing the momery for -zstack-size and --max-memory by 10 times, But the broblem has not been resolved.

image

@TianlongLiang
Copy link
Contributor

I think it may be helpful to take a look at: https://github.com/bytecodealliance/wasm-micro-runtime/tree/main/samples/debug-tools You can locate which line of the source code to throw an exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants