Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deno test segfaults after upgrading to 1.35.x #19926

Closed
lucab opened this issue Jul 24, 2023 · 11 comments · Fixed by #20495
Closed

deno test segfaults after upgrading to 1.35.x #19926

lucab opened this issue Jul 24, 2023 · 11 comments · Fixed by #20495
Labels
bug Something isn't working correctly testing related to deno test and coverage upstream Changes in upstream are required to solve these issues

Comments

@lucab
Copy link
Contributor

lucab commented Jul 24, 2023

I have a mildly large testsuite in a private repo, and after upgrading deno from 1.34.x to 1.35.x I'm starting to see segmentation faults. Specifically, 1.34.3 seems to be working fine while all newer releases up to 1.35.2 do segfault.

I wasn't able to pin down what triggers the segfaults nor to get a minimal reproducer, but so far I've observed that they are easier to reach if I set up the test environment so that the testsuite fails quickly.

As a concrete example, the testsuite uses puppeteer against a local web app, and if I stop the local service then the test run used to fail in this way in 1.34.x:

$ deno test --unstable -A --no-check ./tests/e2e_integration/

FRONTEND_ROOT: https://example.local
SIGNING IN...
Uncaught error from ./tests/e2e_integration/misc_test.ts FAILED

./tests/e2e_integration/misc_test.ts (uncaught error)
error: Error: net::ERR_CONNECTION_REFUSED at https://example.local/signin
          ? new Error(`${response.errorText} at ${url}`)
            ^
    at navigate (file:https:///home/lucab/src/denoland/deploy/vendor/deno.land/x/[email protected]/vendor/puppeteer-core/puppeteer/common/Frame.js:261:13)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async Frame.goto (file:https:///home/example/vendor/deno.land/x/[email protected]/vendor/puppeteer-core/puppeteer/common/Frame.js:227:17)
    at async Page.goto (file:https:///home/example/vendor/deno.land/x/[email protected]/vendor/puppeteer-core/puppeteer/common/Page.js:1477:12)
    at async githubSignin (file:https:///home/example/tools/github_signin.ts:36:3)
    at async file:https:///home/example/tests/e2e_integration/utils.ts:57:13
This error was not caught from a test and caused the test runner to fail on the referenced module.
It most likely originated from a dangling promise, event/timeout handler or top-level code.

Here above, misc_test.ts contains some Deno tests and there is setup logic in utils.ts and github_signin.ts which runs on import (and can fail, as seen).

Under the same conditions, 1.35.x hits a segfault:

$ deno test --unstable -A --no-check ./tests/e2e_integration/

FRONTEND_ROOT: https://example.local
SIGNING IN...
Uncaught error from ./tests/e2e_integration/misc_test.ts FAILED
Segmentation fault (core dumped)

Stacktrace shows the following:

$ gdb --args deno test --unstable -A --no-check ./tests/e2e_integration/
[...]

Thread 2 "tokio-runtime-w" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7bff6c0 (LWP 93062)]
0x000055555804bd85 in v8::internal::wasm::WasmCodeManager::Commit(v8::base::AddressRegion) () at ../../../../v8/src/wasm/wasm-code-manager.cc:1842
Download failed: Invalid argument.  Continuing without source file ./../../../../v8/src/wasm/wasm-code-manager.cc.
1842    ../../../../v8/src/wasm/wasm-code-manager.cc: No such file or directory.

(gdb) bt full
#0  0x000055555804bd85 in v8::internal::wasm::WasmCodeManager::Commit(v8::base::AddressRegion) () at ../../../../v8/src/wasm/wasm-code-manager.cc:1842
No locals.
#1  0x000055555804b135 in v8::internal::wasm::WasmCodeAllocator::AllocateForCodeInRegion(v8::internal::wasm::NativeModule*, unsigned long, v8::base::AddressRegion) () at ../../../../v8/src/wasm/wasm-code-manager.cc:747
No locals.
#2  0x000055555804c6fc in v8::internal::wasm::NativeModule::CreateEmptyJumpTableInRegionLocked(int, v8::base::AddressRegion) () at ../../../../v8/src/wasm/wasm-code-manager.cc:1400
No locals.
#3  0x000055555804b7e7 in v8::internal::wasm::NativeModule::AddCodeSpaceLocked(v8::base::AddressRegion) () at ../../../../v8/src/wasm/wasm-code-manager.cc:1513
No locals.
#4  0x000055555804c6aa in NativeModule () at ../../../../v8/src/wasm/wasm-code-manager.cc:847
No locals.
#5  0x000055555804f958 in v8::internal::wasm::WasmCodeManager::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, unsigned long, std::Cr::shared_ptr<v8::internal::wasm::WasmModule const>) ()
    at ../../../../v8/src/wasm/wasm-code-manager.cc:2137
No locals.
#6  0x000055555806adc9 in v8::internal::wasm::WasmEngine::NewNativeModule(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, std::Cr::shared_ptr<v8::internal::wasm::WasmModule const>, unsigned long) ()
    at ../../../../v8/src/wasm/wasm-engine.cc:1236
No locals.
#7  0x000055555800fd02 in CreateNativeModule () at ../../../../v8/src/wasm/module-compiler.cc:2280
No locals.
#8  0x000055555801bf80 in v8::internal::wasm::AsyncCompileJob::PrepareAndStartCompile::RunInForeground(v8::internal::wasm::AsyncCompileJob*) () at ../../../../v8/src/wasm/module-compiler.cc:2673
No locals.
#9  0x000055555801bd6e in v8::internal::wasm::AsyncCompileJob::CompileTask::RunInternal() () at ../../../../v8/src/wasm/module-compiler.cc:2520
No locals.
#10 0x000055555801161a in v8::internal::wasm::AsyncStreamingProcessor::ProcessCodeSectionHeader(int, unsigned int, std::Cr::shared_ptr<v8::internal::wasm::WireBytesStorage>, int, int) ()
    at ../../../../v8/src/wasm/module-compiler.cc:2863
No locals.
#11 0x0000555558047958 in v8::internal::wasm::AsyncStreamingDecoder::DecodeNumberOfFunctions::NextWithValue(v8::internal::wasm::AsyncStreamingDecoder*) () at ../../../../v8/src/wasm/streaming-decoder.cc:678
No locals.
#12 0x0000555558046a7e in v8::internal::wasm::AsyncStreamingDecoder::OnBytesReceived(v8::base::Vector<unsigned char const>) () at ../../../../v8/src/wasm/streaming-decoder.cc:266
No locals.
#13 0x00005555580678f0 in v8::internal::wasm::WasmEngine::AsyncCompile(v8::internal::Isolate*, v8::internal::wasm::WasmFeatures const&, std::Cr::shared_ptr<v8::internal::wasm::CompilationResultResolver>, v8::internal::wasm::ModuleWireBytes, bool, char const*) () at ../../../../v8/src/wasm/wasm-engine.cc:691
No locals.
#14 0x000055555807a976 in v8::(anonymous namespace)::WebAssemblyInstantiate(v8::FunctionCallbackInfo<v8::Value> const&) () at ../../../../v8/src/wasm/wasm-js.cc:1053
No locals.
#15 0x000055555879eedc in Builtins_CallApiCallbackGeneric ()
No symbol table info available.
#16 0x00007ffff7bf4cf8 in ?? ()
No symbol table info available.
#17 0x00007ffff7bf4d30 in ?? ()
No symbol table info available.
#18 0x0000000000000002 in ?? ()
No symbol table info available.
#19 0x0000000000000058 in ?? ()
No symbol table info available.
#20 0x000033d8c47787c1 in ?? ()
No symbol table info available.
#21 0x00007ffff7bf4ca0 in ?? ()
No symbol table info available.
#22 0x0000000000000034 in ?? ()
No symbol table info available.
#23 0x00007ffff7bf4db8 in ?? ()
No symbol table info available.
#24 0x000055555879d69b in Builtins_InterpreterEntryTrampoline ()
No symbol table info available.
#25 0x000033d8c47786b1 in ?? ()
No symbol table info available.
#26 0x0000000200000000 in ?? ()
No symbol table info available.
#27 0x000033d8c4778389 in ?? ()
No symbol table info available.
#28 0x00007ffff0060260 in ?? ()
No symbol table info available.
#29 0x000020250b1c03e1 in ?? ()
No symbol table info available.
#30 0x00002131776a9c01 in ?? ()
No symbol table info available.
#31 0x000020250b1c03e1 in ?? ()
No symbol table info available.
#32 0x000020250b1c03e1 in ?? ()
No symbol table info available.
#33 0x000033d8c4778389 in ?? ()
No symbol table info available.
#34 0x000021317769be69 in ?? ()
No symbol table info available.
#35 0x000021317769cf09 in ?? ()
No symbol table info available.
#36 0x000020250b1c03e1 in ?? ()
No symbol table info available.
#37 0x000020250b1c03e1 in ?? ()
No symbol table info available.
#38 0x000020250b1c03e1 in ?? ()
No symbol table info available.
#39 0x000020250b1c03e1 in ?? ()
No symbol table info available.
#40 0x000033d8c4778389 in ?? ()
No symbol table info available.
#41 0x000033d8c4778789 in ?? ()
No symbol table info available.
#42 0x00002330e2475289 in ?? ()
No symbol table info available.
#43 0x000020250b1c03e1 in ?? ()
No symbol table info available.
#44 0x000020250b1c03e1 in ?? ()
No symbol table info available.
#45 0x00002131776a9ba9 in ?? ()
No symbol table info available.
#46 0x0000014a00000000 in ?? ()
No symbol table info available.
#47 0x000007558a1607d9 in ?? ()
No symbol table info available.
#48 0x0000000000000003 in ?? ()
No symbol table info available.
#49 0x0000220e3db4d5a9 in ?? ()
No symbol table info available.
#50 0x00002330e2475289 in ?? ()
No symbol table info available.
#51 0x00007ffff7bf4e50 in ?? ()
No symbol table info available.
#52 0x000055555879d69b in Builtins_InterpreterEntryTrampoline ()
No symbol table info available.
#53 0x000020250b1c03e1 in ?? ()
No symbol table info available.
#54 0x000021317769be69 in ?? ()
No symbol table info available.
#55 0x000021317769cf09 in ?? ()
No symbol table info available.
#56 0x000020250b1c03e1 in ?? ()
No symbol table info available.
#57 0x0000000000000000 in ?? ()
No symbol table info available.

(gdb) info threads 
  Id   Target Id                                           Frame 
  1    Thread 0x7ffff7e90dc0 (LWP 93058) "deno"            0x00007ffff7d1eb66 in epoll_wait (epfd=3, events=0x55555a17b590, maxevents=1024, timeout=-1) at ../sysdeps/unix/sysv/linux/epoll_wait.c:30
* 2    Thread 0x7ffff7bff6c0 (LWP 93062) "tokio-runtime-w" 0x000055555804bd85 in v8::internal::wasm::WasmCodeManager::Commit(v8::base::AddressRegion) () at ../../../../v8/src/wasm/wasm-code-manager.cc:1842
  3    Thread 0x7ffff73ff6c0 (LWP 93063) "tokio-runtime-w" __GI___libc_read (nbytes=512, buf=0x7ffff73fe478, fd=9) at ../sysdeps/unix/sysv/linux/read.c:26
  4    Thread 0x7ffff71fe6c0 (LWP 93064) "tokio-runtime-w" __GI___libc_read (nbytes=512, buf=0x7ffff71fd478, fd=11) at ../sysdeps/unix/sysv/linux/read.c:26
  5    Thread 0x7ffff6ffd6c0 (LWP 93065) "tokio-runtime-w" syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
  6    Thread 0x7ffff6dfc6c0 (LWP 93066) "V8 DefaultWorke" __futex_abstimed_wait_common64 (private=-267977736, cancel=true, abstime=0x7ffff6dfb790, op=137, expected=0, futex_word=0x7fffe00112c0) at ./nptl/futex-internal.c:57
  7    Thread 0x7ffff65fb6c0 (LWP 93067) "V8 DefaultWorke" __futex_abstimed_wait_common64 (private=-161503576, cancel=true, abstime=0x7ffff65fa790, op=137, expected=0, futex_word=0x7fffe00112c4) at ./nptl/futex-internal.c:57
  8    Thread 0x7ffff5dfa6c0 (LWP 93068) "V8 DefaultWorke" __futex_abstimed_wait_common64 (private=-169896280, cancel=true, abstime=0x7ffff5df9790, op=137, expected=0, futex_word=0x7fffe00112c0) at ./nptl/futex-internal.c:57
  9    Thread 0x7ffff55f96c0 (LWP 93069) "V8 DefaultWorke" __futex_abstimed_wait_common64 (private=-178288984, cancel=true, abstime=0x7ffff55f8790, op=137, expected=0, futex_word=0x7fffe00112c0) at ./nptl/futex-internal.c:57
  10   Thread 0x7ffff4df86c0 (LWP 93070) "V8 DefaultWorke" __futex_abstimed_wait_common64 (private=-267977736, cancel=true, abstime=0x7ffff4df7790, op=137, expected=0, futex_word=0x7fffe00112c0) at ./nptl/futex-internal.c:57
  11   Thread 0x7fffe7fff6c0 (LWP 93071) "V8 DefaultWorke" __futex_abstimed_wait_common64 (private=-402659672, cancel=true, abstime=0x7fffe7ffe790, op=137, expected=0, futex_word=0x7fffe00112c0) at ./nptl/futex-internal.c:57
  12   Thread 0x7fffe77fe6c0 (LWP 93072) "V8 DefaultWorke" __futex_abstimed_wait_common64 (private=-1792, cancel=true, abstime=0x7fffe77fd790, op=137, expected=0, futex_word=0x7fffe00112c0) at ./nptl/futex-internal.c:57
  13   Thread 0x7fffe6ffd6c0 (LWP 93073) "V8 DefaultWorke" __futex_abstimed_wait_common64 (private=-138461352, cancel=true, abstime=0x7fffe6ffc790, op=137, expected=0, futex_word=0x7fffe00112c4) at ./nptl/futex-internal.c:57
  14   Thread 0x7fffe67fc6c0 (LWP 93074) "V8 DefaultWorke" __futex_abstimed_wait_common64 (private=-427837784, cancel=true, abstime=0x7fffe67fb790, op=137, expected=0, futex_word=0x7fffe00112c0) at ./nptl/futex-internal.c:57
  15   Thread 0x7fffe5ffb6c0 (LWP 93075) "V8 DefaultWorke" __futex_abstimed_wait_common64 (private=-267977736, cancel=true, abstime=0x7fffe5ffa790, op=137, expected=0, futex_word=0x7fffe00112c0) at ./nptl/futex-internal.c:57
  16   Thread 0x7fffe57fa6c0 (LWP 93076) "V8 DefaultWorke" __futex_abstimed_wait_common64 (private=-267977736, cancel=true, abstime=0x7fffe57f9790, op=137, expected=0, futex_word=0x7fffe00112c0) at ./nptl/futex-internal.c:57
  18   Thread 0x7ffff45f76c0 (LWP 93166) "tokio-runtime-w" 0x00007ffff7cddaf1 in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=0x7ffff45f6510, rem=0x7ffff45f6510)
    at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78

This on Linux kernel 5.19.0 and glibc 2.36 (stock Ubuntu 22.10).

@lucab lucab added the testing related to deno test and coverage label Jul 24, 2023
@BrunoBernardino
Copy link

BrunoBernardino commented Aug 4, 2023

I'm also experiencing this after upgrading from 1.34.x to 1.36.0 (Kernel is 6.1.41, glibc is 2.37, distro is Manjaro), with tiny test suites (1-3 files, all with Deno.test()). The constant among these projects is the "does the server boot" test, which seems to be where the test fails with the segmentation fault:

import { assertEquals } from 'std/assert/assert_equals.ts';
import { abortController } from './main.ts';

const baseUrl = 'http:https://localhost:8000';

Deno.test({
  name: 'HTTP Server',
  fn: async () => {
    let response = await fetch(`${baseUrl}/`);
    assertEquals(response.status, 200);

    let responseText = await response.text();
    assertEquals(responseText.includes('Something'), true);

    response = await fetch(`${baseUrl}/blah`);
    assertEquals(response.status, 404);

    responseText = await response.text();
    assertEquals(responseText, 'Not found');

    abortController.abort('Test finished');
  },
  sanitizeResources: false,
  sanitizeOps: false,
});

main.ts is pretty basic too:

import routes, { Route } from './routes.ts';

function handler(request: Request, connectionInfo: Deno.ServeHandlerInfo) {
  const routeKeys = Object.keys(routes);

  for (const routeKey of routeKeys) {
    const route: Route = routes[routeKey];
    const match = route.pattern.exec(request.url);

    if (match) {
      return route.handler(request, match, connectionInfo);
    }
  }

  return new Response('Not found', {
    status: 404,
  });
}

export const abortController = new AbortController();

const PORT = Deno.env.get('PORT') || 8000;

Deno.serve({ port: PORT as number, signal: abortController.signal }, handler);

Finally, routes.ts isn't, but can be pretty simple, to replicate:

export interface Route {
  pattern: URLPattern;
  handler: (
    request: Request,
    match: URLPatternResult,
    connectionInfo: Deno.ServeHandlerInfo,
  ) => Response | Promise<Response>;
}

interface Routes {
  [routeKey: string]: Route;
}

const routes: Routes = {
  index: {
    pattern: new URLPattern({ pathname: '/' }),
    handler: () => {
      return new Response('Something!');
    },
  },
};

export default routes;

I'm not getting segmentation faults all the time (it's like in 4 out of 5 runs), and in GH Actions I haven't seen it fail yet. Here's a "simple app" repo where this is happening: https://github.com/BrunoBernardino/deno-boilerplate-simple-website

