Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2234e11
Add StackOverflowError and stack overflow test
shai-almog Jan 25, 2026
8efb1ca
Ensure StackOverflowError is emitted in native builds
shai-almog Jan 25, 2026
5af4976
Fix stack overflow test string concatenation
shai-almog Jan 25, 2026
04a600d
Avoid native stack overflow in stack overflow test
shai-almog Jan 25, 2026
fdb611b
Simplify stack overflow integration test
shai-almog Jan 25, 2026
824af45
Throw StackOverflowError before native stack exhaustion
shai-almog Jan 25, 2026
08a1325
Lower stack overflow depth limit
shai-almog Jan 25, 2026
c74d7cc
Improve stack overflow test diagnostics
shai-almog Jan 26, 2026
3aed7d8
Add source-level asserts to stack overflow test
shai-almog Jan 26, 2026
281300c
Expand stack overflow test diagnostics
shai-almog Jan 26, 2026
6e5c6c4
Lower stack overflow depth limit further
shai-almog Jan 26, 2026
58c4a5f
Revert overflow limit and add smoke run diagnostics
shai-almog Jan 26, 2026
e95aa0e
Fix smoke output string building
shai-almog Jan 26, 2026
b86650f
Expand stack overflow smoke diagnostics
shai-almog Jan 26, 2026
908bdfe
Add smoke-phase markers to stack overflow test
shai-almog Jan 26, 2026
0b766c7
Add probe run before smoke in stack overflow test
shai-almog Jan 27, 2026
650697e
Add probe markers for stack overflow test
shai-almog Jan 28, 2026
d12a5e5
Assert probe output from native constant report
shai-almog Jan 28, 2026
9d5e74a
Avoid string args in stack overflow test modes
shai-almog Jan 28, 2026
108b05c
Refine smoke assertions for stack overflow test
shai-almog Jan 28, 2026
f7793fe
Simplify smoke path to native markers
shai-almog Jan 29, 2026
4029950
Clarify smoke probe marker failure
shai-almog Jan 29, 2026
62c7ccf
Print smoke probe markers in a single native call
shai-almog Jan 29, 2026
405a78a
Differentiate smoke probe markers
shai-almog Jan 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vm/ByteCodeTranslator/src/cn1_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ struct TryBlock {
};

#define CN1_MAX_STACK_CALL_DEPTH 1024
#define CN1_STACK_OVERFLOW_CALL_DEPTH_LIMIT CN1_MAX_STACK_CALL_DEPTH
#define CN1_MAX_OBJECT_STACK_DEPTH 16536

#define PER_THREAD_ALLOCATION_COUNT 4096
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ public static void markDependencies(List<ByteCodeClass> lst, String[] nativeSour
bc.markDependent(lst);
continue;
}
if(bc.clsName.equals("java_lang_StackOverflowError")) {
bc.markDependent(lst);
continue;
}
if(bc.clsName.equals("java_text_DateFormat")) {
bc.markDependent(lst);
continue;
Expand Down
6 changes: 5 additions & 1 deletion vm/ByteCodeTranslator/src/nativeMethods.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "java_lang_NullPointerException.h"
#include "java_lang_Class.h"
#include "java_lang_System.h"
#include "java_lang_StackOverflowError.h"

#if defined(__APPLE__) && defined(__OBJC__)
#import <Foundation/Foundation.h>
Expand Down Expand Up @@ -1550,9 +1551,12 @@ void initMethodStack(CODENAME_ONE_THREAD_STATE, JAVA_OBJECT __cn1ThisObject, int
THROW_NULL_POINTER_EXCEPTION();
}
#endif
if (threadStateData->callStackOffset >= CN1_STACK_OVERFLOW_CALL_DEPTH_LIMIT - 1) {
throwException(threadStateData, __NEW_INSTANCE_java_lang_StackOverflowError(threadStateData));
return;
}
memset(&threadStateData->threadObjectStack[threadStateData->threadObjectStackOffset], 0, sizeof(struct elementStruct) * (localsStackSize + stackSize));
threadStateData->threadObjectStackOffset += localsStackSize + stackSize;
CODENAME_ONE_ASSERT(threadStateData->callStackOffset < CN1_MAX_STACK_CALL_DEPTH - 1);
threadStateData->callStackClass[threadStateData->callStackOffset] = classNameId;
threadStateData->callStackMethod[threadStateData->callStackOffset] = methodNameId;
threadStateData->callStackOffset++;
Expand Down
44 changes: 44 additions & 0 deletions vm/JavaAPI/src/java/lang/StackOverflowError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2012, Codename One and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Codename One designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Codename One through http://www.codenameone.com/ if you
* need additional information or have any questions.
*/

package java.lang;
/**
* Thrown when a stack overflow occurs because an application recurses too deeply.
* Since: JDK1.0, CLDC 1.0
*/
public class StackOverflowError extends java.lang.VirtualMachineError{
/**
* Constructs a StackOverflowError with no detail message.
*/
public StackOverflowError(){
}

/**
* Constructs a StackOverflowError with the specified detail message.
* s - the detail message.
*/
public StackOverflowError(java.lang.String s){
super(s);
}

}
Loading
Loading