Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.squareup.SocketRocket.NetworkThread(18): EXC_BAD_ACCESS #6117

Closed
hasen6 opened this issue Feb 24, 2016 · 41 comments
Closed

com.squareup.SocketRocket.NetworkThread(18): EXC_BAD_ACCESS #6117

hasen6 opened this issue Feb 24, 2016 · 41 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@hasen6
Copy link

hasen6 commented Feb 24, 2016

After leaving the program running for a few minutes it freezes and I get this error. Running version 0.19.

@fender
Copy link

fender commented Apr 13, 2016

@hasen6 Did you fix your issues?

I get a similar error. com.squareup.SocketRocket.NetworkThread (17): EXC_BAD_ACCESS (code=1)

@hasen6
Copy link
Author

hasen6 commented Apr 14, 2016

Well I think it was to do with the memory leak problem that they still haven't fixed. I haven't had that error again, I mainly get malloc errors which I assume are also to do with the memory leak problem.

@lacker
Copy link
Contributor

lacker commented Oct 21, 2016

I think this is fixed now. I'm going to close this issue but feel free to reopen it if this is still occurring.

@lacker lacker closed this as completed Oct 21, 2016
@azanli
Copy link

azanli commented Mar 20, 2018

This is happening to me after upgrading to RN v0.54.2. Only occurs on iOS builds and happens under the same conditions - after a few minutes of non-usage it freezes and Xcode pinpoints the error here:

RCTWebSocket.xcodeproj > RCTSRWebSocket.m > -stream:handleEvent:

