Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on February 21, 2022, 12:41:41 PM

Title: Math Stack Overflow
Post by: RBPLC on February 21, 2022, 12:41:41 PM
Well, this is the first time I've generated a stack overflow and watchdog timeout. It's clear where the issue is at (FOR Loop), I'm just trying to diagnose what the actual problem is. If I was trying to write to a memory location in the FOR Loop (say Array500) but I only had assigned memory (Array0-499), would this cause the stack overflow and watchdog timeout? 
Title: Re: Math Stack Overflow
Post by: BobO on February 21, 2022, 01:12:26 PM
Well, this is the first time I've generated a stack overflow and watchdog timeout. It's clear where the issue is at (FOR Loop), I'm just trying to diagnose what the actual problem is. If I was trying to write to a memory location in the FOR Loop (say Array500) but I only had assigned memory (Array0-499), would this cause the stack overflow and watchdog timeout?

Generally a math stack overflow is a bug in an instruction. A watchdog is easy to create. Anything over 200ms in a non-yielding task or program ($Main, for instance) is a watchdog. I'm wondering if the watchdog is real, but the math stack issue is secondary.

Title: Re: Math Stack Overflow
Post by: RBPLC on February 22, 2022, 08:18:26 AM
It looks like the Watchdog was primary and math stack overflow was secondary. I was running a loop in a subroutine to sort fault codes. This worked as intended until I had many faults at one time while debugging. I removed the loop and replaced it with a string copy range (which is what I should have done to start with) and it seems to have resolved the issue. 
Title: Re: Math Stack Overflow
Post by: BobO on February 22, 2022, 09:58:18 AM
It looks like the Watchdog was primary and math stack overflow was secondary. I was running a loop in a subroutine to sort fault codes. This worked as intended until I had many faults at one time while debugging. I removed the loop and replaced it with a string copy range (which is what I should have done to start with) and it seems to have resolved the issue.

Ah...loops in subroutines have some caveats. Several technical issues I won't bore you with, but that doesn't surprise me.