issue-#197 Problems with Coroutines

User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

issue-#197 Problems with Coroutines

Post 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.
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#197 Problems with Coroutines

Post 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!
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#197 Problems with Coroutines

Post 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
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#197 Problems with Coroutines

Post 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.
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#197 Problems with Coroutines

Post 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
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#197 Problems with Coroutines

Post 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?
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#197 Problems with Coroutines

Post 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
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#197 Problems with Coroutines

Post 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.
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#197 Problems with Coroutines

Post 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
cfbsoftware
Posts: 204
Joined: Wed Sep 18, 2013 10:06 pm
Contact:

Re: issue-#197 Problems with Coroutines

Post by cfbsoftware »

Robert wrote:... which involved multiple compile unload cycles.
Was that pun intentional? ;)
Post Reply