Closed lucab closed 1 year ago
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://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
@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.
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.
@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!
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.
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.
I'm getting this error on Ubuntu 22.04 after https://github.com/denoland/deno/pull/20135 was merged, both release and debug builds, only happen on builds after babfba14e
commit
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).
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
.
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
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:
Here above,
misc_test.ts
contains some Deno tests and there is setup logic inutils.ts
andgithub_signin.ts
which runs on import (and can fail, as seen).Under the same conditions, 1.35.x hits a segfault:
Stacktrace shows the following:
This on Linux kernel 5.19.0 and glibc 2.36 (stock Ubuntu 22.10).