emscripten-core / emscripten-core/emscripten

Index out of bounds error with an array of certain size

Open
#12,571 6 comments 1 reaction 0 assignees View on GitHub
wontfix
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

I get this error in Firefox when running my wasm code: `Uncaught RuntimeError: index out of bounds`. In Chrome I get this: `Uncaught RuntimeError: memory access out of bounds`.

Here is my code:
```
#include
#include

void test()
{
// int array[1305728]; // this one doesn't cause the error
int array[1312200];
printf("test \n");
}

int main()
{
test();
return 0;
}
```

Why does this happen and how can I fix it? I don't get any errors with smaller array sizes. Here is how I compile:
`emcc test.cpp -o test.html`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.