Skip to content

Enabling Address Sanitizer causes runtime to exit despite NO_EXIT_RUNTIME being set #16348

@cheinr

Description

@cheinr

I've been trying to get the address sanitizer working for a project I'm working on, and it appears to be causing the runtime to exit, even if I set NO_EXIT_RUNTIME.

Here's an example program that does something asynchronously:

// main.c
#include <stdio.h>
#include "emscripten.h"

int main() {
  EM_ASM({
      setTimeout(() => {
          const foo = cwrap('foo', null, null, { async: false });
          foo();
        }, 5000);
    });

  return 0;
}

EMSCRIPTEN_KEEPALIVE void foo() {
  printf("blam!\n");
}

For the latest version of emscripten (3.1.5), I get the following when I don't provide the -fsanitize=address flag:

> emcc -s ALLOW_MEMORY_GROWTH main.c 
> node a.out.js
blam!   // (after 5 seconds)

However, when the address sanitizer is enabled the program exits immediately without waiting for the async operation:

> emcc -s ALLOW_MEMORY_GROWTH -fsanitize=address main.c 
> node a.out.js
> (no output)

This occurs even if I add -s NO_EXIT_RUNTIME=1 when compiling. I've also tried using emscripten versions 3.0.0 and 2.0.0. 3.0.0 had the same behavior, but 2.0.0 worked as I would have expected with the fsanitize=address flag enabled, so I'm assuming this might be a regression?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions