You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upon reading the code it seems if there are more than 7400+ messages in a single packet (back of napkin calculation: based on the # of stacks, around 14864/2 ~ 7432 messages) then it would cause the 2 functions calling each other until stack overflow.
Seems there could be 2 scenarios
If Mongo decides to send a packet with many messages.
It's also possible that Dart batches all the messages into a single packet.
I'm not able to reproduce it locally, but I do see it happen quite often in production so I'm not able to nail down which of the above scenarios caused the issue.
Is there a reason why we choose to read the packets recursively?
Should we handle reading of the packets in iterative manner rather than recursive?
The text was updated successfully, but these errors were encountered:
timk10
changed the title
Stack overflow when reading some data
Stack overflow when reading data
May 4, 2018
We run into stack overflow error due to handleBody/handleHeader calling itself repeatedly (see stacktrace)
Socket error Stack Overflow #0 List.setRange (dart:core-patch/array.dart:31) #1 PacketConverter._readPacketIntoBuffer (package:plato_mongo_dart/src/network/packet_converter.dart:72:12) #2 PacketConverter.handleBody (package:plato_mongo_dart/src/network/packet_converter.dart:63:19) #3 PacketConverter.handleHeader (package:plato_mongo_dart/src/network/packet_converter.dart:37:7) #4 PacketConverter.handleBody (package:plato_mongo_dart/src/network/packet_converter.dart:48:7) #5 PacketConverter.handleHeader (package:plato_mongo_dart/src/network/packet_converter.dart:37:7) #6 PacketConverter.handleBody (package:plato_mongo_dart/src/network/packet_converter.dart:48:7) #7 PacketConverter.handleHeader (package:plato_mongo_dart/src/network/packet_converter.dart:37:7) #8 PacketConverter.handleBody (package:plato_mongo_dart/src/network/packet_converter.dart:48:7) #9 PacketConverter.handleHeader (package:plato_mongo_dart/src/network/packet_converter.dart:37:7) #10 PacketConverter.handleBody (package:plato_mongo_dart/src/network/packet_converter.dart:48:7) #11 PacketConverter.handleHeader (package:plato_mongo_dart/src/network/packet_converter.dart:37:7) #12 PacketConverter.handleBody (package:plato_mongo_dart/src/network/packet_converter.dart:48:7) #13 PacketConverter.handleHeader (package:plato_mongo_dart/src/network/packet_converter.dart:37:7) ... ... #14864 _StreamController.add (dart:async/stream_controller.dart:603) #14865 _Socket._onData (dart:io-patch/socket_patch.dart:1617) #14866 StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart) #14867 StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart) #14868 StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:107:14) #14869 _rootRunUnary (dart:async/zone.dart) #14870 _CustomZone.runUnaryGuarded (dart:async/zone.dart) #14871 _StreamController.add (dart:async/stream_controller.dart:603) #14872 new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1203) #14873 _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart) #14874 _startMicrotaskLoop (dart:async/schedule_microtask.dart) #14875 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart)
Upon reading the code it seems if there are more than 7400+ messages in a single packet (back of napkin calculation: based on the # of stacks, around 14864/2 ~ 7432 messages) then it would cause the 2 functions calling each other until stack overflow.
Seems there could be 2 scenarios
I'm not able to reproduce it locally, but I do see it happen quite often in production so I'm not able to nail down which of the above scenarios caused the issue.
Is there a reason why we choose to read the packets recursively?
Should we handle reading of the packets in iterative manner rather than recursive?
The text was updated successfully, but these errors were encountered: