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

Oops; flutter has exited unexpectedly: "Stack Overflow". #155433

Open
JangJuMyeong opened this issue Sep 20, 2024 · 14 comments · May be fixed by flutter/packages#8390
Open

Oops; flutter has exited unexpectedly: "Stack Overflow". #155433

JangJuMyeong opened this issue Sep 20, 2024 · 14 comments · May be fixed by flutter/packages#8390
Assignees
Labels
c: crash Stack traces logged to the console P1 High-priority issues at the top of the work list package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team

Comments

@JangJuMyeong
Copy link

JangJuMyeong commented Sep 20, 2024

Steps to reproduce

flutter run --machine --start-paused -d 00008130-000C3D0A2EE3803A --devtools-server-address http://127.0.0.1:9100/ --target /Users/likelion/Desktop/chika_client_project/lib/main.dart --flavor dev --enable-impeller

Expected results

Flutter builds successfully, but soon the following issue occurs repeatedly, and it seems that the frequency increases with each build.

Actual results

exception

StackOverflowError: Stack Overflow

#0      _StringBase._createOneByteString (dart:core-patch/string_patch.dart:249:3)
#1      _StringBase.createFromCharCodes (dart:core-patch/string_patch.dart:151:16)
#2      new String.fromCharCodes (dart:core-patch/string_patch.dart:22:24)
#3      _Utf8Decoder.decodeGeneral (dart:convert/utf.dart:668:31)
#4      _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1857:14)
#5      _readFQDN (package:multicast_dns/src/packet.dart:165:24)
#6      _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7      _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#8      _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#9      _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#10     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#11     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#12     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#13     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#14     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#15     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#16     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#17     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#18     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#19     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#20     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#21     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#22     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#23     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#24     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#25     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#26     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#27     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#28     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#29     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#30     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#31     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#32     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#33     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#34     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#35     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#36     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#37     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#38     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#39     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#40     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#41     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#42     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#43     _readFQDN (package:multicast_dns/src/packet.dart:147:38)
...
...
#7203   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7204   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7205   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7206   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7207   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7208   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7209   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7210   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7211   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7212   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7213   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7214   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7215   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7216   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7217   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7218   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7219   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7220   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7221   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7222   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7223   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7224   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7225   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7226   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7227   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7228   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7229   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7230   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7231   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7232   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7233   _readFQDN (package:multicast_dns/src/packet.dart:147:38)
#7234   decodeMDnsResponse.readResourceRecord (package:multicast_dns/src/packet.dart:244:36)
#7235   decodeMDnsResponse (package:multicast_dns/src/packet.dart:372:38)
#7236   MDnsClient._handleIncoming (package:multicast_dns/multicast_dns.dart:238:46)
#7237   MDnsClient.start.<anonymous closure> (package:multicast_dns/multicast_dns.dart:155:47)
#7238   _rootRunUnary (dart:async/zone.dart:1415:13)
#7239   _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217:7)
#7240   _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:365:11)
#7241   _StreamController.add (dart:async/stream_controller.dart:606:5)
#7242   new _RawDatagramSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:2543:33)
#7243   _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1385:14)
#7244   _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#7245   _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)

Code sample

flutter doctor

[✓] Flutter (Channel stable, 3.24.3, on macOS 14.5 23F79 darwin-arm64, locale ko-KR)
    • Flutter version 3.24.3 on channel stable at /Users/likelion/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (8 days ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/likelion/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • ANDROID_HOME = /Users/likelion/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.89.1)
    • VS Code at /Users/likelion/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.96.0

[✓] Connected device (7 available)
    • SM F926N (mobile)               • R3CR70RZ99M               • android-arm64  • Android 14 (API 34)
    • 안우철의 iPhone (4449) (mobile)     • 00008130-0018051E3E02001C • ios            • iOS 17.6.1 21G93
    • Leo (mobile)                    • 00008130-001134960C38001C • ios            • iOS 17.6.1 21G93
    • 장주명의 iPhone (3) (mobile)        • 00008130-000C3D0A2EE3803A • ios            • iOS 17.6.1 21G93
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 128.0.6613.138
    ! Error: Browsing on the local area network for 장주명의 iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

[✓] Flutter (Channel stable, 3.24.3, on macOS 14.5 23F79 darwin-arm64, locale ko-KR)
    • Flutter version 3.24.3 on channel stable at /Users/likelion/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (8 days ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/likelion/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • ANDROID_HOME = /Users/likelion/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.89.1)
    • VS Code at /Users/likelion/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.96.0

[✓] Connected device (7 available)
    • SM F926N (mobile)               • R3CR70RZ99M               • android-arm64  • Android 14 (API 34)
    • 안우철의 iPhone (4449) (mobile)     • 00008130-0018051E3E02001C • ios            • iOS 17.6.1 21G93
    • Leo (mobile)                    • 00008130-001134960C38001C • ios            • iOS 17.6.1 21G93
    • 장주명의 iPhone (3) (mobile)        • 00008130-000C3D0A2EE3803A • ios            • iOS 17.6.1 21G93
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 128.0.6613.138
    ! Error: Browsing on the local area network for 장주명의 iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
@danagbemava-nc danagbemava-nc added the in triage Presently being triaged by the triage team label Sep 20, 2024
@danagbemava-nc
Copy link
Member

Hi @JangJuMyeong, can you provide the full output of flutter run -v that captures the tool crash? The output may be huge so kindly put it into a .txt file and attach it here.

Thank you

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 20, 2024
@JangJuMyeong
Copy link
Author

