-
Bug
-
Resolution: Unresolved
-
P3
-
jfx23
-
None
-
Mac Studio running OS 15.3.1 (24D70)
-
arm
-
os_x
When creating a lot of nested event loops we can hit an OS limit that causes the app to crash. The problem occurs when a performSelectorOnMainThread block is executed by CFRunLoopRun which causes another performSelectorOnMainThread block to be executed by CFRunLoopRun and so on until we're about 250 levels deep. At that point the OS crashes the app with a specific message in the crash log:
Application Specific Information:
Too many nested CFRunLoopRuns
At the JavaFX level this occurs when runLater block A schedules runLater block B and then enters a nested event loop, block B schedules runLater block C and then enters a nested event loop, and so on.
The OS crash report isn't all that useful. It would be better if JavaFX threw a Java exception so the developer see a Java stack trace.
To reproduce, run the attached test case MaxNestedLoops.java.
The "No crash" button will spin up 200 event loops and then unwind them and print "Success!".
The "Crash" button will attempt to spin up 254 event loops and the OS will crash the app.
Edit 2025/03/27: the fix introduced a cross-platform limit of 200 nested event loops as a way to indicate the design issue in the application code.
Application Specific Information:
Too many nested CFRunLoopRuns
At the JavaFX level this occurs when runLater block A schedules runLater block B and then enters a nested event loop, block B schedules runLater block C and then enters a nested event loop, and so on.
The OS crash report isn't all that useful. It would be better if JavaFX threw a Java exception so the developer see a Java stack trace.
To reproduce, run the attached test case MaxNestedLoops.java.
The "No crash" button will spin up 200 event loops and then unwind them and print "Success!".
The "Crash" button will attempt to spin up 254 event loops and the OS will crash the app.
Edit 2025/03/27: the fix introduced a cross-platform limit of 200 nested event loops as a way to indicate the design issue in the application code.
- csr for
-
JDK-8353287 Crash when creating too many nested event loops
-
- Draft
-
- links to
-
Review(master) openjdk/jfx/1741