Commit e83b0393 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Add limit to the number of frames a thread may have.

parent db4165db
......@@ -128,6 +128,7 @@ More detailed changes:
* Correct cases where `NullPointerException` is thrown when a `Display`
was initialized but was not yet claimed by any program.
* SpringCoat
* Add limit to stack frame depth.
* Add support for system properties being based to virtual machine
instances.
* Profiler thread lists are easier to read because the main suite is
......
......@@ -26,6 +26,10 @@ import net.multiphasicapps.profiler.ProfiledThread;
*/
public final class SpringThread
{
/** Maximum depth of the stack. */
public static final int MAX_STACK_DEPTH =
64;
/** The thread ID. */
protected final int id;
......@@ -105,17 +109,21 @@ public final class SpringThread
// Setup blank frame
SpringThread.Frame rv = new SpringThread.Frame();
// Profile for this frame
this.profiler.enterFrame("<blank>", "<blank>", "()V",
System.nanoTime());
// {@squirreljme.error BK4c Stack overflow.}
List<SpringThread.Frame> frames = this._frames;
if (frames.size() >= MAX_STACK_DEPTH)
throw new SpringVirtualMachineException("BK4c");
// Lock on frames as a new one is added
List<SpringThread.Frame> frames = this._frames;
synchronized (frames)
{
frames.add(rv);
}
// Profile for this frame
this.profiler.enterFrame("<blank>", "<blank>", "()V",
System.nanoTime());
// Had one frame (started)
this._hadoneframe = true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment