Segfault in release builds with 2.0.3
mischnic opened this issue · 5 comments
mischnic commented
With a release build (both compiled locally or using the published bianry from 2.0.3), there's a segfault:
const { default: SourceMap } = require('.');
let map = new SourceMap('/test-root');
map.addVLQMap({
mappings: '',
sources: ['x'],
names: [],
});
let buffer = map.toBuffer();
process.stdout.write('4\n\n\n');
let previousMap = new SourceMap(this.projectRoot, buffer);
Process 52935 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x000000012125a9fb index.darwin-x64.node`_rjem_mallocx + 379
index.darwin-x64.node`_rjem_mallocx:
-> 0x12125a9fb <+379>: movzbl (%rcx,%rax), %ecx
0x12125a9ff <+383>: cmpl $0xe7, %ecx
0x12125aa05 <+389>: ja 0x12125aa76 ; <+502>
0x12125aa07 <+391>: movl %ecx, %eax
* frame #0: 0x000000012125a9fb index.darwin-x64.node`_rjem_mallocx + 379
frame #1: 0x000000012122a7b4 index.darwin-x64.node`parcel_sourcemap::SourceMap::from_buffer::hc762a305e0418935 + 308
frame #2: 0x0000000121219182 index.darwin-x64.node`parcel_sourcemap_node::constructor::h55667339899ceede + 3122
mischnic commented
This happens even on v2.0.0.
Any lower optimization levels lower than these will fix it:
[profile.release]
opt-level = 2
codegen-units = 1
debug = 2
The line that fails:
let inner = archived.deserialize(&mut deserializer)?;
Full stack trace
index.darwin-x64.node was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 39734 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x000000013911947b index.darwin-x64.node`_rjem_mallocx [inlined] sz_size2index_lookup(size=0) at sz.h:158:18 [opt]
155 sz_size2index_lookup(size_t size) {
156 assert(size <= LOOKUP_MAXCLASS);
157 {
-> 158 szind_t ret = (sz_size2index_tab[(size-1) >> LG_TINY_MIN]);
159 assert(ret == sz_size2index_compute(size));
160 return ret;
161 }
Target 0: (node) stopped.
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
* frame #0: 0x000000013911947b index.darwin-x64.node`_rjem_mallocx [inlined] sz_size2index_lookup(size=0) at sz.h:158:18 [opt]
frame #1: 0x000000013911946c index.darwin-x64.node`_rjem_mallocx [inlined] sz_size2index(size=0) at sz.h:168:10 [opt]
frame #2: 0x000000013911945f index.darwin-x64.node`_rjem_mallocx [inlined] imalloc_body at jemalloc.c:1832:9 [opt]
frame #3: 0x00000001391193dd index.darwin-x64.node`_rjem_mallocx [inlined] imalloc at jemalloc.c:2005:10 [opt]
frame #4: 0x0000000139119333 index.darwin-x64.node`_rjem_mallocx(size=0, flags=<unavailable>) at jemalloc.c:2588:2 [opt]
frame #5: 0x000000013914e3b7 index.darwin-x64.node`parcel_sourcemap::SourceMap::from_buffer::h45b50d8fc8e6cc0d [inlined] alloc::alloc::alloc::h16e994a1048710d4(layout=Layout @ 0x000060000259e170) at alloc.rs:87:14 [opt]
frame #6: 0x000000013914e3aa index.darwin-x64.node`parcel_sourcemap::SourceMap::from_buffer::h45b50d8fc8e6cc0d [inlined] _$LT$rkyv..de..deserializers..AllocDeserializer$u20$as$u20$rkyv..de..Deserializer$GT$::alloc::h4c3c2c9b5a62c4b5(layout=Layout @ 0x000060000259e160) at deserializers.rs:21:12 [opt]
frame #7: 0x000000013914e3aa index.darwin-x64.node`parcel_sourcemap::SourceMap::from_buffer::h45b50d8fc8e6cc0d [inlined] rkyv::core_impl::_$LT$impl$u20$rkyv..DeserializeUnsized$LT$str$C$D$GT$$u20$for$u20$$LT$str$u20$as$u20$rkyv..ArchiveUnsized$GT$..Archived$GT$::deserialize_unsized::he06e6d16f7a83f52(self=(data_ptr = 0x0000000000000000, length = 0)) at mod.rs:649:25 [opt]
frame #8: 0x000000013914e3aa index.darwin-x64.node`parcel_sourcemap::SourceMap::from_buffer::h45b50d8fc8e6cc0d [inlined] rkyv::std_impl::_$LT$impl$u20$rkyv..Deserialize$LT$alloc..string..String$C$D$GT$$u20$for$u20$$LT$alloc..string..String$u20$as$u20$rkyv..Archive$GT$..Archived$GT$::deserialize::h686fa190a5308857(self=0x000000010287f00c) at mod.rs:192:32 [opt]
frame #9: 0x000000013914e39b index.darwin-x64.node`parcel_sourcemap::SourceMap::from_buffer::h45b50d8fc8e6cc0d at mod.rs:586:41 [opt]
frame #10: 0x000000013914e376 index.darwin-x64.node`parcel_sourcemap::SourceMap::from_buffer::h45b50d8fc8e6cc0d [inlined] rkyv::std_impl::_$LT$impl$u20$rkyv..Deserialize$LT$alloc..vec..Vec$LT$T$GT$$C$D$GT$$u20$for$u20$$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$rkyv..Archive$GT$..Archived$GT$::deserialize::h3de1b54370a2cb15(self=<unavailable>) at mod.rs:484:32 [opt]
frame #11: 0x000000013914e360 index.darwin-x64.node`parcel_sourcemap::SourceMap::from_buffer::h45b50d8fc8e6cc0d [inlined] parcel_sourcemap::_::_$LT$impl$u20$rkyv..Deserialize$LT$parcel_sourcemap..SourceMapInner$C$__D$GT$$u20$for$u20$$LT$parcel_sourcemap..SourceMapInner$u20$as$u20$rkyv..Archive$GT$..Archived$GT$::deserialize::h9f87011e8b983c6e(self=0x000000010287f014) at lib.rs:24:30 [opt]
frame #12: 0x000000013914e2a1 index.darwin-x64.node`parcel_sourcemap::SourceMap::from_buffer::h45b50d8fc8e6cc0d(project_root=(data_ptr = "/", length = 1), buf=(data_ptr = "x", length = 52)) at lib.rs:349:21 [opt]
frame #13: 0x00000001391145a7 index.darwin-x64.node`parcel_sourcemap_node::constructor::h56d5ba6054e46458 at lib.rs:470:29 [opt]
frame #14: 0x0000000139114575 index.darwin-x64.node`parcel_sourcemap_node::constructor::h56d5ba6054e46458 [inlined] parcel_sourcemap_node::constructor::_$u7b$$u7b$closure$u7d$$u7d$::hbb88f48680ea9099 at lib.rs:462:1 [opt]
frame #15: 0x0000000139114575 index.darwin-x64.node`parcel_sourcemap_node::constructor::h56d5ba6054e46458 [inlined] _$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h322410fe1fd3724e(self=AssertUnwindSafe<parcel_sourcemap_node::constructor::{closure_env#0}> @ 0x000060000048ec10) at unwind_safe.rs:271:9 [opt]
frame #16: 0x0000000139114575 index.darwin-x64.node`parcel_sourcemap_node::constructor::h56d5ba6054e46458 at panicking.rs:492:40 [opt]
frame #17: 0x0000000139114575 index.darwin-x64.node`parcel_sourcemap_node::constructor::h56d5ba6054e46458 at panicking.rs:456:19 [opt]
frame #18: 0x0000000139114575 index.darwin-x64.node`parcel_sourcemap_node::constructor::h56d5ba6054e46458 [inlined] std::panic::catch_unwind::h3d2a5924905028ff(f=AssertUnwindSafe<parcel_sourcemap_node::constructor::{closure_env#0}> @ 0x0000600000491860) at panic.rs:137:14 [opt]
frame #19: 0x0000000139114575 index.darwin-x64.node`parcel_sourcemap_node::constructor::h56d5ba6054e46458(raw_env=0x00006000033080a0, cb_info=<unavailable>) at lib.rs:462:1 [opt]
frame #20: 0x0000000100087ed1 node`v8impl::(anonymous namespace)::FunctionCallbackWrapper::Invoke(v8::FunctionCallbackInfo<v8::Value> const&) + 115
frame #21: 0x000000010024633f node`v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) + 563
frame #22: 0x0000000100245aa2 node`v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<true>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) + 476
frame #23: 0x00000001002455cc node`v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) + 216
frame #24: 0x0000000100839799 node`Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit + 57
frame #25: 0x00000001007c9952 node`Builtins_JSBuiltinsConstructStub + 274
frame #26: 0x00000001008c8a22 node`Builtins_ConstructHandler + 706
frame #27: 0x00000001007cc18a node`Builtins_InterpreterEntryTrampoline + 202
frame #28: 0x00000001007c97a5 node`construct_stub_create_deopt_addr + 272
frame #29: 0x00000001008c8a22 node`Builtins_ConstructHandler + 706
frame #30: 0x00000001007cc18a node`Builtins_InterpreterEntryTrampoline + 202
frame #31: 0x00000001007cc18a node`Builtins_InterpreterEntryTrampoline + 202
frame #32: 0x00000001007cc18a node`Builtins_InterpreterEntryTrampoline + 202
frame #33: 0x00000001007cc18a node`Builtins_InterpreterEntryTrampoline + 202
frame #34: 0x00000001007cc18a node`Builtins_InterpreterEntryTrampoline + 202
frame #35: 0x00000001007cc18a node`Builtins_InterpreterEntryTrampoline + 202
frame #36: 0x00000001007cc18a node`Builtins_InterpreterEntryTrampoline + 202
frame #37: 0x00000001007ca398 node`Builtins_JSEntryTrampoline + 88
frame #38: 0x00000001007ca123 node`Builtins_JSEntry + 131
frame #39: 0x00000001002cf207 node`v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) + 2442
frame #40: 0x00000001002ce870 node`v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) + 98
frame #41: 0x00000001002117b7 node`v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) + 273
frame #42: 0x0000000100090268 node`node::ExecuteBootstrapper(node::Environment*, char const*, std::__1::vector<v8::Local<v8::String>, std::__1::allocator<v8::Local<v8::String> > >*, std::__1::vector<v8::Local<v8::Value>, std::__1::allocator<v8::Local<v8::Value> > >*) + 116
frame #43: 0x00000001000913a2 node`node::StartExecution(node::Environment*, char const*) + 370
frame #44: 0x00000001000910fc node`node::StartExecution(node::Environment*, std::__1::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) + 785
frame #45: 0x000000010000a3a5 node`node::LoadEnvironment(node::Environment*, std::__1::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) + 72
frame #46: 0x00000001000f5fd9 node`node::NodeMainInstance::Run(int*, node::Environment*) + 61
frame #47: 0x00000001000f5c90 node`node::NodeMainInstance::Run(node::EnvSerializeInfo const*) + 126
frame #48: 0x00000001000930f5 node`node::Start(int, char**) + 216
frame #49: 0x00000001026294fe dyld`start + 462
DeMoorJasper commented
can't reproduce it locally, maybe disabling jemallocator
fixes it as well?
mischnic commented
Creating a new folder, installing @parcel/source-map
from npm and running the example above also works fine for you?
DeMoorJasper commented
Fails with the published version, but not with the locally built one
mischnic commented
I have rustc 1.60, and clang -v
is 13.1.6