deno: segfault running tools/deno_tcp.ts

▶ target/release/deno --allow-net tools/deno_tcp.ts 127.0.0.1:4544
Listening on 127.0.0.1:4544
[1]    32342 segmentation fault  target/release/deno --allow-net tools/deno_tcp.ts 127.0.0.1:4544
▶ wrk -d 10 --latency http://127.0.0.1:4544
Running 10s test @ http://127.0.0.1:4544
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   548.03us    2.16ms  43.42ms   95.17%
    Req/Sec    32.28k     3.29k   36.54k    81.50%
  Latency Distribution
     50%  132.00us
     75%  138.00us
     90%  208.00us
     99%   10.05ms
  642599 requests in 10.01s, 31.25MB read
Requests/sec:  64198.13
Transfer/sec:      3.12MB

Output from rust-lldb

▶ rust-lldb target/release/deno --  --allow-net tools/deno_tcp.ts 127.0.0.1:4544
(lldb) command script import "/Users/biwanczuk/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py"
(lldb) type summary add --no-value --python-function lldb_rust_formatters.print_val -x ".*" --category Rust
(lldb) type category enable Rust
(lldb) target create "target/release/deno"
Current executable set to 'target/release/deno' (x86_64).
(lldb) settings set -- target.run-args  "--allow-net" "tools/deno_tcp.ts" "127.0.0.1:4544"
(lldb) r
Process 25595 launched: '/Users/biwanczuk/dev/deno/target/release/deno' (x86_64)
Listening on 127.0.0.1:4544
deno was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 25595 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
    frame #0: 0x0000000100983850 deno`::~BackingStore() at backing-store.cc:197:16 [opt]
Target 0: (deno) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
  * frame #0: 0x0000000100983850 deno`::~BackingStore() at backing-store.cc:197:16 [opt]
    frame #1: 0x0000000100726327 deno`::__on_zero_shared() [inlined] operator() at memory:2378:5 [opt]
    frame #2: 0x000000010072631a deno`::__on_zero_shared() at memory:3551 [opt]
    frame #3: 0x000000010070df87 deno`::std__shared_ptr__v8__BackingStore__reset() [inlined] __release_shared at memory:3455:9 [opt]
    frame #4: 0x000000010070df7e deno`::std__shared_ptr__v8__BackingStore__reset() [inlined] __release_shared at memory:3497 [opt]
    frame #5: 0x000000010070df7e deno`::std__shared_ptr__v8__BackingStore__reset() [inlined] ~shared_ptr at memory:4226 [opt]
    frame #6: 0x000000010070df7e deno`::std__shared_ptr__v8__BackingStore__reset() [inlined] ~shared_ptr at memory:4224 [opt]
    frame #7: 0x000000010070df7e deno`::std__shared_ptr__v8__BackingStore__reset() [inlined] reset at memory:4361 [opt]
    frame #8: 0x000000010070df7e deno`::std__shared_ptr__v8__BackingStore__reset() at binding.cc:616 [opt]
    frame #9: 0x000000010004ef1f deno`core::ptr::real_drop_in_place::he7e67422a199d39e + 15
    frame #10: 0x000000010017aedb deno`core::ptr::real_drop_in_place::hbdfcceccbb97d59a + 43
    frame #11: 0x000000010005bbc3 deno`core::ptr::real_drop_in_place::h00649f140172f629 + 19
    frame #12: 0x00000001006e35c3 deno`core::ptr::real_drop_in_place::h746224c518aaf667 + 19
    frame #13: 0x000000010013e578 deno`_$LT$futures_util..stream..futures_unordered..FuturesUnordered$LT$Fut$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h83ba73cdf6a6c66b + 168
    frame #14: 0x0000000100177475 deno`core::ptr::real_drop_in_place::h6f2a5c2c19fa9d6c + 245
    frame #15: 0x0000000100179191 deno`core::ptr::real_drop_in_place::h95854fbe06aad049 + 33
    frame #16: 0x0000000100178ab9 deno`core::ptr::real_drop_in_place::h8f16570a666a4c5e (.llvm.7121938994333845487) + 41
    frame #17: 0x00000001001a3095 deno`_$LT$std..future..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::hef3e620d5c98d44b + 1301
    frame #18: 0x000000010000f8ad deno`tokio::runtime::basic_scheduler::BasicScheduler$LT$P$GT$::block_on::h7a3583bb8574e0fe + 157
    frame #19: 0x00000001000357a0 deno`tokio::runtime::context::enter::h18c96a494c77a009 + 176
    frame #20: 0x00000001001f9eac deno`deno::tokio_util::run_basic::h99fc1fd901132822 + 124
    frame #21: 0x000000010006a860 deno`deno::main::h795ed52523c79963 + 9488
    frame #22: 0x0000000100000c06 deno`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::hdd71bd3eeba61916 + 6
    frame #23: 0x00000001011a5578 deno`std::panicking::try::do_call::h77eb563f55a56484 [inlined] std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::h04f5bc1b8502155f at rt.rs:52:12 [opt]
    frame #24: 0x00000001011a556c deno`std::panicking::try::do_call::h77eb563f55a56484 at panicking.rs:292 [opt]
    frame #25: 0x00000001011afa5f deno`__rust_maybe_catch_panic at lib.rs:78:7 [opt]
    frame #26: 0x00000001011a5e8e deno`std::rt::lang_start_internal::h3d261fac4b6382f2 [inlined] std::panicking::try::h989c79f60ffdf02a at panicking.rs:270:12 [opt]
    frame #27: 0x00000001011a5e5b deno`std::rt::lang_start_internal::h3d261fac4b6382f2 [inlined] std::panic::catch_unwind::hd3f56528916c87b0 at panic.rs:394 [opt]
    frame #28: 0x00000001011a5e5b deno`std::rt::lang_start_internal::h3d261fac4b6382f2 at rt.rs:51 [opt]
    frame #29: 0x0000000100000bf9 deno`main + 41
    frame #30: 0x00007fff71f82cc9 libdyld.dylib`start + 1
    frame #31: 0x00007fff71f82cc9 libdyld.dylib`start + 1
(lldb)

This segfault happens only when running using wrk - I cannot trigger it using nc/curl

I managed to get same segfault running tools/deno_tcp.ts using deno v0.33.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

<strike>I have this one mostly figured out. Here is a patch for rusty v8 that resolves it:</strike>

diff --git a/src/binding.cc b/src/binding.cc
index d37b660..1bdfa9e 100644
--- a/src/binding.cc
+++ b/src/binding.cc
@@ -620,7 +620,9 @@ v8::BackingStore* std__shared_ptr__v8__BackingStore__get(
 
 void std__shared_ptr__v8__BackingStore__reset(
     std::shared_ptr<v8::BackingStore>& ptr) {
-  ptr.reset();
+  if(ptr != NULL){
+    ptr.reset();
+  }
 }
 
 long std__shared_ptr__v8__BackingStore__use_count(