Re: [perl #129820] [NATIVECALL][LTA] callback returns useless error message
Am 06.10.2016 um 21:07 schrieb Brandon Allbery via RT: > Actually, now that I think about it, there is something that can be done; > not ideal, but the best we could do under the circumstances. Callbacks > should be given default exception handlers that at minimum output the > original exception (which currently is being lost when finding the > exception handler fails) and say they're aborting because there's no way to > pass the exception back through C to the outer Perl scope. Something like: > > Exception in Perl callback cannot be passed back through native code. > All we can do is die. Sorry. > Unhandled exception: > (actual thrown exception here) Actually that's the only sane way to deal with such a situation, and that should be documented behaviour for callbacks. Essentially, it's a special case of a callback failing for some reason; any well-designed callback API should offer a way to report back "failure" in some way, be it via an exception, a return code (plus hopefully a data block with more info), or whatever. If the API is not well-designed, the best the callback can do in case of failure is to die with an error message.
Re: [perl #129820] [NATIVECALL][LTA] callback returns useless error message
Am 06.10.2016 um 21:07 schrieb Brandon Allbery via RT: Actually, now that I think about it, there is something that can be done; not ideal, but the best we could do under the circumstances. Callbacks should be given default exception handlers that at minimum output the original exception (which currently is being lost when finding the exception handler fails) and say they're aborting because there's no way to pass the exception back through C to the outer Perl scope. Something like: Exception in Perl callback cannot be passed back through native code. All we can do is die. Sorry. Unhandled exception: (actual thrown exception here) Actually that's the only sane way to deal with such a situation, and that should be documented behaviour for callbacks. Essentially, it's a special case of a callback failing for some reason; any well-designed callback API should offer a way to report back "failure" in some way, be it via an exception, a return code (plus hopefully a data block with more info), or whatever. If the API is not well-designed, the best the callback can do in case of failure is to die with an error message.
Re: [perl #129820] [NATIVECALL][LTA] callback returns useless error message
On Thu, Oct 6, 2016 at 1:48 PM, Brandon Allbery via RT < perl6-bugs-follo...@perl.org> wrote: > I believe this is known. and it's difficult to fix: you simply can't map > exceptions across languages, so an exception in a Perl callback from a C > function called from Perl can only be caught in the context of the callback > itself. C has no clue about the exception, so you can neither catch it in C > Actually, now that I think about it, there is something that can be done; not ideal, but the best we could do under the circumstances. Callbacks should be given default exception handlers that at minimum output the original exception (which currently is being lost when finding the exception handler fails) and say they're aborting because there's no way to pass the exception back through C to the outer Perl scope. Something like: Exception in Perl callback cannot be passed back through native code. All we can do is die. Sorry. Unhandled exception: (actual thrown exception here) -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
Re: [perl #129820] [NATIVECALL][LTA] callback returns useless error message
On Thu, Oct 6, 2016 at 1:48 PM, Brandon Allbery via RT < perl6-bugs-follo...@perl.org> wrote: > I believe this is known. and it's difficult to fix: you simply can't map > exceptions across languages, so an exception in a Perl callback from a C > function called from Perl can only be caught in the context of the callback > itself. C has no clue about the exception, so you can neither catch it in C > Actually, now that I think about it, there is something that can be done; not ideal, but the best we could do under the circumstances. Callbacks should be given default exception handlers that at minimum output the original exception (which currently is being lost when finding the exception handler fails) and say they're aborting because there's no way to pass the exception back through C to the outer Perl scope. Something like: Exception in Perl callback cannot be passed back through native code. All we can do is die. Sorry. Unhandled exception: (actual thrown exception here) -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
Re: [perl #129820] [NATIVECALL][LTA] callback returns useless error message
On Thu, Oct 6, 2016 at 1:39 PM, Itsuki Toyotawrote: > In the following example, ` my = sub (Int $piyo) ` has wrong > signature (` my = sub (Int $piyo, Num $fuga) ` is a right one)and > it returns the error message of "Internal error: Unwound entire stack and > missed handler". > Honestly to say, it doesn't seem to make sense to me and I can't imagine > what to do. > I believe this is known. and it's difficult to fix: you simply can't map exceptions across languages, so an exception in a Perl callback from a C function called from Perl can only be caught in the context of the callback itself. C has no clue about the exception, so you can neither catch it in C nor have C relay it to the original Perl context. The error is, not very clearly (or rather, saying it clearly but in terms of internals), saying this: it can't find an exception handler in the callback's Perl context (and, implicitly, it can never reach one outside of the callback's context). Distilling this down to a short error message is a bit difficult. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
Re: [perl #129820] [NATIVECALL][LTA] callback returns useless error message
On Thu, Oct 6, 2016 at 1:39 PM, Itsuki Toyotawrote: > In the following example, ` my = sub (Int $piyo) ` has wrong > signature (` my = sub (Int $piyo, Num $fuga) ` is a right one)and > it returns the error message of "Internal error: Unwound entire stack and > missed handler". > Honestly to say, it doesn't seem to make sense to me and I can't imagine > what to do. > I believe this is known. and it's difficult to fix: you simply can't map exceptions across languages, so an exception in a Perl callback from a C function called from Perl can only be caught in the context of the callback itself. C has no clue about the exception, so you can neither catch it in C nor have C relay it to the original Perl context. The error is, not very clearly (or rather, saying it clearly but in terms of internals), saying this: it can't find an exception handler in the callback's Perl context (and, implicitly, it can never reach one outside of the callback's context). Distilling this down to a short error message is a bit difficult. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net