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

libgap: what data in the libgap-calling functions must be declared volatile? other pitfalls? #2893

Closed
dimpase opened this issue Oct 4, 2018 · 2 comments
Labels
kind: discussion discussions, questions, requests for comments, and so on topic: libgap things related to libgap

Comments

@dimpase
Copy link
Member

dimpase commented Oct 4, 2018

My libgap-calling code manages to cause infinite recursion in PRINT_OR_APPEND_TO_STREAM: it cannot open stream, tries to ErrorQuit few lines later, ErrorQuit in turns call PRINT_OR_APPEND_TO_STREAM, again it cannot open the stream, etc etc.

The (long) code causing this is here - I probably can produce a reasonably short C code illustrating this (by design, it does call libgap with quite a few invalid inputs, causing errors and processing them in a callback), but I'd rather try to fix things first...

While this potential infinite recursion in itself is a sort of bug in (lib)gap, could it be that my code violates some unwritten rules, e.g. does not use volatile for some data that needs it? Other pitfalls of this sort?

Would it matter if the caller is multi-threaded (which is the case for me) and calls libgap in different threads?

@fingolfin
Copy link
Member

If you call GAP from multithreaded code, then you as caller must take care that no two such calls can run simultaneoulsy, e.g. via a lock, else all hell will break loose.

@dimpase dimpase added topic: libgap things related to libgap and removed topic: libgap things related to libgap labels Oct 31, 2018
@fingolfin fingolfin added kind: discussion discussions, questions, requests for comments, and so on and removed kind: discussion discussions, questions, requests for comments, and so on kind: question labels Mar 21, 2019
@fingolfin
Copy link
Member

The issue you describe at the start sounds like a duplicate of #3028 which should be fixed in GAP 4.11. There are no other API considerations to mention, but keep in mind that GAP is strictly single threaded, and hence so is libgap. Callers have to take care to call it from at most one thread at a time (or possibly even restrict all calls to it to a single thread).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: discussion discussions, questions, requests for comments, and so on topic: libgap things related to libgap
Projects
None yet
Development

No branches or pull requests

2 participants