@@ -595,6 +595,17 @@ static void testArray() {
595595 }
596596}
597597
598+ // When compiling with address sanitizer, disable `testArrayBadAlloc`.
599+ // With an address sanitized build the following test won't throw the
600+ // expected std::bad_alloc, so only run the test for non-sanitized builds.
601+ // Note that annotating the test function with ARCH_NO_SANITIZE_ADDRESS
602+ // won't work since the assertion occurs within VtArray and not the test.
603+ //
604+ // When compiling for wasm, disable `testArrayBadAlloc`. The way the resize
605+ // is handled does not trigger a std::bad_alloc exception but instead
606+ // triggers a native exception from the host that bubbles up to the JS
607+ // runtime environment.
608+ #if !defined(ARCH_SANITIZE_ADDRESS) && !defined(ARCH_OS_WASM_VM)
598609static void testArrayBadAlloc ()
599610{
600611 // Test that attempts to create overly large arrays throw
@@ -618,6 +629,7 @@ static void testArrayBadAlloc()
618629 // pass
619630 }
620631}
632+ #endif
621633
622634static void testRecursiveDictionaries ()
623635{
@@ -2274,16 +2286,6 @@ int main(int argc, char *argv[])
22742286{
22752287 testArray ();
22762288
2277- // When compiling with address sanitizer, disable `testArrayBadAlloc`.
2278- // With an address sanitized build the following test won't throw the
2279- // expected std::bad_alloc, so only run the test for non-sanitized builds.
2280- // Note that annotating the test function with ARCH_NO_SANITIZE_ADDRESS
2281- // won't work since the assertion occurs within VtArray and not the test.
2282- //
2283- // When compiling for wasm, disable `testArrayBadAlloc`. The way the resize
2284- // is handled does not trigger a std::bad_alloc exception but instead
2285- // triggers a native exception from the host that bubbles up to the JS
2286- // runtime environment.
22872289#if !defined(ARCH_SANITIZE_ADDRESS) && !defined(ARCH_OS_WASM_VM)
22882290 testArrayBadAlloc ();
22892291#endif
0 commit comments