@lucab
Copy link
Contributor Author

lucab commented Aug 4, 2023

@BrunoBernardino thanks for the reproducer. I tried to run deno test -A on your repository locally and indeed it segfaults for me too. Running it under gdb shows the same stacktrace that I posted initially.

@bartlomieju
Copy link
Member

bartlomieju commented Aug 4, 2023

Dang, I think this might be Linux-only problem. I'm not able to reproduce it no matter how many times I run it.

I will upgrade V8 next week, let's see if that helps.

@BrunoBernardino
Copy link

BrunoBernardino commented Aug 4, 2023

@bartlomieju kind of. I would say it's Linux-only if it also failed in GH Actions, but it doesn't seem to (or I've just been lucky).

Nevermind, I re-read what you said. You didn't say it happens all the time on Linux, only that it happens only in Linux. Carry on!

@dsherret
Copy link
Member

dsherret commented Aug 5, 2023

I'm also getting this on Linux with some code that uses Wasm. Occurs in 1.35.0+

> git clone https://github.com/dsherret/dax && cd dax
> git checkout d795426aeceab77f02dd2c537a9d099752c535a2
> deno test -A
...
Segmentation fault (core dumped)

Seems it needs to load many files for this to occur as when I filter it to one file the issue goes away. Edit: Nope, just had it happen with one file.

@bartlomieju
Copy link
Member

I'm erring on the side of V8 bug as we haven't touched WASM support at all in a few months. I'll let you know once we get a new version of V8 landed some time next week.

@marcosc90
Copy link
Contributor

I'm getting this error on Ubuntu 22.04 after #20135 was merged, both release and debug builds, only happen on builds after babfba14e commit

@tekul
Copy link

tekul commented Aug 18, 2023

Not sure if it's connected, but I also get a segfault just running cargo test from the current deno HEAD. If I run in gdb I get:

Thread 494 "tsc::tests::tes" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff69f66c0 (LWP 76619)]
0x000055555dad7e39 in v8::internal::ThreadIsolation::RegisterJitPage(unsigned long, unsigned long, v8::internal::ThreadIsolation::AllocationSource) () at ../../../../v8/src/common/code-memory-access.cc:306
306	                                      AllocationSource source) {
(gdb) where
#0  0x000055555dad7e39 in v8::internal::ThreadIsolation::RegisterJitPage(unsigned long, unsigned long, v8::internal::ThreadIsolation::AllocationSource) () at ../../../../v8/src/common/code-memory-access.cc:306
#1  0x000055555dc0f899 in v8::internal::MemoryAllocator::SetPermissionsOnExecutableMemoryChunk(v8::internal::VirtualMemory*, unsigned long, unsigned long, unsigned long) () at ../../../../v8/src/heap/memory-allocator.cc:735
#2  0x000055555dc0f6d0 in v8::internal::MemoryAllocator::AllocateAlignedMemory(unsigned long, unsigned long, unsigned long, v8::internal::AllocationSpace, v8::internal::Executability, void*, v8::internal::VirtualMemory*) ()
    at ../../../../v8/src/heap/memory-allocator.cc:283
#3  0x000055555dc0faba in v8::internal::MemoryAllocator::AllocateUninitializedChunkAt(v8::internal::BaseSpace*, unsigned long, v8::internal::Executability, unsigned long, v8::internal::PageSize) ()
    at ../../../../v8/src/heap/memory-allocator.cc:379
#4  0x000055555dc0ff6f in v8::internal::MemoryAllocator::AllocatePage(v8::internal::MemoryAllocator::AllocationMode, v8::internal::Space*, v8::internal::Executability) () at ../../../../v8/src/heap/memory-allocator.cc:601
#5  0x000055555dc30238 in v8::internal::PagedSpaceBase::TryExpandImpl(v8::internal::MemoryAllocator::AllocationMode) () at ../../../../v8/src/heap/paged-spaces.cc:374
#6  0x000055555dc3139d in v8::internal::PagedSpaceBase::TryExpand(int, v8::internal::AllocationOrigin) () at ../../../../v8/src/heap/paged-spaces.cc:836
#7  0x000055555dc312e3 in v8::internal::PagedSpaceBase::RawRefillLabMain(int, v8::internal::AllocationOrigin) () at ../../../../v8/src/heap/paged-spaces.cc:928
#8  0x000055555dc30e31 in v8::internal::PagedSpaceBase::RefillLabMain(int, v8::internal::AllocationOrigin) () at ../../../../v8/src/heap/paged-spaces.cc:827
#9  0x000055555dbb7bc8 in v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) ()
    at ../../../../v8/src/heap/heap-allocator.cc:78
#10 0x000055555dbb8a34 in v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) ()
    at ../../../../v8/src/heap/heap-allocator.cc:105
#11 0x000055555db9d483 in v8::internal::Factory::CodeBuilder::AllocateInstructionStream(bool) () at ../../../../v8/src/heap/factory.cc:283
#12 0x000055555db9d67b in v8::internal::Factory::CodeBuilder::BuildInternal(bool) () at ../../../../v8/src/heap/factory.cc:154
#13 0x000055555db9dace in v8::internal::Factory::CodeBuilder::Build() () at ../../../../v8/src/heap/factory.cc:319
#14 0x000055555e314a86 in v8::internal::RegExpMacroAssemblerX64::GetCode(v8::internal::Handle<v8::internal::String>) () at ../../../../v8/src/regexp/x64/regexp-macro-assembler-x64.cc:1129
#15 0x000055555df708dc in v8::internal::RegExpCompiler::Assemble(v8::internal::Isolate*, v8::internal::RegExpMacroAssembler*, v8::internal::RegExpNode*, int, v8::internal::Handle<v8::internal::String>) ()
    at ../../../../v8/src/regexp/regexp-compiler.cc:288
#16 0x000055555df960a6 in v8::internal::RegExpImpl::Compile(v8::internal::Isolate*, v8::internal::Zone*, v8::internal::RegExpCompileData*, v8::base::Flags<v8::internal::RegExpFlag, int, int>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, bool, unsigned int&) () at ../../../../v8/src/regexp/regexp.cc:1016
#17 0x000055555df95785 in v8::internal::RegExpImpl::CompileIrregexp(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, bool) ()
    at ../../../../v8/src/regexp/regexp.cc:571
#18 0x000055555df9489a in v8::internal::RegExpImpl::IrregexpPrepare(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>) () at ../../../../v8/src/regexp/regexp.cc:657
#19 0x000055555df94b90 in v8::internal::RegExpImpl::IrregexpExec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>, v8::internal::RegExp::ExecQuirks) () at ../../../../v8/src/regexp/regexp.cc:768
#20 0x000055555dfb5f93 in v8::internal::Runtime_RegExpExec(int, unsigned long*, v8::internal::Isolate*) () at ../../../../v8/src/runtime/runtime-regexp.cc:912
#21 0x000055555eb1e376 in Builtins_CEntry_Return1_ArgvOnStack_NoBuiltinExit ()
#22 0x000055555eba2971 in Builtins_RegExpPrototypeTest ()
#23 0x000055555ea85b6a in Builtins_InterpreterEntryTrampoline ()

I'm running on Arch Linux (on an AMD Ryzen 9 5950X Processor.):

$ uname -a
Linux celeste 6.4.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 11 Aug 2023 11:03:36 +0000 x86_64 GNU/Linux

UPDATE: This no longer happens on the latest HEAD with deno_core 0.204 (which downgraded the v8 version).

@tekul
Copy link

tekul commented Aug 31, 2023

I get the problem above again with the latest HEAD (since deno_core was updated again). I also get it running cargo test on a clean checkout of deno_core.

@bartlomieju bartlomieju added bug Something isn't working correctly upstream Changes in upstream are required to solve these issues labels Sep 11, 2023
bartlomieju added a commit that referenced this issue Sep 14, 2023
This is a mitigation for segfaults happening in V8 on CPU with MPK
(memory protected keys).

After much trail and error we found that unless V8 platform is
initialized on main thread the segfaults start appears once JIT 
kicks in. "deno test" and "deno bench" were affected by
this problem.

Fixes #19926
Fixes #20243
Fixes #20450

---------

Co-authored-by: Bartek Iwańczuk <[email protected]>
@tekul
Copy link

tekul commented Sep 19, 2023

I'm still seeing a segfault, I think even after these changes. Running cargo clean followed by cargo test as before with the latest deno_core (6a369d5702be using v8 0.76.0):

Thread 46 "modules::tests:" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff63f36c0 (LWP 36038)]
0x00005555569e23da in v8::internal::ThreadIsolation::RegisterJitPage(unsigned long, unsigned long) () at ../../../../v8/src/common/code-memory-access.cc:362

@dsherret
Copy link
Member

dsherret commented Sep 19, 2023

@tekul it might be best to open a separate issue for that in deno_core because that's cargo test and not deno test so it might not be related to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly testing related to deno test and coverage upstream Changes in upstream are required to solve these issues
Projects
None yet
6 participants