@danagbemava-nc The log generated using the flutter run -v command provides detailed information for tracing issues in the Flutter app. If any additional information is needed to resolve the issue, please let me know.
chika_error_log.txt

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 23, 2024
@danagbemava-nc
Copy link
Member

Hi @JangJuMyeong, thanks for the logs. One more thing, do you only get this issue when you're running on an iOS device?

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 23, 2024
@JangJuMyeong
Copy link
Author

@danagbemava-nc hi I've been testing it for a few days, and it seems to only occur on iOS. Thank you.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 25, 2024
@danagbemava-nc
Copy link
Member

Thanks for the update.

Labeling based on the crash logs shared above

@danagbemava-nc danagbemava-nc added c: crash Stack traces logged to the console platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. team-tool Owned by Flutter Tool team and removed in triage Presently being triaged by the triage team labels Sep 26, 2024
@andrewkolos
Copy link
Contributor

In the flutter doctor output, I see

    ! Error: Browsing on the local area network for 장주명의 iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

장주명의 is the device being used here, right? This error message could be a hint as to what is going on here. I'm curious whether resolving this would prevent this crash. Could you try resolving this and then seeing if this crash still occurs?

@andrewkolos andrewkolos added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 27, 2024
@JangJuMyeong
Copy link
Author

@andrewkolos Hello, I apologize for the delay in response due to the long holiday period. The mentioned device is not in use, and therefore, I don't think it's causing the issue. The actual device causing the problem is another iPhone named "장주명의 iPhone(3)."

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 1, 2024
@bkonyi
Copy link
Contributor

bkonyi commented Oct 22, 2024

@jmagman would you happen to know who owns package:multicast_dns? This looks like we're stuck recursing while parsing.

@bkonyi bkonyi added P2 Important issues not at the top of the work list triaged-tool Triaged by Flutter Tool team labels Oct 22, 2024
@jmagman
Copy link
Member

jmagman commented Oct 22, 2024

would you happen to know who owns package:multicast_dns?

Technically me but I haven't touched it so I should probably pass it onto a different owner.
https://github.com/flutter/packages/blob/5e03bb1da411c99d80727f46e1821c4fdc6ea12c/CODEOWNERS#L29

Historically it's been maintained by community contributors and the tools team.

@sunsetroads
Copy link

Is there any progress or temporary solution for this issue? The iOS development experience is very poor, with errors occurring as soon as it starts, making debugging impossible.

@sunsetroads
Copy link

The issue can be confirmed as unrelated to the business logic, as it also easily occurs in newly created projects on iOS devices.

@jmagman
Copy link
Member

jmagman commented Dec 20, 2024

This has quite a few reports duplicated to it.
@bkonyi would you consider bumping this to a P1 and having someone look at it? This will probably be tricky without being able to reproduce. Perhaps there's some debugging that can be added to make this actionable?

@bkonyi bkonyi added P1 High-priority issues at the top of the work list and removed P2 Important issues not at the top of the work list labels Dec 20, 2024
@bkonyi
Copy link
Contributor

bkonyi commented Dec 20, 2024

This has quite a few reports duplicated to it. @bkonyi would you consider bumping this to a P1

Done. I won't be able to take a look until the new year, but maybe @andrewkolos will have some time?

@andrewkolos andrewkolos self-assigned this Dec 20, 2024
@andrewkolos andrewkolos added the package flutter/packages repository. See also p: labels. label Dec 26, 2024
@andrewkolos
Copy link
Contributor

andrewkolos commented Jan 6, 2025

TL;DR: It's possible via the compression scheme defined in RFC1035 section 4.1.41 that _readFQDN could recurse arbitrarily deeply. Re-implementing this code to be iterative could fix this. However, I am very surprised that this would ever need to recurse this much in practice to begin with, so I am not 100% confident in this fix without having a repro (i.e. a real-world packet that causes _readFQDN to produce a stack overflow).


I was not familiar with this code (or RFC6762 or RFC1035) at all, so I did some reading. Here's the relevant background knowledge I found:

_readFQDN is called downstream of readResourceRecord (as seen in the stack trace). Let's start there. readResourceRecord parses a resource record stored in the binary formatted as specified section 4.1.3 in RFC10351. _readFQDN in particular parses the NAME section of that resource record. The recursive bit here is from the compression scheme detailed in section 4.1.4 in that same document. To simplify a bit, the NAME section within a record—instead of containing a full hostname like foo.isa.arpa—can simply point to the NAME section within another record that contains the same hostname. Alternatively, it could contain foo and then a pointer to another NAME section that contains isa.arpa; or it could contain foo and a pointer to another section that contains both 1) isa and 2) a pointer to a third section that contains arpa.

Moving on, it's still surprising this could ever recurse to a depth great enough to cause a stack overflow2. Since I don't know what message caused this, I cannot know the cause for sure, but it's possible that simply rewriting _readFQDN to be iterative rather than recursive would be a solution here, so that's what I think I will do.

Footnotes

  1. https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.3 2

  2. Keep in mind that the top of the stack trace ends with code getting past the recursive part of this function (we reach L165), so this is not an infinite recursion via circular pointers in the NAME sections. Is it possible that a domain could contain hundreds or thousands of labels (e.g. foo.bar.baz...<thousands of parts here>...alice.bob.com)?? I wonder if I am missing something here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: crash Stack traces logged to the console P1 High-priority issues at the top of the work list package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels. triaged-tool Triaged by Flutter Tool team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants