Thank you so much for the answer. Does dlmalloc and emmalloc still use sbrk and emscripten_resize_heap if -sABORTTING_MALLOC is disabled? Because I need an approach that does not depend on any emscripten options or flags and that still detects malloc and free. Another idea is to look out for the memory.size instruction. I think both, dlmalloc and emmalloc, will call memory.size within sbrk (corrrect me, if I am wrong) to identify, if there is enough memory.
Or maybe you have any other ideas how I can reliably detect malloc and free :) s...@google.com schrieb am Montag, 8. Juli 2024 um 21:36:28 UTC+2: > 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 <nguy...@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-disc...@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/8c84d6c6-49d6-4a03-bd6a-96f20a34a28bn%40googlegroups.com.