-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
resource_error(stack) isn't caught if PL_exception(0) is called #1138
Comments
Hmmm ... the problem doesn't seem to be the However, in adding some debug print statements, I found that if I subsequently try to get the error term using So, the question becomes: can I detect that a local stack overflow has happened, so that I don't do something that changes the exception into a variable? (That would be the easiest workaround, I think) |
There's one obvious work-around: check for exception equal |
First of all,
|
Yes, I have pulled 308c922 ... I get the same result. Because there appear to be some subtle issues with the Prolog lifetimes of terms and the C++ lifetimes, I'm temporarily isolating that issue by serializing the exception in PlException (using PL_get_nchars() because it's easy to debug); when I get that all working (including exceptions from PlQuery), I'll revisit the |
I would just block the test for now. I'm a bit busy. In due time I can create the C equivalent to test and show what should be done. |
If Pl_exception(0) is called when stack overflow occurs, the return value is a term that is a
variable
(as determined byPL_term_type()
). Also, it seems to remove some exception information, so that return "false" results in failure rather than an exception. (That is, if I don't do thePL_exception(0)
call, I get a resource error; if I do aPL_exception(0)
and then return "false", I just get failure and no exception.)When I don't call
PL_exception(0)
, this is the error term I get (the foreign code is fromtest_cpp.cpp
, but uses a "work-in-progress" version ofSWI-cpp2.h
):If you need a reproducible example, I can make one. But I was hoping that the reason can be determined by quickly looking at the code. Is it perhaps that
PL_new_term_ref()
doesn't work when there's a stack overflow, and theensureLocalSpace()
call confuses things? (I notice that there's no check for thePL_new_term_ref()
, which presumably has returned0
; but before that it should have (recursively?) calledraiseStackOverflow()
?I'm OK with getting a variable if the exception term can't be determined or allocated; the problem is that
PL_exception(0)
ends up removing some information from the exception, so areturn false
produces a failure in Prolog and not an exception.The text was updated successfully, but these errors were encountered: