Added safety check to lazyusf for non-working sets; Now they'll fail with a useful error message instead of locking up in an infinite loop

CQTexperiment
Chris Moeller 2014-04-05 20:22:19 -07:00
parent 47d3a8dffe
commit 0a4046f2bf
1 changed files with 13 additions and 0 deletions

View File

@ -722,10 +722,23 @@ void ExecuteInterpreterOpCode (usf_state_t * state) {
} }
void StartInterpreterCPU (usf_state_t * state) { void StartInterpreterCPU (usf_state_t * state) {
const int safety_count_max = 20000000;
int safety_count = safety_count_max;
size_t last_sample_buffer_count = state->sample_buffer_count;
state->NextInstruction = NORMAL; state->NextInstruction = NORMAL;
while(state->cpu_running) { while(state->cpu_running) {
ExecuteInterpreterOpCode(state); ExecuteInterpreterOpCode(state);
if (!--safety_count) {
if (last_sample_buffer_count == state->sample_buffer_count) {
DisplayError( state, "Emulator core is not generating any samples after 400 million instructions" );
break;
} else {
safety_count = safety_count_max;
last_sample_buffer_count = state->sample_buffer_count;
}
}
} }
state->cpu_stopped = 1; state->cpu_stopped = 1;