mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -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.Remove;
|
||||||
import org.teavm.interop.Rename;
|
import org.teavm.interop.Rename;
|
||||||
import org.teavm.interop.Superclass;
|
import org.teavm.interop.Superclass;
|
||||||
import org.teavm.interop.Unmanaged;
|
|
||||||
import org.teavm.runtime.ExceptionHandling;
|
import org.teavm.runtime.ExceptionHandling;
|
||||||
|
|
||||||
@Superclass("java.lang.Object")
|
@Superclass("java.lang.Object")
|
||||||
|
@ -104,16 +103,11 @@ public class TThrowable extends RuntimeException {
|
||||||
@Override
|
@Override
|
||||||
public Throwable fillInStackTrace() {
|
public Throwable fillInStackTrace() {
|
||||||
if (PlatformDetector.isLowLevel()) {
|
if (PlatformDetector.isLowLevel()) {
|
||||||
stackTrace = fillInStackTraceLowLevel();
|
stackTrace = (TStackTraceElement[]) (Object) ExceptionHandling.fillStackTrace();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Unmanaged
|
|
||||||
private static TStackTraceElement[] fillInStackTraceLowLevel() {
|
|
||||||
return (TStackTraceElement[]) (Object) ExceptionHandling.fillStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Rename("getMessage")
|
@Rename("getMessage")
|
||||||
public String getMessage0() {
|
public String getMessage0() {
|
||||||
return message;
|
return message;
|
||||||
|
|
|
@ -67,6 +67,8 @@ import org.teavm.runtime.ExceptionHandling;
|
||||||
import org.teavm.runtime.ShadowStack;
|
import org.teavm.runtime.ShadowStack;
|
||||||
|
|
||||||
public class ExceptionHandlingShadowStackContributor {
|
public class ExceptionHandlingShadowStackContributor {
|
||||||
|
private static final MethodReference FILL_STACK_TRACE = new MethodReference(ExceptionHandling.class,
|
||||||
|
"fillStackTrace", StackTraceElement[].class);
|
||||||
private Characteristics characteristics;
|
private Characteristics characteristics;
|
||||||
private List<CallSiteDescriptor> callSites;
|
private List<CallSiteDescriptor> callSites;
|
||||||
private BasicBlock defaultExceptionHandler;
|
private BasicBlock defaultExceptionHandler;
|
||||||
|
@ -281,7 +283,11 @@ public class ExceptionHandlingShadowStackContributor {
|
||||||
|| insn instanceof NullCheckInstruction || insn instanceof BoundCheckInstruction) {
|
|| insn instanceof NullCheckInstruction || insn instanceof BoundCheckInstruction) {
|
||||||
return true;
|
return true;
|
||||||
} else if (insn instanceof InvokeInstruction) {
|
} 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user