#1013931 libtorrent-rasterbar2.0: Crash on exit

Package:
libtorrent-rasterbar2.0
Source:
libtorrent-rasterbar
Description:
C++ bittorrent library by Rasterbar Software
Submitter:
Hilko Bengen
Date:
2022-07-04 10:51:03 UTC
Severity:
grave
#1013931#5
Date:
2022-06-27 16:47:11 UTC
From:
To:
Dear Maintainer,

bug #1013470 about a nbdkit rebuild failure was reported and it turned
out that this happens because of a crash that happens even in trivial
cases:

,----
| $ server/nbdkit plugins/torrent/.libs/nbdkit-torrent-plugin.so --help
| nbdkit [-4|--ipv4-only] [-6|--ipv6-only]
|        [-D|--debug PLUGIN|FILTER|nbdkit.FLAG=N]
|        [-e|--exportname EXPORTNAME] [--exit-with-parent]
|        [--filter FILTER ...] [-f|--foreground]
|        [-g|--group GROUP] [-i|--ipaddr IPADDR]
|        [--log stderr|syslog|null]
|        [-n|--newstyle] [--mask-handshake MASK] [--no-sr] [-o|--oldstyle]
|        [-P|--pidfile PIDFILE]
|        [-p|--port PORT] [-r|--readonly]
|        [--run CMD] [-s|--single] [--selinux-label LABEL] [--swap]
|        [-t|--threads THREADS]
|        [--tls off|on|require]
|        [--tls-certificates /path/to/certificates]
|        [--tls-psk /path/to/pskfile] [--tls-verify-peer]
|        [-U|--unix SOCKET] [-u|--user USER]
|        [-v|--verbose] [-V|--version] [--vsock]
|        PLUGIN [[KEY=]VALUE [KEY=VALUE [...]]]
|
| nbdkit --dump-config
|
| nbdkit PLUGIN --dump-plugin
|
| nbdkit --help
|
| Please read the nbdkit(1) manual page for full usage.
|
| plugin: torrent (nbdkit bittorrent plugin)
| (plugins/torrent/.libs/nbdkit-torrent-plugin.so)
| torrent=<TORRENT>   (required) Torrent or magnet link.
| file=DISK.iso                  File to serve within torrent.
| cache=DIR                      Set directory to store partial downloads.
| Segmentation fault
`----

From the output, it looks as if the crash occurred on a cleanup code
path.

Downgrading to 2.0.6-3 (before the OpenSSL 3 rebuild) makes the
segmentation fault go away.

The stacktrace below suggests that this is related to cleanup code
registered using atexit(3): pthread_rwlock_wrlock() is called with a
NULL pointer.

,----
| $ gdb --args server/nbdkit plugins/torrent/.libs/nbdkit-torrent-plugin.so --help
| GNU gdb (Debian 12.1-2) 12.1
| Copyright (C) 2022 Free Software Foundation, Inc.
| [...]
| (gdb) run
| Starting program: /home/bengen/p/deb/nbdkit/server/nbdkit plugins/torrent/.libs/nbdkit-torrent-plugin.so --help
| [Thread debugging using libthread_db enabled]
| Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
| nbdkit [-4|--ipv4-only] [-6|--ipv6-only]
|        [-D|--debug PLUGIN|FILTER|nbdkit.FLAG=N]
| [...]
| torrent=<TORRENT>   (required) Torrent or magnet link.
| file=DISK.iso                  File to serve within torrent.
| cache=DIR                      Set directory to store partial downloads.
|
| Program received signal SIGSEGV, Segmentation fault.
| __GI___pthread_rwlock_wrlock (rwlock=0x0) at pthread_rwlock_wrlock.c:27
| 27	pthread_rwlock_wrlock.c: No such file or directory.
| (gdb) bt
| #0  __GI___pthread_rwlock_wrlock (rwlock=0x0) at pthread_rwlock_wrlock.c:27
| #1  0x00007ffff6c8a8e9 in CRYPTO_THREAD_write_lock (lock=<optimized out>) at ../crypto/threads_pthread.c:112
| #2  0x00007ffff6ba7a03 in conf_modules_finish_int () at ../crypto/conf/conf_mod.c:524
| #3  0x00007ffff6ba8132 in CONF_modules_unload (all=1) at ../crypto/conf/conf_mod.c:482
| #4  0x00007ffff726af24 in boost::asio::ssl::detail::openssl_init_base::do_init::~do_init (this=0x55556157dc50, __in_chrg=<optimized out>)
|     at /usr/include/boost/asio/ssl/detail/impl/openssl_init.ipp:90
| #5  std::_Sp_counted_ptr<boost::asio::ssl::detail::openssl_init_base::do_init*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (
|     this=<optimized out>) at /usr/include/c++/11/bits/shared_ptr_base.h:348
| #6  0x00007ffff726b09a in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x55556157db90)
|     at /usr/include/c++/11/bits/shared_ptr_base.h:168
| #7  std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=<optimized out>, __in_chrg=<optimized out>)
|     at /usr/include/c++/11/bits/shared_ptr_base.h:705
| #8  std::__shared_ptr<boost::asio::ssl::detail::openssl_init_base::do_init, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (
|     this=<optimized out>, __in_chrg=<optimized out>) at /usr/include/c++/11/bits/shared_ptr_base.h:1154
| #9  std::shared_ptr<boost::asio::ssl::detail::openssl_init_base::do_init>::~shared_ptr (this=<optimized out>, __in_chrg=<optimized out>)
|     at /usr/include/c++/11/bits/shared_ptr.h:122
| #10 0x00007ffff7bb9f77 in __run_exit_handlers (status=status@entry=0, listp=0x7ffff7d4d738 <__exit_funcs>,
|     run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108
| #11 0x00007ffff7bba11a in __GI_exit (status=status@entry=0) at exit.c:139
| #12 0x000055555555a944 in main (argc=<optimized out>, argv=<optimized out>) at ./server/main.c:678
`----

