Hi Ngula, In emscripten the allocators such as dlmalloc and emmalloc use `sbrk()` when they run out of memory. `sbrk()` then calls `emscripten_resize_heap`, which by default will abort with an error message here: https://github.com/emscripten-core/emscripten/blob/b3c25673f53974ff1f30df43701dc63af7cbbdc4/src/library.js#L280-L290. So the error messages in this case live in the JavaScript, not in the wasm module.
This behaviour is affected by the `-sABORTTING_MALLOC` setting though. If you disable this setting then you don't get any kind of error message and malloc simply returns zero. cheers, sam On Mon, Jul 8, 2024 at 8:56 AM NgulaDE <nguyle...@gmail.com> wrote: > Hey, I am working on a patcher for Wasm. > Is there a way to identify the malloc and the free function of the > dlmalloc and emmalloc allocator? My supervisor says that malloc prints an > error message, such as "out of memory", "allocation failed" or > "insufficient memory", if memory allocation via malloc fails. Supposedly, > these strings will be stored in the data section on the linear memory. In > some wasm modules, i saw these error messages stored in the data section, > but I could not quite figure out how these strings are printed nor how they > are accessed. > > Thank you > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to emscripten-discuss+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/01d093c1-fb3c-497d-88c9-8a48cd4ec975n%40googlegroups.com > <https://groups.google.com/d/msgid/emscripten-discuss/01d093c1-fb3c-497d-88c9-8a48cd4ec975n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va29O1iSzPmkdM_UDQoXEvtqnpELFtBxq2MypVvFqq70Wqg%40mail.gmail.com.