RFR: JDK-8317920: JDWP-agent sends broken exception event with onthrow option [v5]

Johannes Bechberger jbechberger at openjdk.org
Tue Oct 17 19:32:45 UTC 2023


On Tue, 17 Oct 2023 19:07:45 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:

>  I'm also wondering if we shouldn't just export cbException() and call it directly rather than mimic a lot of what it is doing, although probably what would be easier is a new API that handles the event described in the EventInfo passed to it. Maybe cbEI(). This would resolve the handlerID issue I point out (the event would not be sent if there is no request for it, and if there is a request it will be sent with the correct handlerID, not 0).

Maybe in a follow-up in a PR? This is not directly related to the exception value and could potentially change the behavior of the `onthrow` feature, therefore needing more tests.

> src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c line 730:
> 
>> 728:         if (opt_info != NULL) {
>> 729:             info = *opt_info;
>> 730:         }
> 
> Try the following code here. I don't think I changed anything outside this area, but since I also have your diffs present I can't reacall for sure. I also cleaned this section up a bit. It looks like it only has to deal with EI_EXCEPTION and opt_info is always set.
> 
> 
>         /*
>          * TO DO: Kludgy way of getting the triggering event to the
>          * just-attached debugger. It would be nice to make this a little
>          * cleaner. There is also a race condition where other events
>          * can get in the queue (from other not-yet-suspended threads)
>          * before this one does. (Also need to handle allocation error below?)
>          */
>         struct bag *initEventBag;
>         LOG_MISC(("triggering_ei == EI_EXCEPTION"));
>         JDI_ASSERT(triggering_ei == EI_EXCEPTION);
>         JDI_ASSERT(opt_info != NULL);
>         initEventBag = eventHelper_createEventBag();
>         threadControl_onEventHandlerEntry(currentSessionID, opt_info, NULL);
>         eventHelper_recordEvent(opt_info, 0, suspendPolicy, initEventBag);
>         (void)eventHelper_reportEvents(currentSessionID, initEventBag);
>         bagDestroyBag(initEventBag);

Looks good, I'm running it locally.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/16145#issuecomment-1767039725
PR Review Comment: https://git.openjdk.org/jdk/pull/16145#discussion_r1362654959


More information about the serviceability-dev mailing list