<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Our code and some libraries do enter some nested event loops at a
few places when it makes sense, but we didn't do anything to
explicitly provoke this, this occurred naturally in our
application. So it would be nice if JavaFX could somehow guard
against this, especially since crashing the JVM is probably the
worst thing that can happen.<br>
<br>
I looked at the documentation, but it seems like the public API at
Platform::enterNestedEventLoop does not mention this.<br>
From my understanding, the method
Platform::canStartNestedEventLoop is potentially the right method
to indicate to the caller that the limit is close by returning
false.<br>
And even if something like an exception is thrown when a nested
event loop is started while it is close to the limit, that would
still be much better than a direct crash.<br>
<br>
Best<br>
Christopher Schnick<br>
</p>
<div class="moz-cite-prefix">On 10/03/2025 18:51, Andy Goryachev
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:BYAPR10MB30138F9BCE8C7CD533D86221E5D62@BYAPR10MB3013.namprd10.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator"
content="Microsoft Word 15 (filtered medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Aptos;
panose-1:2 11 0 4 2 2 2 2 2 4;}@font-face
{font-family:"Iosevka Fixed SS16";
panose-1:2 0 5 9 3 0 0 0 0 4;}@font-face
{font-family:"Times New Roman \(Body CS\)";
panose-1:2 11 6 4 2 2 2 2 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:10.0pt;
font-family:"Aptos",sans-serif;}span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Iosevka Fixed SS16";
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}div.WordSection1
{page:WordSection1;}</style>
<div class="WordSection1">
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">This
looks to me like it might be hitting the (native) thread
stack size limit.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">c.s.glass.ui.Application::enterNestedEventLoop()
even warns about it:<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p style="margin:0in;background:white"><span
style="font-family:"Iosevka Fixed SS16";color:#FF2600"> *
An application may enter several nested loops recursively.
There's no</span><span
style="font-family:"Iosevka Fixed SS16";color:black"><o:p></o:p></span></p>
<p style="margin:0in;background:white"><span
style="font-family:"Iosevka Fixed SS16";color:#FF2600"> *
limit of recursion other than that imposed by the native
stack size.</span><span
style="font-family:"Iosevka Fixed SS16";color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">-andy<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div
style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span
style="font-size:12.0pt;color:black">From:
</span></b><span
style="font-size:12.0pt;color:black">openjfx-dev
<a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev-retn@openjdk.org"><openjfx-dev-retn@openjdk.org></a> on behalf of
Martin Fox <a class="moz-txt-link-rfc2396E" href="mailto:martinfox656@gmail.com"><martinfox656@gmail.com></a><br>
<b>Date: </b>Monday, March 10, 2025 at 10:10<br>
<b>To: </b>Christopher Schnick
<a class="moz-txt-link-rfc2396E" href="mailto:crschnick@xpipe.io"><crschnick@xpipe.io></a><br>
<b>Cc: </b>OpenJFX <a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev@openjdk.org"><openjfx-dev@openjdk.org></a><br>
<b>Subject: </b>Re: JVM crashes on macOS when
entering too many nested event loops<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span
style="font-size:11.0pt">Hi Christopher,<br>
<br>
I was able to reproduce this crash. I wrote a small
routine that recursively calls itself in a runLater
block and then enters a nested event loop. The
program crashes when creating loop 254. I’m not sure
where that limit comes from so it’s possible that
consuming some other system resource could lower it.
I couldn’t see any good way to determine how many
loops are active by looking at the crash report
since it doesn’t show the entire call stack.
<br>
I did a quick trial on Linux and was able to create
a lot more loops (over 600) but then started seeing
erratic behavior and errors coming from the Java VM.
The behavior was variable unlike on the Mac which
always crashes when creating loop 254.<br>
<br>
Martin<br>
<br>
> On Mar 7, 2025, at 6:24</span><span
style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><span
style="font-size:11.0pt">AM, Christopher Schnick
<a class="moz-txt-link-rfc2396E" href="mailto:crschnick@xpipe.io"><crschnick@xpipe.io></a> wrote:<br>
> <br>
> Hello,<br>
> <br>
> I have attached a JVM fatal error log that
seemingly was caused by our JavaFX application
entering too many nested event loops, which macOS
apparently doesn't like.<br>
> <br>
> As far as I know, there is no upper limit
defined on how often an event loop can be nested, so
I think this is a bug that can occur in rare
situations.<br>
> <br>
> Best<br>
> Christopher Schnick<hs_err_pid.txt><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</body>
</html>