MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / InteropString

Function InteropString

test/stack_overflow.cpp:14–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12EM_JS_DEPS(main, "$stringToUTF8OnStack");
13
14void __attribute__((noinline)) InteropString(char *staticBuffer) {
15 char *string = (char*)EM_ASM_PTR({
16 var str = "hello, this is a string! ";
17#if ONE_BIG_STRING
18 // double it until it is bigger than the stack
19 for (var i = 0; i < 15; ++i) {
20 str = str + str;
21 }
22 stringToUTF8OnStack(str);
23#else
24 // allocate as many times as we need to overflow
25 for (var i = 0; i < 1024 * 1024; i++) {
26 stringToUTF8OnStack(str);
27 }
28 abort("we should never get here!");
29#endif
30 });
31}
32
33int main() {
34 // Make C side consume a large portion of the stack, before bumping the rest with C++<->JS interop.

Callers 1

mainFunction · 0.85

Calls 1

abortFunction · 0.50

Tested by

no test coverage detected