-
Notifications
You must be signed in to change notification settings - Fork 139
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
Error reporting and the c-kona interface #511
Comments
Here's one complication: |
Also, when an error is reported from k to C as part of an ongoing dialogue, k has not necessarily closed. So it's probable that the null K-object is still in use in k. This all seems to indicate that reference counting may not be done on the the null K-object in k2 or k3. |
You need to create a new null object with an embedded error string, not change the standard _n. |
Well ... that make sense. Thanks !! |
On the other hand, maybe not ...
|
Why does standard _n have r->n > 0? Nothing special needed for refcounting a returned error or _n. The refcount is in r->_c. In k3, for a symbol value, r->n is used to store the string pointer. This is why CandK.txt keeps referring to ->n. Kona doesn’t use r->n to store string ptr. See the defn of macro Ks. In case any K returning function has to return Some error “foo”, it should |
Thanks again ... |
In k2.8, it is possible to easily show that an error condition returns null
in Kona, you seem to get the correct behavior
But that is because k2.8 is correctly parsing from right to left
and kona is erroneously parsing from left to right (and capturing the token to the left of an amend before attempting to capture any tokens to the right of the amend)
See issue #481. |
This is not a bug. Kona was designed to return 0 to indicate an error (see Coding Guidelines). Both this issue and issue 481 concern how kona was designed to handle errors. |
This issue was identified by @bakul.
In k2.8 (or in k3), when there is an error, k returns a null K-object(r) that has (r->t==6) and (r->n != 0) where r->n is a string (pointer to a character buffer) containing the error message. When k should return a null, then (r->t==6) and (r->n==0).
See https://a.kx.com/a/k/connect/c/CandK.txt
Currently, in src/k.c of kona:
The signature of snprintf is
where snprintf returns the number of characters printed into the buffer.
So, when there is an error in kona, it seems that kona returns some sort of amalgam of an int and K(0).
Bakul's work on the c-kona interface demonstrates that this amalgam (upon error) will test equal to 0 in C.
My own experiments seem to show that b->t and b->n are indeterminate. Note that the c-kona interface crashes on an attempt to show b, or to access b->t or b->n if there was an error in kona.
This should all be fixed in kona, to bring kona into alignment with k2.8 and k3 and so that the c-kona interface can work as it should.
The text was updated successfully, but these errors were encountered: