abbr / deasync

Turns async function into sync via JavaScript wrapper of Node event loop
MIT License
971 stars 73 forks source link

Assertion failed : Abort Trap #55

Open RSsimranjeetsingh opened 8 years ago

RSsimranjeetsingh commented 8 years ago

Hi,

I am using deasync module in my jasmine test cases. Actually in my beforeall method of jasmine, I have to synchronously call some async methods in the same order (one after another). But since Javascript is a single threaded scripting lang, hence I have to block the call b/w 2 async methods using deasync method...deasync.runlooponce(); used inside a while loop.

Now the issue is that in Microsoft OS, this works fine, but in case of Mac OS, the script fails abruptly, with the below error message:

Assertion failed: (handle->type == UV_TCP || handle->type == UV_TTY || handle->type == UV_NAMED_PIPE), function uv___stream_fd, file ../deps/uv/src/unix/stream.c, line 1545. Abort trap: 6

Can you please help me out in resolving this issue on Mac OS.

PS : Just for your info, I am also making use of fs - file read & write in a synchronous manner, but making REST API http calls in Async manner. Also in fs fileread method I am converting string text in JSON format using JSON.parse(string text)

Let me know in case you require any further info.

Regards Simran

abbr commented 8 years ago

How can you tell the error is caused by deasync? There is no indication in the message.

RSsimranjeetsingh commented 8 years ago

When I removed the deasync module, & instead chain the http requests within there callback, then it works fine. So suspecting it might be caused by deasync module.

jaysirju commented 8 years ago

I'm actually seeing the same thing as @RSsimranjeetsingh.

RSsimranjeetsingh commented 8 years ago

@jaysirju : Are you also experiencing this issue only on Mac OS? If you can please brief more on your issue?

jaysirju commented 8 years ago

Yes, this is occurring on OS/X 10.11.

I am writing a bunch of tests using Jasmine, and one of the libraries I call uses the deasync module to synchronously call some REST APIs. Executing the tests results in the same exception in this issue (I actually found this by googling the exception). I commented out the call to my library, and now the tests at least execute without the exception.

AlexCatch commented 8 years ago

I am also getting this issue on OSX 10.11, it occurs when trying to use deasync on Google Maps geocoding api.

var func = deasync(googleMapsClient.geocode); var result = func({address: customers[0].get('postCode')}); console.log(result.json.results[0]);

The console.log gets fired and prints out the data before throwing the error mentioned in the issue.

tomerb15 commented 8 years ago

happened here as well with: deasync": "^0.1.4 OSX: 10.11.6

gtorodelvalle commented 8 years ago

Same issue using macOS Sierra:

grantchiu011101 commented 7 years ago

Same issue here..
my development env macOS Sierra: 10.12.1 node version 6.3.1 deasync 0.1.8 and 0.1.9

console.log ( url) ;
request({url: url, json: true})
.then(function(res){

    var close_ary = [ ......] ;
    /* my data here */

    var params = {
        startIdx: 0,
        endIdx: close_ary.length - 1,
        name: "EMA",
        inReal: close_ary,
        optInTimePeriod: 30
    } ;

    var done = false;
    var ema;
    talib.execute(params, function cb(res){
        ema = res;
        done = true ;
    });

    require('deasync').loopWhile(function(){ return !done ; }) ;
}).catch ( function(err) {
    console.log ( "error here") ;
    console.log ( err) ;
}) ;

when i run the above code, the following message will return.

Assertion failed: (handle->type == UV_TCP || handle->type == UV_TTY || handle->type == UV_NAMED_PIPE), function uv___stream_fd, file ../deps/uv/src/unix/stream.c, line 1568.
[Finished in 1.5s with exit code -6]
grantchiu011101 commented 7 years ago

I'm pretty sure deasync have problem after make a TCP call.

cause if i change request to fs.readFileAsync("file.json", "utf-8"), everything is fine.

and It seems this problem on happen on macOS.. cause deasync is fine when same code run on ubuntu. (I tried)

tomerb15 commented 7 years ago

Did anyone solve this? Having the same issue...

TimUnderhay commented 7 years ago

I'm also getting this error on Sierra 10.12.4 with deasync.

I was rather wondering if anyone would be doing something about it at some point, as this has been open for over a year and it appears to be affecting quite a few people?

