Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Mar 2022 22:34:40 +0100
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
Cc:        John Baldwin <jhb@freebsd.org>, Ed Maste <emaste@freebsd.org>, dev-commits-src-branches@freebsd.org
Subject:   Re: git: b2127b6f1ae2 - stable/13 - Install unwind.h into /usr/include
Message-ID:  <7482C54A-1128-4AFF-A74E-53D88334C1D9@FreeBSD.org>
In-Reply-To: <20220305113613.7760bb3845cda1c04707fb34@dec.sakura.ne.jp>
References:  <20220303224535.a0cca57e1f033e930a7f8f9d@dec.sakura.ne.jp> <3166E99F-1616-40D9-BD8B-D18E8104D6FF@FreeBSD.org> <a9863238-04e5-381d-105d-311a2b0c3f56@FreeBSD.org> <6E5AD771-3140-480A-BF20-95B8E8A27189@FreeBSD.org> <20220305113613.7760bb3845cda1c04707fb34@dec.sakura.ne.jp>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_0655F321-539A-465B-BB9C-D0EF8E7F9DE6
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

On 5 Mar 2022, at 03:36, Tomoaki AOKI <junchoon@dec.sakura.ne.jp> wrote:
>=20
> On Fri, 4 Mar 2022 19:25:06 +0100
> Dimitry Andric <dim@FreeBSD.org> wrote:
>> On 3 Mar 2022, at 21:30, John Baldwin <jhb@freebsd.org> wrote:
>>>=20
>>> On 3/3/22 10:08 AM, Dimitry Andric wrote:
...
>> For some reason, with the libunwind headers instead, it now gets =
shifted
>> by 8 bytes. I think we are having a case of kludges upon kludges upon
>> hacks, which is now falling apart... :-)
>>=20
>> In any case, if I unconditionally enable the "#if defined
>> _LIBCPPABI_VERSION // detect libc++abi" block in except.cxx, it does
>> detect the exception header successfully, the gengal.bin command does
>> not crash anymore, and the whole libreoffice build succeeds. The
>> libreoffice binaries even run OK, though I only did light testing, =
like
>> opening a doc file and messing around with it a little bit.
>>=20
>> But I'm not sure if it is the solution we want. Maybe we should again
>> put in some sort of compat hack, to make the libunwind/libcxxrt
>> combination work for this scenario? (I think libreoffice is one of =
the
>> few applications that calls __cxa_throw directly, with its own =
deleter
>> function...)
>>=20
>> -Dimitry
>>=20
>=20
> Thanks for your hard work!
> Maybe, editors/libreoffice should adapt to the change if __UNWIND_H__
> is defined in /usr/include/unwind.h, but if some others (including
> not-yet-ported softwares) have the same problem, compat hack on base
> would be better preferred.
>=20
> If there is a standard way to avoid this (use already-existing wrapper
> function?), it would be better fixing editors/libreoffice with some
> hints written into porter's handbook.

There's something very strange going on here, as evidenced by yet
another gdb session:

(gdb) frame 2
#2  0x000000082c2e92e7 in __cxa_free_exception =
(thrown_exception=3D0x87b5aff00) at =
/share/dim/src/freebsd/llvm-14-update/contrib/libcxxrt/exception.cc:627
627                             =
ex->exceptionDestructor(thrown_exception);
(gdb) print thrown_exception
$31 =3D (void *) 0x87b5aff00
(gdb) print static_cast<__cxa_exception*>(thrown_exception)-1
$32 =3D (__cxa_exception *) 0x87b5afe88

So according to the spec, casting the void pointer 'thrown_exception' to
a __cxa_exception pointer, then subtracting 1, should give you the
original __cxa_exception struct. In this case, it subtracts 8 bytes,
going from 0x87b5aff00 to 0x87b5afe88.

Now I do exactly the same in the libreoffice frame one below, where the
incoming void pointer 'pExc' is the previous 'thrown_exception' value:

(gdb) frame 1
#1  gcc3::deleteException (pExc=3D0x87b5aff00) at =
bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx:139
139         OUString unoName( toUNOname( header->exceptionType->name() ) =
);
(gdb) print pExc
$33 =3D (void *) 0x87b5aff00
(gdb) print static_cast<__cxa_exception*>(pExc)-1
$34 =3D (__cxa_exception *) 0x87b5afe80

So in *this* function, subtracting 1 from a __cxa_exception pointer
subtracts 16 bytes instead, going from 0x87b5aff00 to 0x87b5afe80!

I don't know what causes this, except maybe that libreoffice pulls in
some different definition of __cxa_exception. It looks like they have
their own header for this:

=
https://cgit.freedesktop.org/libreoffice/core/tree/bridges/source/cpp_uno/=
gcc3_linux_x86-64/share.hxx

but it's not clear to me whether they are enabling any of these custom
declarations...

-Dimitry


--Apple-Mail=_0655F321-539A-465B-BB9C-D0EF8E7F9DE6
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.2

iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCYiPXcAAKCRCwXqMKLiCW
o+CvAJ4onozGounph9uMUWtBQ/iMMeMWnQCfWJ9SNI9eFGX8FwyxS/CrZlARzyc=
=9nXp
-----END PGP SIGNATURE-----

--Apple-Mail=_0655F321-539A-465B-BB9C-D0EF8E7F9DE6--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7482C54A-1128-4AFF-A74E-53D88334C1D9>