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

StackOverflowError forwarding_stream.dart in _MultiControllerSink.add #707

Open
davidpanic opened this issue Dec 19, 2022 · 3 comments
Open
Labels
under evaluation We are determining the bast way to approach this issue waiting for response Waiting for follow up

Comments

@davidpanic
Copy link

davidpanic commented Dec 19, 2022

This exception was reported to our sentry instance by some of our end user devices. Seems to me like it is caused by some internal rxdart logic, hence why I'm reporting it here. I have not had luck reproducing this - it's hard to do when the stacktrace doesn't even tell you where to look. I'm hoping you can help me out here, I'd like to know what conditions are needed to get this to occur.

We are using rxdart 0.27.7.

Stacktrace (Click to show)
StackOverflowError: Stack Overflow
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_controller.dart", in _StreamController._add
  File "stream_controller.dart", in _StreamController.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_impl.dart", in _MultiStreamController.addSync
  File "forwarding_stream.dart", in _MultiControllerSink.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_controller.dart", in _StreamController._add
  File "stream_controller.dart", in _StreamController.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_impl.dart", in _MultiStreamController.addSync
  File "forwarding_stream.dart", in _MultiControllerSink.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_controller.dart", in _StreamController._add
  File "stream_controller.dart", in _StreamController.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_impl.dart", in _MultiStreamController.addSync
  File "forwarding_stream.dart", in _MultiControllerSink.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_controller.dart", in _StreamController._add
  File "stream_controller.dart", in _StreamController.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  ?, in ...
  ?, in ...
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_controller.dart", in _StreamController._add
  File "stream_controller.dart", in _StreamController.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_impl.dart", in _MultiStreamController.addSync
  File "forwarding_stream.dart", in _MultiControllerSink.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_controller.dart", in _StreamController._add
  File "stream_controller.dart", in _StreamController.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_impl.dart", in _MultiStreamController.addSync
  File "forwarding_stream.dart", in _MultiControllerSink.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_controller.dart", in _StreamController._add
  File "stream_controller.dart", in _StreamController.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _BufferingStreamSubscription._add
  File "stream_impl.dart", in _MultiStreamController.addSync
  File "forwarding_stream.dart", in _MultiControllerSink.add
  File "zone.dart", in _RootZone.runUnaryGuarded
  File "stream_impl.dart", in _BufferingStreamSubscription._sendData
  File "stream_impl.dart", in _DelayedData.perform
  File "stream_impl.dart", in _PendingEvents.handleNext
  File "stream_impl.dart", in _PendingEvents.schedule.<fn>
  File "schedule_microtask.dart", in _microtaskLoop
  File "schedule_microtask.dart", in _startMicrotaskLoop
@hoc081098 hoc081098 added the under evaluation We are determining the bast way to approach this issue label Jan 1, 2023
@hoc081098
Copy link
Collaborator

I think that stack trace does not help much :(

@hoc081098 hoc081098 added the waiting for response Waiting for follow up label Jan 1, 2023
@DeToxer
Copy link

DeToxer commented Jun 30, 2023

I am experiencing a similar thing. I get a Stack overflow exception but my stack grace if a bit different. I am also struggling to reproduce this. What i did find out when it finally happened was that if i removed the StreamSubscriptions listening to the stream within my ReplaySubject, the Stack overflow exception went away. When i commented it in again the exception started to appear again

#0      Zone.current (dart:async/zone.dart:596:3)
#1      _runGuarded (dart:async/stream_controller.dart:817:10)
#2      _StreamController._subscribe.<anonymous closure> (dart:async/stream_controller.dart:694:7)
#3      _BufferingStreamSubscription._guardCallback (dart:async/stream_impl.dart:415:13)
#4      _StreamController._subscribe (dart:async/stream_controller.dart:693:18)
#5      _MultiStream.listen (dart:async/stream_impl.dart:1033:23)
#6      _forwardMulti.<anonymous closure>.listenToUpstream (package:rxdart/src/utils/forwarding_stream.dart:36:29)
#7      _forwardMulti.<anonymous closure> (package:rxdart/src/utils/forwarding_stream.dart:52:7)
#8      _MultiStream.listen.<anonymous closure> (dart:async/stream_impl.dart:1031:16)
#9      _runGuarded (dart:async/stream_controller.dart:815:24)
#10     _StreamController._subscribe.<anonymous closure> (dart:async/stream_controller.dart:694:7)
#11     _BufferingStreamSubscript<…>
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Stack Overflow
#0      Zone.current (dart:async/zone.dart:596:3)
#1      _runGuarded (dart:async/stream_controller.dart:817:10)
#2      _StreamController._subscribe.<anonymous closure> (dart:async/stream_controller.dart:694:7)
#3      _BufferingStreamSubscription._guardCallback (dart:async/stream_impl.dart:415:13)
#4      _StreamController._subscribe (dart:async/stream_controller.dart:693:18)
#5      _MultiStream.listen (dart:async/stream_impl.dart:1033:23)
#6      _forwardMulti.<anonymous closure>.listenToUpstream (package:rxdart/src/utils/forwarding_stream.dart:36:29)
#7      _forwardMulti.<anonymous closure> (package:rxdart/src/utils/forwarding_stream.dart:52:7)
#8      _MultiStream.listen.<anonymous closure> (dart:async/stream_impl.dart:1031:16)
#9      _runGuarded (dart:async/stream_controller.dart:815:24)
#10     _StreamController._subscribe.<anonymous closure> (dart:async/stream_controller.dart:694:7)
#11     _BufferingStreamSubscript<…>
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: 'dart:async/stream_impl.dart': Failed assertion: line 336 pos 12: '<optimized out>': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:12)
#3      _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#4      _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#5      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#6      _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#7      _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: 'dart:async/stream_impl.dart': Failed assertion: line 336 pos 12: '!_inCallback': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:12)
#3      _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#4      _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#5      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#6      _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#7      _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

@hoc081098
Copy link
Collaborator

I think it's caused by adding to many events to the ReplaySubject, maybe a recursion :))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
under evaluation We are determining the bast way to approach this issue waiting for response Waiting for follow up
Projects
None yet
Development

No branches or pull requests

3 participants