volure commented 7 years ago

Add one more to this ticker. OSX 10.11.6 node 8.2.0 request 2.81.0 deasync 0.1.10

crashes if I try to allow deasync to sync request. I have tried numerous different things to get deasync to stop crashing. but to no avail, every time I try to deasnc a request in this project, I end up crashing.

Here is a full trace of the issue.

Process:               node [1371]
Path:                  /Users/USER/*/node
Identifier:            node
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        node [1367]
Responsible:           Terminal [311]
User ID:               503

Date/Time:             2017-07-20 13:33:10.386 -0700
OS Version:            Mac OS X 10.11.6 (15G1510)
Report Version:        11
Anonymous UUID:        E54E2CAC-492F-D19C-24EE-8E43419D1B22

Time Awake Since Boot: 290 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Application Specific Information:
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff8f4bdf06 __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff929874ec pthread_kill + 90
2   libsystem_c.dylib               0x00007fff93d596df abort + 129
3   node                            0x0000000100a76ca5 node::Abort() + 34
4   node                            0x0000000100a75b63 node::Assert(char const* const (*) [4]) + 251
5   node                            0x0000000100aab643 node::(anonymous namespace)::Parser::Execute(v8::FunctionCallbackInfo<v8::Value> const&) + 221
6   node                            0x000000010017b0c2 v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) + 466
7   node                            0x00000001001e6eef v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(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) + 911
8   node                            0x00000001001e6449 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) + 281
9   ???                             0x000011d0158040bd 0 + 19585411596477
10  ???                             0x000011d015b62a40 0 + 19585415129664
11  ???                             0x000011d015ae8dc0 0 + 19585414630848
12  ???                             0x000011d015946fd4 0 + 19585412919252
13  ???                             0x000011d015806bbb 0 + 19585411607483
14  ???                             0x000011d015b2935d 0 + 19585414894429
15  ???                             0x000011d015b18ab5 0 + 19585414826677
16  ???                             0x000011d015b18237 0 + 19585414824503
17  ???                             0x000011d015806bbb 0 + 19585411607483
18  ???                             0x000011d015b621ce 0 + 19585415127502
19  ???                             0x000011d015806bbb 0 + 19585411607483
20  ???                             0x000011d015810290 0 + 19585411646096
21  ???                             0x000011d0158d646d 0 + 19585412457581
22  node                            0x0000000100559626 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, bool, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, v8::internal::Handle<v8::internal::Object>, v8::internal::Execution::MessageHandling) + 742
23  node                            0x0000000100559283 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>*) + 179
24  node                            0x00000001001619ef v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) + 559
25  node                            0x0000000100a66432 node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) + 292
26  node                            0x0000000100ac5e0e node::StreamBase::EmitData(long, v8::Local<v8::Object>, v8::Local<v8::Object>) + 214
27  node                            0x0000000100ac8180 node::StreamWrap::OnReadImpl(long, uv_buf_t const*, uv_handle_type, void*) + 524
28  node                            0x0000000100ac8689 node::StreamWrap::OnReadCommon(uv_stream_s*, long, uv_buf_t const*, uv_handle_type) + 127
29  node                            0x0000000100be78a1 uv__stream_io + 1261
30  node                            0x0000000100bef158 uv__io_poll + 1621
31  node                            0x0000000100bdfae7 uv_run + 321
32  deasync.node                    0x000000010222b9ee Run(Nan::FunctionCallbackInfo<v8::Value> const&) + 52
33  deasync.node                    0x000000010222bcf5 Nan::imp::FunctionCallbackWrapper(v8::FunctionCallbackInfo<v8::Value> const&) + 136
34  node                            0x000000010017b0c2 v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) + 466
35  node                            0x00000001001e6eef v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(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) + 911
36  node                            0x00000001001e6449 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) + 281
37  ???                             0x000011d0158040bd 0 + 19585411596477
38  ???                             0x000011d015ba40be 0 + 19585415397566
39  ???                             0x000011d015ba3d8d 0 + 19585415396749
40  ???                             0x000011d015806bbb 0 + 19585411607483
41  ???                             0x000011d015ba28bf 0 + 19585415391423
42  ???                             0x000011d015806bbb 0 + 19585411607483
43  ???                             0x000011d015ba23cb 0 + 19585415390155
44  ???                             0x000011d0159474e3 0 + 19585412920547
45  ???                             0x000011d015947054 0 + 19585412919380
46  ???                             0x000011d015806bbb 0 + 19585411607483
47  ???                             0x000011d015b3e46e 0 + 19585414980718
48  ???                             0x000011d015adbffb 0 + 19585414578171
49  ???                             0x000011d015ad3075 0 + 19585414541429
50  ???                             0x000011d015810290 0 + 19585411646096
51  ???                             0x000011d0158d646d 0 + 19585412457581
52  node                            0x0000000100559626 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, bool, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, v8::internal::Handle<v8::internal::Object>, v8::internal::Execution::MessageHandling) + 742
53  node                            0x0000000100559283 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>*) + 179
54  node                            0x00000001001619ef v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) + 559
55  node                            0x0000000100a66623 node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) + 789
56  node                            0x0000000100aaca53 node::(anonymous namespace)::Parser::OnReadImpl(long, uv_buf_t const*, uv_handle_type, void*) + 219
57  node                            0x0000000100ac8689 node::StreamWrap::OnReadCommon(uv_stream_s*, long, uv_buf_t const*, uv_handle_type) + 127
58  node                            0x0000000100be78a1 uv__stream_io + 1261
59  node                            0x0000000100bef158 uv__io_poll + 1621
60  node                            0x0000000100bdfae7 uv_run + 321
61  node                            0x0000000100a8481c node::Start(v8::Isolate*, node::IsolateData*, int, char const* const*, int, char const* const*) + 736
62  node                            0x0000000100a7f7c1 node::Start(uv_loop_s*, int, char const* const*, int, char const* const*) + 462
63  node                            0x0000000100a7edb5 node::Start(int, char**) + 331
64  node                            0x0000000100000e34 start + 52

Thread 1:: V8 WorkerThread
0   libsystem_kernel.dylib          0x00007fff8f4b7fae semaphore_wait_trap + 10
1   node                            0x0000000100bf5fd7 v8::base::Semaphore::Wait() + 23
2   node                            0x0000000100b075d0 v8::platform::TaskQueue::GetNext() + 48
3   node                            0x0000000100b0ba3b v8::platform::WorkerThread::Run() + 43
4   node                            0x0000000100bf8917 v8::base::ThreadEntry(void*) + 87
5   libsystem_pthread.dylib         0x00007fff9298499d _pthread_body + 131
6   libsystem_pthread.dylib         0x00007fff9298491a _pthread_start + 168
7   libsystem_pthread.dylib         0x00007fff92982351 thread_start + 13

Thread 2:: V8 WorkerThread
0   libsystem_kernel.dylib          0x00007fff8f4b7fae semaphore_wait_trap + 10
1   node                            0x0000000100bf5fd7 v8::base::Semaphore::Wait() + 23
2   node                            0x0000000100b075d0 v8::platform::TaskQueue::GetNext() + 48
3   node                            0x0000000100b0ba3b v8::platform::WorkerThread::Run() + 43
4   node                            0x0000000100bf8917 v8::base::ThreadEntry(void*) + 87
5   libsystem_pthread.dylib         0x00007fff9298499d _pthread_body + 131
6   libsystem_pthread.dylib         0x00007fff9298491a _pthread_start + 168
7   libsystem_pthread.dylib         0x00007fff92982351 thread_start + 13

Thread 3:: V8 WorkerThread
0   libsystem_kernel.dylib          0x00007fff8f4b7fae semaphore_wait_trap + 10
1   node                            0x0000000100bf5fd7 v8::base::Semaphore::Wait() + 23
2   node                            0x0000000100b075d0 v8::platform::TaskQueue::GetNext() + 48
3   node                            0x0000000100b0ba3b v8::platform::WorkerThread::Run() + 43
4   node                            0x0000000100bf8917 v8::base::ThreadEntry(void*) + 87
5   libsystem_pthread.dylib         0x00007fff9298499d _pthread_body + 131
6   libsystem_pthread.dylib         0x00007fff9298491a _pthread_start + 168
7   libsystem_pthread.dylib         0x00007fff92982351 thread_start + 13

Thread 4:: V8 WorkerThread
0   libsystem_kernel.dylib          0x00007fff8f4b7fae semaphore_wait_trap + 10
1   node                            0x0000000100bf5fd7 v8::base::Semaphore::Wait() + 23
2   node                            0x0000000100b075d0 v8::platform::TaskQueue::GetNext() + 48
3   node                            0x0000000100b0ba3b v8::platform::WorkerThread::Run() + 43
4   node                            0x0000000100bf8917 v8::base::ThreadEntry(void*) + 87
5   libsystem_pthread.dylib         0x00007fff9298499d _pthread_body + 131
6   libsystem_pthread.dylib         0x00007fff9298491a _pthread_start + 168
7   libsystem_pthread.dylib         0x00007fff92982351 thread_start + 13

Thread 5:
0   libsystem_kernel.dylib          0x00007fff8f4b7fae semaphore_wait_trap + 10
1   node                            0x0000000100bea5d6 uv_sem_wait + 16
2   node                            0x0000000100adab02 node::inspector::(anonymous namespace)::StartIoThreadMain(void*) + 28
3   libsystem_pthread.dylib         0x00007fff9298499d _pthread_body + 131
4   libsystem_pthread.dylib         0x00007fff9298491a _pthread_start + 168
5   libsystem_pthread.dylib         0x00007fff92982351 thread_start + 13

Thread 6:
0   libsystem_kernel.dylib          0x00007fff8f4bddb6 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff92985728 _pthread_cond_wait + 767
2   node                            0x0000000100bea6f8 uv_cond_wait + 9
3   node                            0x0000000100bddb71 worker + 227
4   libsystem_pthread.dylib         0x00007fff9298499d _pthread_body + 131
5   libsystem_pthread.dylib         0x00007fff9298491a _pthread_start + 168
6   libsystem_pthread.dylib         0x00007fff92982351 thread_start + 13

Thread 7:
0   libsystem_kernel.dylib          0x00007fff8f4bddb6 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff92985728 _pthread_cond_wait + 767
2   node                            0x0000000100bea6f8 uv_cond_wait + 9
3   node                            0x0000000100bddb71 worker + 227
4   libsystem_pthread.dylib         0x00007fff9298499d _pthread_body + 131
5   libsystem_pthread.dylib         0x00007fff9298491a _pthread_start + 168
6   libsystem_pthread.dylib         0x00007fff92982351 thread_start + 13

Thread 8:
0   libsystem_kernel.dylib          0x00007fff8f4bddb6 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff92985728 _pthread_cond_wait + 767
2   node                            0x0000000100bea6f8 uv_cond_wait + 9
3   node                            0x0000000100bddb71 worker + 227
4   libsystem_pthread.dylib         0x00007fff9298499d _pthread_body + 131
5   libsystem_pthread.dylib         0x00007fff9298491a _pthread_start + 168
6   libsystem_pthread.dylib         0x00007fff92982351 thread_start + 13

Thread 9:
0   libsystem_kernel.dylib          0x00007fff8f4bddb6 __psynch_cvwait + 10
1   libsystem_pthread.dylib         0x00007fff92985728 _pthread_cond_wait + 767
2   node                            0x0000000100bea6f8 uv_cond_wait + 9
3   node                            0x0000000100bddb71 worker + 227
4   libsystem_pthread.dylib         0x00007fff9298499d _pthread_body + 131
5   libsystem_pthread.dylib         0x00007fff9298491a _pthread_start + 168
6   libsystem_pthread.dylib         0x00007fff92982351 thread_start + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000006  rcx: 0x00007fff5fbeb8d8  rdx: 0x0000000000000000
  rdi: 0x0000000000000a0b  rsi: 0x0000000000000006  rbp: 0x00007fff5fbeb900  rsp: 0x00007fff5fbeb8d8
   r8: 0x0000000000000040   r9: 0x00007fff79e911e0  r10: 0x0000000008000000  r11: 0x0000000000000206
  r12: 0x00007fff5fbeb988  r13: 0x0000000100d0be06  r14: 0x00007fff79b34000  r15: 0x0000000100d0be02
  rip: 0x00007fff8f4bdf06  rfl: 0x0000000000000206  cr2: 0x00007fff79e8f008

Logical CPU:     0
Error Code:      0x02000148
Trap Number:     133

Binary Images:
       0x100000000 -        0x10141830f +node (???) <C97E3358-C259-3FF4-9B99-EEB6DA64FB9F> /Users/USER/*/node
       0x10222b000 -        0x10222bfff +deasync.node (???) <421576A9-3767-3636-9008-37D06B109868> /Users/USER/*/deasync.node
       0x102230000 -        0x102258ff7 +uws_darwin_57.node (???) <2D799611-4703-3924-BDD0-FDC6ECF83CAC> /Users/USER/*/uws_darwin_57.node
    0x7fff659e0000 -     0x7fff65a17a47  dyld (360.22) <884763FC-CC0F-31CC-ACC4-75A805CE401D> /usr/lib/dyld
    0x7fff87fe7000 -     0x7fff881f4fff  libicucore.A.dylib (551.51.4) <3899B146-3840-3D4A-8C4A-FE391D5D25C7> /usr/lib/libicucore.A.dylib
    0x7fff88b3c000 -     0x7fff88b3dfff  libsystem_blocks.dylib (65) <1244D9D5-F6AA-35BB-B307-86851C24B8E5> /usr/lib/system/libsystem_blocks.dylib
    0x7fff89cfd000 -     0x7fff89d05ffb  libsystem_dnssd.dylib (625.60.4) <80189998-32B0-316C-B5C5-53857486713D> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff8a7ba000 -     0x7fff8a7bbffb  libSystem.B.dylib (1226.10.1) <8B780EC7-53B7-3844-B3D8-5E81F5CA598C> /usr/lib/libSystem.B.dylib
    0x7fff8aad9000 -     0x7fff8aae2ff3  libsystem_notify.dylib (150.40.1) <D48BDE34-0F7E-34CA-A0FF-C578E39987CC> /usr/lib/system/libsystem_notify.dylib
    0x7fff8afb5000 -     0x7fff8b01bff7  libsystem_network.dylib (583.50.1) <B52DAB73-92DC-3DA7-B9F4-B899D66445C1> /usr/lib/system/libsystem_network.dylib
    0x7fff8b353000 -     0x7fff8b35bfff  libsystem_networkextension.dylib (385.40.36) <66095DC7-6539-38F2-95EE-458F15F6D014> /usr/lib/system/libsystem_networkextension.dylib
    0x7fff8b35c000 -     0x7fff8b389fff  libdispatch.dylib (501.40.12) <C7499857-61A5-3D7D-A5EA-65DCC8C3DF92> /usr/lib/system/libdispatch.dylib
    0x7fff8b38a000 -     0x7fff8b395ff7  libcommonCrypto.dylib (60075.50.1) <93732261-34B4-3914-B7A2-90A81A182DBA> /usr/lib/system/libcommonCrypto.dylib
    0x7fff8b396000 -     0x7fff8b39efff  libcopyfile.dylib (127) <A48637BC-F3F2-34F2-BB68-4C65FD012832> /usr/lib/system/libcopyfile.dylib
    0x7fff8bfc6000 -     0x7fff8bfcafff  libcache.dylib (75) <9548AAE9-2AB7-3525-9ECE-A2A7C4688447> /usr/lib/system/libcache.dylib
    0x7fff8e2ec000 -     0x7fff8e2fdff7  libsystem_trace.dylib (201.10.3) <E9311C03-9E61-3B13-AF3F-A64956FFF269> /usr/lib/system/libsystem_trace.dylib
    0x7fff8e791000 -     0x7fff8e7c0ffb  libsystem_m.dylib (3105) <08E1A4B2-6448-3DFE-A58C-ACC7335BE7E4> /usr/lib/system/libsystem_m.dylib
    0x7fff8ef6a000 -     0x7fff8efe1feb  libcorecrypto.dylib (335.50.1) <B5C05FD7-A540-345A-87BF-8E41848A3C17> /usr/lib/system/libcorecrypto.dylib
    0x7fff8efe2000 -     0x7fff8efe3fff  libsystem_secinit.dylib (20) <32B1A8C6-DC84-3F4F-B8CE-9A52B47C3E6B> /usr/lib/system/libsystem_secinit.dylib
    0x7fff8f1bc000 -     0x7fff8f1bdffb  libremovefile.dylib (41) <552EF39E-14D7-363E-9059-4565AC2F894E> /usr/lib/system/libremovefile.dylib
    0x7fff8f4a7000 -     0x7fff8f4c5ff7  libsystem_kernel.dylib (3248.60.11.5.3) <F8228B30-AF62-3D47-A3A9-4A360787B238> /usr/lib/system/libsystem_kernel.dylib
    0x7fff8faa2000 -     0x7fff8faaafef  libsystem_platform.dylib (74.40.2) <29A905EF-6777-3C33-82B0-6C3A88C4BA15> /usr/lib/system/libsystem_platform.dylib
    0x7fff8faab000 -     0x7fff8ff21fff  com.apple.CoreFoundation (6.9 - 1259.11) <B8056BE3-151B-3003-91C9-6720CF04937B> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7fff90a06000 -     0x7fff90a2fff7  libxpc.dylib (765.50.8.1.1) <2819674A-621A-3ACB-9657-DF42353D6CFD> /usr/lib/system/libxpc.dylib
    0x7fff90a39000 -     0x7fff90a39ff7  libunc.dylib (29) <DDB1E947-C775-33B8-B461-63E5EB698F0E> /usr/lib/system/libunc.dylib
    0x7fff90a6f000 -     0x7fff90a98fff  libsystem_info.dylib (477.50.4) <FAA9226D-64DE-3769-A6D8-6CABA4B7FF4D> /usr/lib/system/libsystem_info.dylib
    0x7fff91068000 -     0x7fff9106dff3  libunwind.dylib (35.3) <F6EB48E5-4D12-359A-AB54-C937FBBE9043> /usr/lib/system/libunwind.dylib
    0x7fff91077000 -     0x7fff91079fff  libsystem_coreservices.dylib (19.2) <1B3F5AFC-FFCD-3ECB-8B9A-5538366FB20D> /usr/lib/system/libsystem_coreservices.dylib
    0x7fff92981000 -     0x7fff9298aff7  libsystem_pthread.dylib (138.10.4) <3DD1EF4C-1D1B-3ABF-8CC6-B3B1CEEE9559> /usr/lib/system/libsystem_pthread.dylib
    0x7fff92dd6000 -     0x7fff92dedff7  libsystem_asl.dylib (323.50.1) <41F8E11F-1BD0-3F1D-BA3A-AA1577ED98A9> /usr/lib/system/libsystem_asl.dylib
    0x7fff93638000 -     0x7fff9363bfff  libsystem_sandbox.dylib (460.60.3) <2DDCB4AF-3037-34E5-A451-6846AFB9B85C> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff93cfb000 -     0x7fff93d88fef  libsystem_c.dylib (1082.60.1) <28733D22-553E-3CBC-8D2C-EDCEB46E46AF> /usr/lib/system/libsystem_c.dylib
    0x7fff93d93000 -     0x7fff93d95ff7  libquarantine.dylib (80) <B3B7B630-9012-3DA3-9458-5C009625E606> /usr/lib/system/libquarantine.dylib
    0x7fff93e30000 -     0x7fff93e76ff7  libauto.dylib (186) <999E610F-41FC-32A3-ADCA-5EC049B65DFB> /usr/lib/libauto.dylib
    0x7fff94196000 -     0x7fff941e9ff7  libc++.1.dylib (120.1) <8FC3D139-8055-3498-9AC5-6467CB7F4D14> /usr/lib/libc++.1.dylib
    0x7fff941ea000 -     0x7fff941ebfff  libDiagnosticMessagesClient.dylib (100) <4243B6B4-21E9-355B-9C5A-95A216233B96> /usr/lib/libDiagnosticMessagesClient.dylib
    0x7fff94c71000 -     0x7fff94c76ff7  libmacho.dylib (875.1) <318264FA-58F1-39D8-8285-1F6254EE410E> /usr/lib/system/libmacho.dylib
    0x7fff965c6000 -     0x7fff965c6fff  liblaunch.dylib (765.50.8.1.1) <6E0BA641-F99D-398C-B5F1-A921EFFB3786> /usr/lib/system/liblaunch.dylib
    0x7fff9666d000 -     0x7fff96670ffb  libdyld.dylib (360.22) <F103B2FB-D383-38CB-992A-E16BDCB00A03> /usr/lib/system/libdyld.dylib
    0x7fff9669f000 -     0x7fff966a1ff7  libsystem_configuration.dylib (802.40.13) <3DEB7DF9-6804-37E1-BC83-0166882FF0FF> /usr/lib/system/libsystem_configuration.dylib
    0x7fff98569000 -     0x7fff9857aff7  libz.1.dylib (61.20.1) <B3EBB42F-48E3-3287-9F0D-308E04D407AC> /usr/lib/libz.1.dylib
    0x7fff98978000 -     0x7fff98978ff7  libkeymgr.dylib (28) <8371CE54-5FDD-3CE9-B3DF-E98C761B6FE0> /usr/lib/system/libkeymgr.dylib
    0x7fff9bfb3000 -     0x7fff9bfbaff7  libcompiler_rt.dylib (62) <A13ECF69-F59F-38AE-8609-7B731450FBCD> /usr/lib/system/libcompiler_rt.dylib
    0x7fff9c3a9000 -     0x7fff9c70bf3f  libobjc.A.dylib (680) <7489D2D6-1EFD-3414-B18D-2AECCCC90286> /usr/lib/libobjc.A.dylib
    0x7fff9cb8b000 -     0x7fff9cba7ff7  libsystem_malloc.dylib (67.40.1) <5748E8B2-F81C-34C6-8B13-456213127678> /usr/lib/system/libsystem_malloc.dylib
    0x7fff9d476000 -     0x7fff9d4a0ff7  libc++abi.dylib (307.2) <922EFB36-0E9E-315B-8270-E81AC43472C0> /usr/lib/libc++abi.dylib
    0x7fff9d849000 -     0x7fff9d860ff7  libsystem_coretls.dylib (83.40.5) <C90DAE38-4082-381C-A185-2A6A8B677628> /usr/lib/system/libsystem_coretls.dylib

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 18
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 14762
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=138.9M resident=0K(0%) swapped_out_or_unallocated=138.9M(100%)
Writable regions: Total=128.4M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=128.4M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                  2048K        2 
Kernel Alloc Once                    4K        2 
MALLOC                            46.8M       24 
MALLOC guard page                   16K        4 
Memory Tag 255                   547.3M      112 
STACK GUARD                       56.0M       11 
Stack                             44.1M       11 
VM_ALLOCATE                          4K        2 
__DATA                            3640K       48 
__LINKEDIT                       104.6M        6 
__TEXT                            34.3M       48 
__UNICODE                          552K        2 
shared memory                       12K        4 
===========                     =======  ======= 
TOTAL                            839.3M      263 
stetsmando commented 7 years ago

