tidev / node-ios-device

Queries connected iOS devices and installs apps
Other
122 stars 37 forks source link

Crashing when accessing invalid address #9

Closed youanden closed 9 years ago

youanden commented 9 years ago

This may not be related to node-ios-device, but according to the Console.app, node-ios-device has something to do with it.

I have an electron app and I am attempting to use the trackDevices or just devices (running on a poll to avoid blocking the UI thread) functions to detect connected iOS devices.

I've witnessed the following:

Here is the relevant bit:

Process:               ElectronReact Helper [3956]
Path:                  /Users/USER/Documents/*/ElectronReact.app/Contents/Frameworks/ElectronReact Helper.app/Contents/MacOS/ElectronReact Helper
Identifier:            com.electron.electronreact.helper
Version:               0
Code Type:             X86-64 (Native)
Parent Process:        Electron [3951]
Responsible:           Electron [3951]
User ID:               501

Date/Time:             2015-10-02 16:10:42.714 -0400
OS Version:            Mac OS X 10.10.5 (14F27)
Report Version:        11
Anonymous UUID:        BA4501D5-37D1-933C-C440-2D46A4724A31

Sleep/Wake UUID:       BB8C9647-D88F-4BEB-A068-BD8E7FF1C1F0

Time Awake Since Boot: 15000 seconds
Time Since Wake:       4600 seconds

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

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0xffffffffffffffff

VM Regions Near 0xffffffffffffffff:
--> shared memory          00007fffffed6000-00007fffffed7000 [    4K] r-x/r-x SM=SHM  

Thread 0 Crashed:: CrRendererMain  Dispatch queue: com.apple.main-thread
0   libnode.dylib                   0x0000000107ec6734 v8::internal::Context::native_context() + 4
1   libnode.dylib                   0x0000000108064723 v8::internal::Isolate::native_context() + 19
2   libnode.dylib                   0x0000000107d9518f v8::Object::New(v8::Isolate*) + 63
3   node_ios_device_v46.node        0x000000011602fd66 Device::Device(_am_device*&) + 68 (nan_implementation_12_inl.h:183)
4   node_ios_device_v46.node        0x000000011602e836 on_device_notification(am_device_notification_callback_info*, void*) + 304 (ios-device.cpp:224)
5   com.apple.mobiledevice          0x00000001160b971f _AMDDeviceAttachedCallbackv3 + 285
6   com.apple.mobiledevice          0x000000011604349c _USBMuxCustomRunLoopSourcePerformCallback + 1396
7   com.apple.CoreFoundation        0x00007fff8d4c6a01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
8   com.apple.CoreFoundation        0x00007fff8d4b8b8d __CFRunLoopDoSources0 + 269
9   com.apple.CoreFoundation        0x00007fff8d4b81bf __CFRunLoopRun + 927
10  com.apple.CoreFoundation        0x00007fff8d4b7bd8 CFRunLoopRunSpecific + 296
11  com.apple.Foundation            0x00007fff8ac10b29 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 278
12  Electron Framework              0x0000000103d0a444 0x103bab000 + 1438788
13  Electron Framework              0x0000000103d09c1c 0x103bab000 + 1436700
14  Electron Framework              0x0000000103d3f973 0x103bab000 + 1657203
15  Electron Framework              0x0000000103d2fe8d 0x103bab000 + 1592973
16  Electron Framework              0x00000001047166f0 0x103bab000 + 11974384
17  Electron Framework              0x000000010418529c 0x103bab000 + 6136476
18  Electron Framework              0x00000001041848f6 0x103bab000 + 6134006
19  Electron Framework              0x0000000103bad44d AtomMain + 77
20  com.electron.electronreact.helper   0x0000000103ba8eea main + 58
21  libdyld.dylib                   0x00007fff81f8d5c9 start + 1

Is this something that can be caught in C++ to avoid accessing a "connected" device when it is in fact disconnected? Am I completely off in my diagnosis?

Any help would be appreciated!

youanden commented 9 years ago

Resolved this issue by basically increasing the CFTimeInterval interval to 1.0 in ios-device.cpp since I don't really need it to be "that" fast - no more crashes.

cb1kenobi commented 9 years ago

@youanden Sorry for the delay in responding. I'm glad to hear that you figured it out! We've never tested node-ios-device from a long running Node app. We basically install the app and relay the system log.

I can see how 0.25 seconds is a bit aggressive. I wonder if 0.5 seconds would solve the problem?

youanden commented 9 years ago

@cb1kenobi Tried it at .5, still happening, though much less frequently.

zcmgyu commented 4 years ago

Hi, @cb1kenobi I have the same issue while running the application. Sometimes it just takes a few seconds to crash Electron application without error message. But sometimes, it is more than one hour until crashing. I'm trying increasing interval in ios-device.cpp as @youanden's suggestion, but that file no longer exists. I appreciate it if you share where I could change that one.