Cheers,
-Hilko

#1013931#14
Date:
2022-06-28 07:29:45 UTC
From:
To:
forwarded 1013931 https://github.com/arvidn/libtorrent/issues/6940
thanks

Forwarded to https://github.com/arvidn/libtorrent/issues/6940

Christian

#1013931#19
Date:
2022-06-28 13:05:11 UTC
From:
To:
Could you try this upstream patch ?

https://github.com/arvidn/libtorrent/pull/6941

Christian

#1013931#24
Date:
2022-06-28 22:13:55 UTC
From:
To:
* Christian Marillat:

Perhaps I'm missing something … it seems to me that this patch is
to be appplied onto version 1.2, not 2.0 – and the verrsion nbdkit was
most recently built with is 2.0.6.

Cheers,
-Hilko

#1013931#29
Date:
2022-07-01 16:16:48 UTC
From:
To:
I think I found the root cuase in boost1.74 – and reported it as
#1014180. Please note that libtorrent-rasterbar has to be rebuilt for
the change to take effect.

(It might be a good idea to add a Built-Using line to debian/control.)

Cheers,
-Hilko

#1013931#34
Date:
2022-07-04 06:22:52 UTC
From:
To:
Built-Using doesn't work with virtual package.

Christian

#1013931#39
Date:
2022-07-04 06:33:57 UTC
From:
To:
Well, virtual isn't the right word, but libboost-dev is an empty
package and dh_gencontrol return nothing. dh_gencontrol need to be
called with libboost1.74-dev completely unusable for the long term.

Christian

#1013931#44
Date:
2022-07-04 10:49:07 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
libtorrent-rasterbar, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1013931@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Christian Marillat <marillat@debian.org> (supplier of updated libtorrent-rasterbar package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Mon, 04 Jul 2022 12:40:15 +0200
Source: libtorrent-rasterbar
Architecture: source
Version: 2.0.6-4
Distribution: unstable
Urgency: medium
Maintainer: Christian Marillat <marillat@debian.org>
Changed-By: Christian Marillat <marillat@debian.org>
Closes: 1013931
Changes:
 libtorrent-rasterbar (2.0.6-4) unstable; urgency=medium
 .
   * Build with latest boost1.74 (Closes: #1013931)
Checksums-Sha1:
 9593dd0a07e62543b444cf2af187aa9526177e50 2350 libtorrent-rasterbar_2.0.6-4.dsc
 5849d24b92bb28866ca0e35a7e73c1933140f7e7 12908 libtorrent-rasterbar_2.0.6-4.debian.tar.xz
 ceb11fac78eea72af2b1c699b769e7f3ac64fa7d 7668 libtorrent-rasterbar_2.0.6-4_source.buildinfo
Checksums-Sha256:
 34ad29aaedd2d46e53d874f46d16daca0e763e79f9fdf095f4b610a46d30ad1f 2350 libtorrent-rasterbar_2.0.6-4.dsc
 2d20448cdf799156f4cd67c512070cc01846d1ee92b793c1abcf3339573a75ba 12908 libtorrent-rasterbar_2.0.6-4.debian.tar.xz
 770b068180d5b98bf932b643ed659c2cafc1daff40cc67b2ff4275376b843226 7668 libtorrent-rasterbar_2.0.6-4_source.buildinfo
Files:
 9933aef11ceb752f6592a31419776d10 2350 libs optional libtorrent-rasterbar_2.0.6-4.dsc
 ccfaccacf9a977f6c17704de7253b78a 12908 libs optional libtorrent-rasterbar_2.0.6-4.debian.tar.xz
 4baaaf7d4efe968332ef89ae27f31312 7668 libs optional libtorrent-rasterbar_2.0.6-4_source.buildinfo
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEpAH/mTaPofmBUt51XICMK2VVgRcFAmLCxPAACgkQXICMK2VV
gRfMnhAAzR/ohhS3gnKVgMk4eRmAf08FNpd+q9R9Hib2+0ZgM7ZI8ym2lJvEr3wi
WrTsX13nFcDld0zF+xCkr8QBOF2VRBigIzjV2HZ7exWWOkB9vN6h5yA4450VUCaq
lMrrW5Xfq7KKCMaqHZN7brD2hCxGk/rCBFf/3aW2TjYBwmZvOpaNpJ8Q3f0bRYmt
b/p84mVweU4oz8ykP8/CVTrusKuEQC2y837XPiQwCpoGVYmYolyjtA/ppOarl5M0
vaI+UYALoVmWEZEqcu5f54C0caFrK2VYcRXgNUweBBcdzjHo0GqOixGh+FSqKDQX
Xwmq/FMazIsCcgeWR+xrpZWGs1eFg8Im0LDGuCDxZEWjoYQTZp7y1+NfrFrMneJ+
JOAkVB5XOfZC22Jkw5l08bSuF9hPm3oBywB1t6AxHZWp0Jm3AMkbmtevU3FFXEct
lNdB5ywlQKPaJpg0sKQuKFFLhd2b8Iw2rDHg/AlhpaXG9MDx1J3karGKbwBa8Syd
KX2jbY5JQ5c2EQy4rwajCube3rXHONU2wSHzgXMQXGkgouLJn7iVFmZISzvrkf2V
YzLAnKl8GXevFpd3cYtO/JWesZnVgVGnjA8gvNpVw5282YIStgLUdmg3N53GLj1z
7anU9GjCTPdk7vRLVQWetIM2AP7sViC+KmQUMwwcjF3UMwOxdN4=
=m/yL
-----END PGP SIGNATURE-----