I'm also having this issue and am also on MacOS 10.12.6. I'm using the require('deasync').loopWhile(function(){return !done;}); flavor. I actually found this issue in the Node repo itself. It mentions that the issue may be linked to memory consumption.

celso commented 7 years ago

Same problem here. Assertion failed: (handle->type == UV_TCP || handle->type == UV_TTY || handle->type == UV_NAMED_PIPE), function uv___stream_fd, file ../deps/uv/src/unix/stream.c, line 1619.

dremekie commented 7 years ago

While this is a very convenient module, I can confirm that it has caused nightmares for me when using it with redis, sqlite3 and another datastore that I cannot recall at the moment. The only way I was able to get around the issue (unexplained connectivity problems) is to completely remove the use of this module.

stetsmando commented 7 years ago

@dremekie I unfortunately had to do the same. It forced me to write my async code in a different place where previously I was writing it in Mongoose lifecycle hooks (don't ask me why, it's a long story).

TimUnderhay commented 7 years ago

If the lack of action on this issue is bothering you, I would urge you to contact the author directly, as he/she does not appear to be seeing all of the requests for help. The email address can be found by visiting https://api.github.com/users/NNNN/events/public, plugging in the username for NNNN, and looking for the 'email' property.

dremekie commented 7 years ago

@citizentim My intent was to share my experience with the others that were hitting similar issues. The lack of action on this issue is not bothering me (anymore). :)

