-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#3484 Join to psi thread in pshi-halt function to avoid segmentation fault #3487
#3484 Join to psi thread in pshi-halt function to avoid segmentation fault #3487
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Either @amebel or @leungmanhin need to do the final review/merge.
) | ||
|
||
; ------------------------------------------------------------- | ||
(define* (psi-halt component #:optional (timeout 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking that an infinite default timeout would be better. That would be guaranteed to always have the correct behavior (although it might hang if there are other bugs).
(if (not (null? lst)) | ||
(let | ||
((thread (car (car lst))) | ||
(comp (cdr (car lst)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, (car (car lst))
is the same as (caar lst)
and (cdr (car lst))
is the same as (cdar lst)
and there's a large collection of utilities here: https://srfi.schemers.org/srfi-1/srfi-1.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and for accessing elements of a pair, you can use first
and second
.. or maybe even list-ref
... here, it does not really matter, but names like that are just slightly more readable for conventional programmers coming from other languages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What calls psi-halt
during scheme exit?
Never mind got a better context after reading #3484 |
Psi starts a new thread and checks the provided atom value if the thread should stop.
When Scheme exits it can destroy the Atomspace first so when psi checks the atom on a separated thread the atom or its values may not exist anymore.
The fix stores the created thread object with the provided atom in a list and uses the stored atom to join to the thread in the psi-halt function.