Skip to content

Commit

Permalink
throw timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
tjchern committed Sep 5, 2018
1 parent da5f84b commit 719b19e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/tron/common/runtime/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.tron.common.runtime.vm.program.InternalTransaction.ExecutorType;
import org.tron.common.runtime.vm.program.Program;
import org.tron.common.runtime.vm.program.Program.JVMStackOverFlowException;
import org.tron.common.runtime.vm.program.Program.OutOfResourceException;
import org.tron.common.runtime.vm.program.ProgramPrecompile;
import org.tron.common.runtime.vm.program.ProgramResult;
import org.tron.common.runtime.vm.program.invoke.ProgramInvoke;
Expand Down Expand Up @@ -526,6 +527,10 @@ public void go() {
result.setException(e);
runtimeError = result.getException().getMessage();
logger.error("runtime error is :{}", result.getException().getMessage());
} catch (OutOfResourceException e) {
result.setException(e);
runtimeError = result.getException().getMessage();
logger.error("runtime error is :{}", result.getException().getMessage());
} catch (Throwable e) {
program.spendAllEnergy();
if (Objects.isNull(result.getException())) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/tron/common/runtime/vm/VM.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.tron.common.runtime.vm.program.Program;
import org.tron.common.runtime.vm.program.Program.JVMStackOverFlowException;
import org.tron.common.runtime.vm.program.Program.OutOfEnergyException;
import org.tron.common.runtime.vm.program.Program.OutOfResourceException;
import org.tron.common.runtime.vm.program.Stack;

@Slf4j(topic = "VM")
Expand Down Expand Up @@ -1333,6 +1334,9 @@ public void play(Program program) {

} catch (JVMStackOverFlowException e) {
throw new JVMStackOverFlowException();
} catch (OutOfResourceException e) {
program.setRuntimeFailure(e);
throw e;
} catch (RuntimeException e) {
if (StringUtils.isEmpty(e.getMessage())) {
program.setRuntimeFailure(new RuntimeException("Unknown Exception"));
Expand Down

0 comments on commit 719b19e

Please sign in to comment.