TimUnderhay commented 7 years ago

My comment wasn't directed specifically to you, @dremekie, but to all those facing the same issues.

mmontano commented 6 years ago

I had this same issue and I was able to make this work by doing two things:

  1. I put the require in the same scope level as the loopWhile call
  2. I defined the test variable after the require to deasync

previously I had:

deasync = require("deasync")

testFunction = -> --- testVar = false ---asyncFunction -> ------doSomething() ------testVar = true ---deasync.loopWhile(!testVar)

the above would get the assert error The below works and does not cause the error

testFunction = -> ---deasync = require("deasync") ---testVar = false ---asyncFunction -> ------doSomething() ------testVar = true ---deasync.loopWhile(!testVar)

elado commented 6 years ago

Seeing the same error in jest, when using npm-install-version (that uses deasync as a dependency)

It looks like it's coming from binding.run() in loopWhile.

BenPatterson2 commented 5 years ago

Also seeing this

CyrusNajmabadi commented 5 years ago

Also hitting. Question for people here, are you hitting this on only Macs, or on Windows or Linux. So far we've only seen it on macs.

For context, pulumi is hitting this in: https://github.com/pulumi/pulumi/issues/3260

CyrusNajmabadi commented 5 years ago

So, doing some psychic debugging (i.e. not actually debugging through this happening live, just examining callstack and docs).