assert(_workQueue != NULL);
  dispatch_async(_workQueue, ^{	     <==== com.squareup.SocketRocket.NetworkThread (9): EXC_BAD_ACCESS (code=1, address=0x51760916)
    switch (eventCode) {
      case NSStreamEventOpenCompleted: {
        RCTSRLog(@"NSStreamEventOpenCompleted %@", aStream);
        if (self.readyState >= RCTSR_CLOSING) {
          return;
        }
        assert(self->_readBuffer);

        if (self.readyState == RCTSR_CONNECTING && aStream == self->_inputStream) {
          [self didConnect];
        }
        [self _pumpWriting];
        [self _pumpScanner];
        break;
      }

@pergunt
Copy link

pergunt commented Mar 26, 2018

When i leave the iPhone for few seconds in Debug-remotely mode this error is occurs and all making freeze com.squareup.SocketRocket.NetworkThread (10): signal SIGABRT. Anyone resolve it ?

@ozberkctn
Copy link

I have same problem. Any idea ? @friendly-robot

@maxim-kolesnikov
Copy link

Same problem when I open WebView and wait ~10 min.
Debug status: On

"react": "16.2.0",
"react-native": "0.53.0",

@Paul-Bird
Copy link

Leave debugging for short while also have EXC_BAD_ACCESS for com.squareup.SocketRocket.NetworkThread - (void)main; (line 1592) . react-native: 0.54.4

@SuhairZain
Copy link
Contributor

@lacker I can verify that this issue is still happening. Following is my env details:

Environment:
  OS: macOS High Sierra 10.13.4
  Node: 8.4.0
  Yarn: 0.27.5
  npm: 5.3.0
  Watchman: 4.9.0
  Xcode: Xcode 9.3 Build version 9E145
  Android Studio: 3.1 AI-173.4697961

Packages: (wanted => installed)
  react: 16.2.0 => 16.2.0
  react-native: 0.53.0 => 0.53.0

Could you please reopen this issue?

@jayporta
Copy link

I am also experiencing this issue

Environment:
OS: macOS High Sierra 10.13.4
Node: 8.4.0
npm: 4.6.1
Watchman: 4.9.1
Xcode: Xcode 9.3 Build version 9E145
Android Studio: n/a
React Native: react-native: 0.55.2

Error:

Assertion failed: (_workQueue != NULL), function -[RCTSRWebSocket stream:handleEvent:], file /Users/jay/Developer/DeveloperSubDirectory/ProjectDirectory/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m, line 1349.

@amardeepranu
Copy link

amardeepranu commented Apr 23, 2018

Happening to me as well on RN v0.54.2

@iamdurui
Copy link

Happening to me as well on RN v0.55.3

@andidev
Copy link

andidev commented Apr 28, 2018

@lacker
This should really be reopened and somebody should really look into this. We are doing http requests each second and after a while the app crashes which makes the app totally useless.

@nick-skriabin
Copy link

Same here

iOS 11.3 (iPhone X, iPhone 6s)
macOS 10.13.4
RN 0.55.3
React 16.3.1

@undef1ned
Copy link

Same issue

Environment:
OS: macOS High Sierra 10.13.1
Node: 8.9.4
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

@Yessengerey
Copy link

The same issue is happening to me as well.

Error message:
com.squareup.SocketRocket.NetworkThread (10): signal SIGABRT`

However, I have a suspicion that this might be due to my other error in the same file of RCTSRWebSocket.m:
'React/RCTAssert.h' file not found
Which I, unfortunately, was not able to resolve no matter what I tried.

Environment:
OS: macOS High Sierra 10.13.4
Node: 8.9.4
Yarn: 1.6.0
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.3.1 Build version 9E501
Android Studio: 3.1 AI-173.4720617

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4

@handsssome
Copy link

handsssome commented May 31, 2018

I got this too
com.squareup.SocketRocket.NetworkThread (8): signal SIGABRT

Environment:
OS: macOS High Sierra 10.13.4
Node: 8.9.4
Yarn: Not Found
npm: 6.1.0
Watchman: 4.9.0
Xcode: Xcode 9.4 Build version 9F1027a
Android Studio: 3.0 AI-171.4408382

Packages: (wanted => installed)
react: ^16.3.1 => 16.3.1
react-native: ^0.54.4 => 0.54.4

@mikekhristo
Copy link

mikekhristo commented Jun 2, 2018

Happening here as well.

com.squareup.SocketRocket.NetworkThread (15): signal SIGABRT

Environment:
OS: macOS High Sierra 10.13.5
Node: 9.2.0
Yarn: 1.2.0
npm: 6.1.0
Watchman: 4.9.0
Xcode: Xcode 9.3.1 Build version 9E501

Packages
react: 16.4.0
react-native: 0.55.2

@topwebtek7
Copy link

Happening on my app as well. Same env as above ☝️

@udarts
Copy link

udarts commented Jun 5, 2018

I keep getting the same issue, and I must say it is getting really annoying. Can someone please take a look at those errors and fix them?

@tapz
Copy link

tapz commented Jun 6, 2018

Looks like it only took 2 years to fix this... #19489

@udarts
Copy link

udarts commented Jun 7, 2018

@tapz thanks, I checked and made changes on my end, but still the error occurs. Also looking at the link, it seems that not all tests are ok.

@udarts
Copy link

udarts commented Jun 8, 2018

I can't work like this, constantly getting that **** error: Assertion failed: (_workQueue != NULL), function -[RCTSRWebSocket stream:handleEvent:], file ../node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m, line 1343.

I know more people getting this error and it is really frustrating.

@zhongwuzw
Copy link
Contributor

zhongwuzw commented Jun 9, 2018

@andidev @nicholasrq , Sorry for not working, I try my best to resolve these crash, now I refactor some code sync from SRWebSocket, please see 19498, much appreciated if you guys can try it and give me some feedback. 😂

@udarts , Can you remove the assert statements of _workQueue and add some code like below based on my PR to test wether it crash? I just can't reproduce crash now.

@nick-skriabin
Copy link

@zhongwuzw does it affect debugging in any way? if i understand this part of the code correctly this code allows us to use webworkers for remote debugging. correct me if i’m wrong

@zhongwuzw
Copy link
Contributor

@nicholasrq , It's the native code of WebSocket, in other words, we can setup a websocket connection. So any besides debugging wants to use WebSocket protocol would use this.

@andidev
Copy link

andidev commented Jun 13, 2018

@zhongwuzw
I tried your fix (by modifying RCTSRWebSocket.m in node_modules) and though it worked for a while, but sadly it did not fix my issue. I get the following Crash backtrace.

Crashed Thread:        4  com.squareup.SocketRocket.NetworkThread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       EXC_I386_GPFLT
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

Application Specific Information:
CoreSimulator 518.22 - Device: iPhone 6 - Runtime: iOS 9.0 (13A344) - DeviceType: iPhone 6

...

Thread 4 Crashed:: com.squareup.SocketRocket.NetworkThread
0   libobjc.A.dylib                     0x0000000108fb4d10 objc_retain + 16
1   libobjc.A.dylib                     0x0000000108fb4d4a objc_storeStrong + 32
2   com.ressgroup.ress.debug            0x000000010826c0b5 __copy_helper_block_.482 + 69 (RCTSRWebSocket.m:1344)
3   libsystem_blocks.dylib              0x000000010d99359d _Block_copy_internal + 325
4   libdispatch.dylib                   0x000000010d905ddd _dispatch_Block_copy + 43
5   libdispatch.dylib                   0x000000010d909298 dispatch_async + 57
6   com.ressgroup.ress.debug            0x000000010826b540 -[RCTSRWebSocket stream:handleEvent:] + 1680 (RCTSRWebSocket.m:1344)
7   com.apple.CoreFoundation            0x000000010a0ce124 _signalEventSync + 180
8   com.apple.CoreFoundation            0x000000010a10242e _cfstream_shared_signalEventSync + 478
9   com.apple.CoreFoundation            0x000000010a0900a1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
10  com.apple.CoreFoundation            0x000000010a085fcc __CFRunLoopDoSources0 + 556
11  com.apple.CoreFoundation            0x000000010a085483 __CFRunLoopRun + 867
12  com.apple.CoreFoundation            0x000000010a084e98 CFRunLoopRunSpecific + 488
13  com.apple.Foundation                0x0000000108b8f891 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 267
14  com.ressgroup.ress.debug            0x000000010826d368 -[_RCTSRRunLoopThread main] + 376 (RCTSRWebSocket.m:1586)
15  com.apple.Foundation                0x0000000108c2d36b __NSThread__start__ + 1198
16  libsystem_pthread.dylib             0x000000010dc4d661 _pthread_body + 340
17  libsystem_pthread.dylib             0x000000010dc4d50d _pthread_start + 377
18  libsystem_pthread.dylib             0x000000010dc4cbf9 thread_start + 13

@nick-skriabin
Copy link

nick-skriabin commented Jun 14, 2018

Now i'm getting this error instead of queue thing (after fixing it using @zhongwuzw approach)

It's in react-native/Libraries/WebSocket/RCTSRWebSocket.m at line 1599

Same as before, after 10-20 minutes of idle app crashed

image

@LuongTruong
Copy link

Hi guys, this issue is bothering me. I try the solution of @zhongwuzw, my application last longer but then it continue to crash again.

My Env:
"react": "16.3.1",
"react-native": "0.55.4",

If someone have solution please let me know. Thank you in advance!

@zhongwuzw
Copy link
Contributor

@truongluong1314520 , you try the PR? Can you post the crash backtrace?

@SiBorya
Copy link

SiBorya commented Jun 25, 2018

I faced same issue as @nicholasrq at the first place. However, I used that PR by @zhongwuzw , it works for more than 20 minutes now. I will keep the app running for hours and post the issue here if any.

@LuongTruong
Copy link

Hi @zhongwuzw , I use your code:

`// Don't use code below please
// assert(_workQueue != NULL);
dispatch_queue_t workQueue = _workQueue;

if (workQueue == NULL) {
return;
}

dispatch_async(workQueue, ^{
switch (eventCode) {
case NSStreamEventOpenCompleted: {
........`

I will run it again and report it to you later

@zhongwuzw
Copy link
Contributor

@truongluong1314520 , Emm, you should use this, I will remove the comments to prevent misleading.

@LuongTruong
Copy link

Sr @zhongwuzw , after reading the ticket, I do not know what to do in my RCTSRWebSocket.m to fix the issue. Can you please give me more details?

@SiBorya
Copy link

SiBorya commented Jun 26, 2018

I kept the app running for more than 18 hours, it works properly. I suppose the PR really solve this issue since 2016.
@truongluong1314520 What you have to do is copy and paste. Click into "File Changed" section and "View" that RCTSRWebSocket.m, copy that content into yours.

@LuongTruong
Copy link

Hi @zhongwuzw , thank you for your solution and quick reply. From what Kroderia said, I am sure your code can work like a charm
Hi @Kroderia , thank you for test. Everybody should see this

@lorenc-tomasz
Copy link

The same crash on 0.55.4

@erwan-lcs
Copy link

Hi @zhongwuzw

Copy pasting the content of RCTSRWebSocket.m from your pull request #19489
into: [MyProject] > Libraries > RCTWebSocket.xcodeproj > RCTSRWebSocket.m in XCode works for me ! It has been running for 16 hours so far when it was crashing after a few minutes before.

My setup: iPad3 iOs 9.3.5, xCode 9.4.1

  "dependencies": {
    "appcenter": "^1.4.0",
    "appcenter-analytics": "^1.4.0",
    "appcenter-crashes": "^1.4.0",
    "axios": "^0.18.0",
    "eslint-config-rallycoding": "^3.2.0",
    "lz-string": "^1.4.4",
    "moment": "^2.22.1",
    "react": "16.3.2",
    "react-native": "0.55.3",
    "react-native-device-info": "^0.21.5",
    "react-native-fcm": "^14.1.3",
    "react-native-fs": "^2.9.12",
    "react-native-mail": "^3.0.6",
    "react-native-vector-icons": "^4.6.0",
    "react-navigation": "1.5.11",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-thunk": "^2.2.0"
  }

@zhongwuzw
Copy link
Contributor

@Kroderia @erwan-lcs , Thanks for tests.

@technoplato
Copy link

@erwan-lcs I copy-pasted the code you linked and so far, everything is working again as expected. Will report back if any errors occur.

@mattijsf
Copy link
Contributor

I have been using the following (dirty) script to apply the PR during my post-install:

echo "Patching RCTSRWebSocket.m from https://github.com/facebook/react-native/pull/19489"
# The patch iself outputs a failure when the file is already patched therefor the output is silenced and the exit code is ignored
# Important: Note that due to the above the patch might silently fail to apply in a future version of react-native!
curl -sS https://patch-diff.githubusercontent.com/raw/facebook/react-native/pull/19489.patch | patch -p1 -N -d node_modules/react-native &> /dev/null || true

I can say that I haven't seen any com.squareup.SocketRocket related crashes after that.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
facebook-github-bot pushed a commit that referenced this issue Jan 2, 2019
Summary:
Fixes #21086.
Fixes #6117.

This PR fixes a crash caused by a race condition when `webSocket` deallocated and `NSStream` delegate callback, because `NSStream`'s delegate callback be called on `RCTSR_networkRunLoop`.

This PR mainly changes:

* Remove unnecessary `nil` operation in `dealloc` method.
* Add a new method `_scheduleCleanUp` to schedule `webSocket` cleanup also on `RCTSR_networkRunLoop`.
* In `stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode` delegate method, add a `wself` to make safe further.
Pull Request resolved: #22439

Differential Revision: D13564247

Pulled By: cpojer

fbshipit-source-id: 675c1b2805aa45c54d7708d796f5843ef7ea34e2
bruchim pushed a commit to wix-playground/react-native that referenced this issue Feb 12, 2019
Summary:
Fixes facebook#21086.
Fixes facebook#6117.

This PR fixes a crash caused by a race condition when `webSocket` deallocated and `NSStream` delegate callback, because `NSStream`'s delegate callback be called on `RCTSR_networkRunLoop`.

This PR mainly changes:

* Remove unnecessary `nil` operation in `dealloc` method.
* Add a new method `_scheduleCleanUp` to schedule `webSocket` cleanup also on `RCTSR_networkRunLoop`.
* In `stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode` delegate method, add a `wself` to make safe further.
Pull Request resolved: facebook#22439

Differential Revision: D13564247

Pulled By: cpojer

fbshipit-source-id: 675c1b2805aa45c54d7708d796f5843ef7ea34e2
marcinolek pushed a commit to marcinolek/react-native that referenced this issue Feb 13, 2019
Summary:
Fixes facebook#21086.
Fixes facebook#6117.

This PR fixes a crash caused by a race condition when `webSocket` deallocated and `NSStream` delegate callback, because `NSStream`'s delegate callback be called on `RCTSR_networkRunLoop`.

This PR mainly changes:

* Remove unnecessary `nil` operation in `dealloc` method.
* Add a new method `_scheduleCleanUp` to schedule `webSocket` cleanup also on `RCTSR_networkRunLoop`.
* In `stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode` delegate method, add a `wself` to make safe further.
Pull Request resolved: facebook#22439

Differential Revision: D13564247

Pulled By: cpojer

fbshipit-source-id: 675c1b2805aa45c54d7708d796f5843ef7ea34e2
grabbou pushed a commit that referenced this issue Feb 18, 2019
Summary:
Fixes #21086.
Fixes #6117.

This PR fixes a crash caused by a race condition when `webSocket` deallocated and `NSStream` delegate callback, because `NSStream`'s delegate callback be called on `RCTSR_networkRunLoop`.

This PR mainly changes:

* Remove unnecessary `nil` operation in `dealloc` method.
* Add a new method `_scheduleCleanUp` to schedule `webSocket` cleanup also on `RCTSR_networkRunLoop`.
* In `stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode` delegate method, add a `wself` to make safe further.
Pull Request resolved: #22439

Differential Revision: D13564247

Pulled By: cpojer

fbshipit-source-id: 675c1b2805aa45c54d7708d796f5843ef7ea34e2
t-nanava pushed a commit to microsoft/react-native-macos that referenced this issue Jun 17, 2019
Summary:
Fixes facebook#21086.
Fixes facebook#6117.

This PR fixes a crash caused by a race condition when `webSocket` deallocated and `NSStream` delegate callback, because `NSStream`'s delegate callback be called on `RCTSR_networkRunLoop`.

This PR mainly changes:

* Remove unnecessary `nil` operation in `dealloc` method.
* Add a new method `_scheduleCleanUp` to schedule `webSocket` cleanup also on `RCTSR_networkRunLoop`.
* In `stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode` delegate method, add a `wself` to make safe further.
Pull Request resolved: facebook#22439

Differential Revision: D13564247

Pulled By: cpojer

fbshipit-source-id: 675c1b2805aa45c54d7708d796f5843ef7ea34e2
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.