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

SocketException: Reading from a closed socket #47018

Open
huangsir0 opened this issue Aug 26, 2021 · 8 comments
Open

SocketException: Reading from a closed socket #47018

huangsir0 opened this issue Aug 26, 2021 · 8 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. library-io P2 A bug or feature request we're likely to work on

Comments

@huangsir0
Copy link

Steps to Reproduce

I don't know how to reproduce this SocketException,it suddenly report an error during the application.

flutter doctor

[✓] Flutter (Channel stable, 2.2.0, on macOS 11.2.3 20D91 darwin-x64, locale zh-Hans-CN)
    • Flutter version 2.2.0 at /Users/huangsir/flutter-2.0.6/flutter
    • Framework revision b22742018b (3 months ago), 2021-05-14 19:12:57 -0700Engine revision a9d88a4d18
    • Dart version 2.13.0Pub download mirror https://pub.flutter-io.cnFlutter download mirror https://storage.flutter-io.cn

error stack

flutter: content: Caught error: SocketException: Reading from a closed socket
flutter: content: #0      _RawSecureSocket.read (dart:io/secure_socket.dart:662:7)
dart-lang/http#1      _Socket._onData (dart:io-patch/socket_patch.dart:2159:28)
dart-lang/http#2      _rootRunUnary (dart:async/zone.dart:1362:47)
dart-lang/http#3      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
dart-lang/http#4      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
dart-lang/http#5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
dart-lang/http#6      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
dart-lang/http#7      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
dart-lang/http#8      _StreamController._add (dart:async/stream_controller.dart:607:7)
dart-lang/http#9      _StreamController.add (dart:async/stream_controller.dart:554:5)
dart-lang/http#10     _RawSecureSocket._sendReadEvent (dart:io/secure_socket.dart:991:19)
dart-lang/http#11     _rootRun (dart:async/zone.dart:1346:47)
dart-lang/http#12     _CustomZone.run (dart:async/zone.dart:1258:19)
dart-lang/http#13     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
dart-lang/http#14     _CustomZone.bindCallbackGuarded.<an<>
@natebosch natebosch transferred this issue from dart-lang/http Aug 27, 2021
@keertip keertip added the area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. label Aug 27, 2021
@lrhn lrhn added the library-io label Sep 1, 2021
@alaatm
Copy link

alaatm commented Sep 29, 2022

I am having similar crash reports:

SocketException: Reading from a closed socket

[
  "_RawSecureSocket.read (dart:io/secure_socket.dart:770)",
  "_Socket._onData (dart:io-patch/socket_patch.dart:2323)",
  "_RootZone.runUnaryGuarded (dart:async/zone.dart:1586)",
  "_BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339)",
  "_BufferingStreamSubscription._add (dart:async/stream_impl.dart:271)",
  "_SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774)",
  "_StreamController._add (dart:async/stream_controller.dart:648)",
  "_StreamController.add (dart:async/stream_controller.dart:596)",
  "_RawSecureSocket._sendReadEvent (dart:io/secure_socket.dart:1107)",
  "Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18)",
  "_Timer._runTimers (dart:isolate-patch/timer_impl.dart:398)",
  "_Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429)",
  "_RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192)"
]

I am unable to reproduce this as well, this crash is reported from some devices and the app state is always in the paused state when this happens. It happens after interacting with a chat page (using sockets with signalR client) then minimizing the app.

@JimmyHuang454
Copy link

Same thing happens to me too. This crash really confuse me, It seem this crash comes from .../io/secure_socket.dart, when a TLS socket closed, it raw socket keep sending data to TLS handler, then tigger this crash.

@a-siva a-siva added the P2 A bug or feature request we're likely to work on label Apr 28, 2023
@a-siva
Copy link
Contributor

a-siva commented Apr 28, 2023

Bumping priority as folks seem to run into this frequently

@a-siva
Copy link
Contributor

a-siva commented Apr 28, 2023

//cc @brianquinlan

@bagedevimo
Copy link

Happy to have a go at a fix for this, if it's on the less-tricky side of hard. My suggestion in #52210 was to change from a exception to returning nil, like the other conditional checks in that method (a few lines below).

If someone can provide a steer on writing a test and/or a fix, very happy to have a go.

@a-siva
Copy link
Contributor

a-siva commented May 1, 2023

I was looking at adding the suggested fix, I am in the process of trying to add a regression test that will work with our test harness.

@lrhn lrhn added area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. and removed area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Apr 21, 2024
@afl-dev
Copy link

afl-dev commented Apr 24, 2024

up

@ZaneCode6574
Copy link

I met this problem too. Have no idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. library-io P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

9 participants