Page 1 of 2

issue-#197 Problems with Coroutines

Posted: Fri Apr 19, 2019 2:17 pm
by Robert
For the issue see: https://redmine.blackboxframework.org/issues/197.

Initial discussion of this topic is in viewtopic.php?f=50&t=610&start=94 starting at date 10 April 2019.

Re: issue-#197 Problems with Coroutines

Posted: Sat Apr 20, 2019 9:24 am
by Robert
Latest crash today:

- Many trap windows called by Kernel.MarkReferencedCoroutines, then a final window called by Kernel.Cleanup, then 2 seconds later, exit to Windows.

No crashes yesterday!

Re: issue-#197 Problems with Coroutines

Posted: Sat Apr 27, 2019 8:29 am
by Josef Templ
Robert wrote:Latest crash today:

- Many trap windows called by Kernel.MarkReferencedCoroutines, then a final window called by Kernel.Cleanup, then 2 seconds later, exit to Windows.

No crashes yesterday!

Did it happen without unloading any modules that implement a coroutine?

- Josef

Re: issue-#197 Problems with Coroutines

Posted: Sat Apr 27, 2019 9:09 am
by Robert
Josef Templ wrote:Did it happen without unloading any modules that implement a coroutine?
I can't remember precisely.
But while my module is now pretty stable / finished, it almost certainly had had a few cycles of minor edit - compile - unload.

The setup is, in some ways, pretty simple. Coroutines are only used in one module, which only generates one Iterator within a Command. The Command may be called more than once by the user, and each time a fresh Iterator is created.

The Iterator variable is a global variable of the module; it is not a local variable on a procedure call stack.

No other modules have pointer chains to the Iterator.

Re: issue-#197 Problems with Coroutines

Posted: Sat Apr 27, 2019 1:07 pm
by Josef Templ
Can you send me the sources?
I am not interested in the particular processing being done but in the overall setup and
if there is anything special about it. Something that I may have not considered in my tests.
Low-level things like finalizers, trap handlers, huge or otherwise special data structures,
calls to WinApi functions, etc.
Without that I am not able to debug this issue.
My tests so far have not shown a single anomaly.

- Josef

Re: issue-#197 Problems with Coroutines

Posted: Wed Jun 26, 2019 9:48 am
by Robert
Maybe we should reject this issue until the problem appears again, if ever?

It has only affected me with one module, and then only during development. I am currently using the module with no problems.

The problem was always intermittent; I could never consistently provoke it.

If we do reject the main issue, should the minor points mentioned be fixed now?

Re: issue-#197 Problems with Coroutines

Posted: Mon Nov 18, 2019 10:43 pm
by Josef Templ
There seems to be a related posting on the community forum at https://community.blackboxframework.org ... f=48&t=238.
Fortunately, it also contains a bug fix proposal for the garbage collector issue.

- Josef

Re: issue-#197 Problems with Coroutines

Posted: Tue Nov 19, 2019 4:10 pm
by Robert
Interesting, and it sounds as if a fix has been found.
I am currently on a (pedal) cycling holiday in Spain, so can not look at the comments in any detail until I return (and even then will probably not understand the technical detail).
The problems I had were while developing a mapping program I use for planning these biking trips. The program now works reliably; the problems I had only occurred while developing it which involved multiple compile unload cycles.

Re: issue-#197 Problems with Coroutines

Posted: Tue Nov 19, 2019 4:42 pm
by Josef Templ
Robert, this is exactly where the bug occurs: unloading of a module that implements a coroutine object.
In that case the finalization procedure of the coroutine object is not called because the module the object belongs to
has been unloaded. In other words, even when the finalizer is inherted it is not executed when the module is unloaded.
Fortunately this can be fixed by moving the finalizer from module Coroutines to module Kernel.

have a safe trip

- Josef

Re: issue-#197 Problems with Coroutines

Posted: Tue Dec 03, 2019 7:46 pm
by cfbsoftware
Robert wrote:... which involved multiple compile unload cycles.
Was that pun intentional? ;)