mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
C/Wasm: fix heap corruption when GC hits on initializing stack trace of exception
This commit is contained in:
parent
4f9567561c
commit
6ed00f1af2
|
@ -22,7 +22,6 @@ import org.teavm.classlib.java.util.TArrays;
|
|||
import org.teavm.interop.Remove;
|
||||
import org.teavm.interop.Rename;
|
||||
import org.teavm.interop.Superclass;
|
||||
import org.teavm.interop.Unmanaged;
|
||||
import org.teavm.runtime.ExceptionHandling;
|
||||
|
||||
@Superclass("java.lang.Object")
|
||||
|
@ -104,16 +103,11 @@ public class TThrowable extends RuntimeException {
|
|||
@Override
|
||||
public Throwable fillInStackTrace() {
|
||||
if (PlatformDetector.isLowLevel()) {
|
||||
stackTrace = fillInStackTraceLowLevel();
|
||||
stackTrace = (TStackTraceElement[]) (Object) ExceptionHandling.fillStackTrace();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Unmanaged
|
||||
private static TStackTraceElement[] fillInStackTraceLowLevel() {
|
||||
return (TStackTraceElement[]) (Object) ExceptionHandling.fillStackTrace();
|
||||
}
|
||||
|
||||
@Rename("getMessage")
|
||||
public String getMessage0() {
|
||||
return message;
|
||||
|
|
|
@ -67,6 +67,8 @@ import org.teavm.runtime.ExceptionHandling;
|
|||
import org.teavm.runtime.ShadowStack;
|
||||
|
||||
public class ExceptionHandlingShadowStackContributor {
|
||||
private static final MethodReference FILL_STACK_TRACE = new MethodReference(ExceptionHandling.class,
|
||||
"fillStackTrace", StackTraceElement[].class);
|
||||
private Characteristics characteristics;
|
||||
private List<CallSiteDescriptor> callSites;
|
||||
private BasicBlock defaultExceptionHandler;
|
||||
|
@ -281,7 +283,11 @@ public class ExceptionHandlingShadowStackContributor {
|
|||
|| insn instanceof NullCheckInstruction || insn instanceof BoundCheckInstruction) {
|
||||
return true;
|
||||
} else if (insn instanceof InvokeInstruction) {
|
||||
return isManagedMethodCall(characteristics, ((InvokeInstruction) insn).getMethod());
|
||||
MethodReference method = ((InvokeInstruction) insn).getMethod();
|
||||
if (method.equals(FILL_STACK_TRACE)) {
|
||||
return true;
|
||||
}
|
||||
return isManagedMethodCall(characteristics, method);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user