OpenSSL and panama-foreign

Rémy Maucherat remm at apache.org
Wed Nov 10 17:43:55 UTC 2021


On Wed, Nov 10, 2021 at 6:03 PM Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
>
> This looks really odd.
>
> The crash happens at line 4420. But `s` has already been dereferenced
> e.g. in 4408 and 4413.
>
> This smells of something stomping on the stack?
>
> It would help a lot if you could try the panama-foreign version against
> the JDK 18 PR we have here:
>
> https://git.openjdk.java.net/jdk/pull/5907
>
> This is like panama-foreign _minus_ the latest VM changes (e.g. VM
> support is like that in 17).
>
> If the above PR works but Panama doesn't, I think then we're staring at
> a regression in the linker runtime.

Ok, quick test then since this is very interesting. It cores (exact same ones).

I'll work on all the other items now (thanks for all the homework ;) ).

Rémy

>
> Maurizio
>
> On 10/11/2021 11:20, Rémy Maucherat wrote:
> > In gdb, the debug is:
> >
> > #10 ssl3_shutdown (s=0x0) at ssl/s3_lib.c:4420
> > 4420            if (s->s3->alert_dispatch)
> > (gdb) print s
> > $1 = (SSL *) 0x0
> >
> > With the corresponding source:
> > 4400    int ssl3_shutdown(SSL *s)
> > 4401    {
> > 4402        int ret;
> > 4403
> > 4404        /*
> > 4405         * Don't do anything much if we have not done the
> > handshake or we don't
> > 4406         * want to send messages:-)
> > 4407         */
> > 4408        if (s->quiet_shutdown || SSL_in_before(s)) {
> > 4409            s->shutdown = (SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);
> > 4410            return 1;
> > 4411        }
> > 4412
> > 4413        if (!(s->shutdown & SSL_SENT_SHUTDOWN)) {
> > 4414            s->shutdown |= SSL_SENT_SHUTDOWN;
> > 4415            ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY);
> > 4416            /*
> > 4417             * our shutdown alert has been sent now, and if it
> > still needs to be
> > 4418             * written, s->s3->alert_dispatch will be true
> > 4419             */
> > 4420            if (s->s3->alert_dispatch)
> > 4421                return -1;        /* return WANT_WRITE */
> > 4422        } else if (s->s3->alert_dispatch) {
> > 4423            /* resend it if not sent */
> > 4424            ret = s->method->ssl_dispatch_alert(s);
> > 4425            if (ret == -1) {
> > 4426                /*
> > 4427                 * we only get to return -1 here the 2nd/Nth
> > invocation, we must
> > 4428                 * have already signalled return 0 upon a previous
> > invocation,
> > 4429                 * return WANT_WRITE
> > 4430                 */
> > 4431                return ret;
> > 4432            }


More information about the panama-dev mailing list