libuv docs clearly state:

http://docs.libuv.org/en/v1.x/loop.html#c.uv_run

uv_run() is not reentrant. It must not be called from a callback.

Looking into the issue more, this is not only difficult for them to support, they just have lots of code that has the presumption that there will be no reentrant calls.

However, as we can see in the stack listed in

However, from the callstack listed in https://github.com/abbr/deasync/issues/55#issuecomment-316822474 there is clearly reentrancy here:

25  node                            0x0000000100a66432 node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) + 292
26  node                            0x0000000100ac5e0e node::StreamBase::EmitData(long, v8::Local<v8::Object>, v8::Local<v8::Object>) + 214
27  node                            0x0000000100ac8180 node::StreamWrap::OnReadImpl(long, uv_buf_t const*, uv_handle_type, void*) + 524
28  node                            0x0000000100ac8689 node::StreamWrap::OnReadCommon(uv_stream_s*, long, uv_buf_t const*, uv_handle_type) + 127
29  node                            0x0000000100be78a1 uv__stream_io + 1261
30  node                            0x0000000100bef158 uv__io_poll + 1621
31  node                            0x0000000100bdfae7 uv_run + 321
32  deasync.node                    0x000000010222b9ee Run(Nan::FunctionCallbackInfo<v8::Value> const&) + 52
33  deasync.node                    0x000000010222bcf5 Nan::imp::FunctionCallbackWrapper(v8::FunctionCallbackInfo<v8::Value> const&) + 136
34  node                            0x000000010017b0c2 v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) + 466
...
53  node                            0x0000000100559283 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>*) + 179
54  node                            0x00000001001619ef v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) + 559
55  node                            0x0000000100a66623 node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) + 789
56  node                            0x0000000100aaca53 node::(anonymous namespace)::Parser::OnReadImpl(long, uv_buf_t const*, uv_handle_type, void*) + 219
57  node                            0x0000000100ac8689 node::StreamWrap::OnReadCommon(uv_stream_s*, long, uv_buf_t const*, uv_handle_type) + 127
58  node                            0x0000000100be78a1 uv__stream_io + 1261
59  node                            0x0000000100bef158 uv__io_poll + 1621
60  node                            0x0000000100bdfae7 uv_run + 321
61  node                            0x0000000100a8481c node::Start(v8::Isolate*, node::IsolateData*, int, char const* const*, int, char const* const*) + 736

It looks like the initial node code is called back into due to some stream IO being received. This is happening in frames 60->50. This causes some amount of callback code to run until it eventually hits the deasync.Run call (which you can see in frames 32-33). that Run call also ends up receiving some sort of stream IO which it then tries to process but ends up asserting on.

It seems likely that something in the apple specific code for libuv is working in a manner where they are just not safe to this sort of thing happening. They might have some code that simply does something like this:

someState = true
... work ...
someState = false

And this immediately doesn't work in a reentrant environment as what's in an outer ...work... may end up with inconsistent values for this state due to an inner returning and corrupting things.

I have no good answers on what to do here.