Skip to content
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

Merged
merged 1 commit into from
May 2, 2019

Conversation

stellarspot
Copy link
Contributor

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.

Copy link
Member

@linas linas left a 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))
Copy link
Member

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))))
Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor

@amebel amebel left a 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?

@amebel
Copy link
Contributor

amebel commented May 2, 2019

Never mind got a better context after reading #3484

@amebel amebel merged commit 854c9aa into opencog:master May 2, 2019
@stellarspot stellarspot deleted the feature/handle-psi-exit-crash branch July 3, 2019 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants