#1040375 /usr/lib/x86_64-linux-gnu/simplescreenrecorder/libssr-glinject.so: Segmentation fault when used with anything #1040375
- Package:
- simplescreenrecorder-lib
- Source:
- simplescreenrecorder-lib
- Description:
- feature-rich screen recorder that supports X11 and OpenGL - GLInject library
- Submitter:
- BZZZZ
- Date:
- 2024-05-07 14:51:03 UTC
- Severity:
- normal
- Tags:
Dear Maintainer,
* What led up to the situation?
Trying to "Record OpenGL" in simplescreenrecorder.
* What exactly did you do (or not do) that was effective (or
ineffective)?
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/simplescreenrecorder/libssr-glinject.so /usr/bin/true
* What was the outcome of this action?
Segmentation fault
* What outcome did you expect instead?
/usr/bin/true exits with 0 status code.
sudo apt build-dep simplescreenrecorder sudo apt install git mesa-utils simplescreenrecorder git clone --depth=1https://github.com/MaartenBaert/ssr cd ssr sudo --reset-timestamp ENABLE_32BIT_GLINJECT=FALSE ./simple-build-and-install # press Ctrl+C when it asks password LD_PRELOAD=build-release/glinject/libssr-glinject.so /usr/bin/true # no segmentation fault! build-release/src/simplescreenrecorder & LD_PRELOAD=build-release/glinject/libssr-glinject.so glxgears # works and can record opengl simplescreenrecorder & LD_PRELOAD=build-release/glinject/libssr-glinject.so glxgears # simplescreenrecorder from apt also works and can record opengl
[BZZZZ] It is unclear to me why you believe this should work. Can you tell me where you got the idea to run the shared library like this? Note, I am able to reproduce the crash. I only use the package by starting simplescreenrecorder, so I have never seen the problem you are reporting before, and do not understand when it would occur in normal use. Can you explain? I tried running from valgrind, but it did not work. I get the segfault, but no information about where the segfault happen. valgrind --trace-children=yes dash -c "LD_PRELOAD=/usr/lib/x86_64-linux-gnu/simplescreenrecorder/libssr-glinject.so /usr/bin/true" Same problem with gdb: (gdb) set environment LD_PRELOAD /usr/lib/x86_64-linux-gnu/simplescreenrecorder/libssr-glinject.so (gdb) run Starting program: /usr/bin/true During startup program terminated with signal SIGSEGV, Segmentation fault. (gdb) bt No stack. (gdb) I have no idea how to debug this.
[Petter Reinholdtsen]
1. /usr/bin/ssr-glinject from simplescreenrecorder package sets
LD_PRELOAD=/usr/$LIB/simplescreenrecorder/libssr-glinject.so
which also segmentation faults
2. LD_PRELOAD=/path/to/libssr-glinject.so works if simplescreenrecorder is compiled from source from https://github.com/MaartenBaert/ssr
[Petter Reinholdtsen]
How do you "Record OpenGL" glxgears?
When I try to launch anything using "OpenGL settings..." silent segmentation fault happens.
I know it's segmentation fault (launched "ls") because "sudo dmesg -c" outputs:
[ 261.486120] ls[3859]: segfault at ffffffffffffffe8 ip 00007f315ab2fd9a sp 00007ffc03c91e50 error 5 in libstdc++.so.6.0.30[7f315aa99000+101000] likely on CPU 2 (core 2, socket 0)
[ 261.486134] Code: ff eb b4 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3 0f 1e fa 55 48 89 fd 53 48 89 f3 48 83 ec 08 48 8b 06 48 89 77 08 c6 07 00 <48> 8b 78 e8 48 01 f7 48 8b 87 d8 00 00 00 8b 77 20 48 85 c0 74 2a
I figured out a way to run this under valgrind: cp /usr/lib/x86_64-linux-gnu/simplescreenrecorder/libssr-glinject.so . chmod a+rx libssr-glinject.so valgrind ./libssr-glinject.so This provide something semi-sensible from valgrind. No idea what the mapped region is, might have to build the library with debug information for this. Installing simplescreenrecorder-dbgsym and simplescreenrecorder-lib-dbgsym did not help to get more sensible information about where it crashes. Perhaps printf debugging is the only option? ==125603== Memcheck, a memory error detector ==125603== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. ==125603== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info ==125603== Command: ./libssr-glinject.so ==125603== ==125603== ==125603== Process terminating with default action of signal 11 (SIGSEGV) ==125603== Bad permissions for mapped region at address 0x108000 ==125603== at 0x108000: ??? (in /scratch/pere/src/opencamlib-salsa/libssr-glinject.so) ==125603== ==125603== HEAP SUMMARY: ==125603== in use at exit: 0 bytes in 0 blocks ==125603== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==125603== ==125603== All heap blocks were freed -- no leaks are possible ==125603== ==125603== For lists of detected and suppressed errors, rerun with: -s ==125603== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) Segmentation fault (core dumped)
I had a look upstream, and found two issues that seem to be about this crash bug: https://github.com/MaartenBaert/ssr/issues/992 and https://github.com/MaartenBaert/ssr/issues/1013 . The latter have some patch proposals. If the latest upstream git edition work, could the fix be the change descrived as "Switch to PLT hooks to make GLInject work with new dlopen/dlsym in libc" in <URL: https://github.com/MaartenBaert/ssr/commit/83b8f9f5d9c9ab06152657e57f85b6f71954a6b9 >? I do not use ssr much myself, and have not had time to test.
Hello, Bug #1040375 in simplescreenrecorder reported by you has been fixed in the Git repository and is awaiting an upload. You can see the commit message below and you can check the diff of the fix at: https://salsa.debian.org/multimedia-team/simplescreenrecorder/-/commit/d0fd87b48f684087934e32fd4ae20e3f39d59b81 ------------------------------------------------------------------------ Added 0000-switch-to-PLT-hooks-for-glinject.patch to fix segfault in glinject. Closes: #1040375 ------------------------------------------------------------------------ (this message was generated automatically) -- Greetings https://bugs.debian.org/1040375
[Petter Reinholdtsen] I applied the upstream commit in git branch fix-1040375-glinject and tested it on Bookworm, but alas, the .so file still segfaults with a useless backtrace. I might have applied the commit incorrectly, as it did not apply without changes, but hope not. Perhaps someone who understand what is happening can have a look?
Hello,
looking through some bugs about crashes I came to this one
and found found it interesting.
If a proper backtrace is still helping one can get one by using
systemd-coredump.
Another nice way to debug early startup is using rr debugger.
(Plus the ability to debug back and forth.)
As far as I see the crash happens because it wants to print this message:
57 GLINJECT_PRINT("Error: Can't open libdl.so!");
But unfortunately libstdc++ seems not yet prepared to output the error.
(rr) bt
#0 0x00007fbf7ff2fd9a in std::basic_ostream<char, std::char_traits<char> >::sentry::sentry(std::basic_ostream<char, std::char_traits<char> >&) () from /lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x00007fbf7ff3074c in std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) () from /lib/x86_64-linux-gnu/libstdc++.so.6
#2 0x00007fbf7ff30bdb in std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007fbf805cef6f in InitGLInject () at ./glinject/Hook.cpp:57
#4 0x00007fbf805cf13f in dlsym (handle=0x7fbf8060d2e0, symbol=0x7fbf80185f7a "pthread_create") at ./glinject/Hook.cpp:231
#5 0x00007fbf80136dd7 in glvndSetupPthreads () at ../src/util/glvnd_pthread.c:452
#6 0x00007fbf801351a9 in __glDispatchOnLoadInit () at ../src/GLdispatch/GLdispatch.c:174
#7 0x00007fbf805de9ce in call_init (env=0x7ffeea4b1538, argv=0x7ffeea4b1528, argc=1, l=<optimized out>) at ./elf/dl-init.c:74
#8 call_init (l=<optimized out>, argc=1, argv=0x7ffeea4b1528, env=0x7ffeea4b1538) at ./elf/dl-init.c:26
#9 0x00007fbf805deab4 in _dl_init (main_map=0x7fbf8060d2e0, argc=1, argv=0x7ffeea4b1528, env=0x7ffeea4b1538) at ./elf/dl-init.c:121
#10 0x00007fbf805f4a70 in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#11 0x0000000000000001 in ?? ()
#12 0x00007ffeea4b25ea in ?? ()
#13 0x0000000000000000 in ?? ()
(rr)
(For some reason with libstdc++6-dbgsym the backtrace gets less good.)
I guess upstream discussed this issue here:
https://github.com/MaartenBaert/ssr/issues/947
And a package built from `fix-1040375-glinject` did no
longer show this crash to me.
Attached file shows my actions inside a minimal bookworm VM.
Kind regards,
Bernhard
[Bernhard Übelacker] Thank you very much for the analysis and links. I applied the upstream patch to the Debian package build, and it sure seem to fix the segfault. Will need to do some more testing, and will upload a fixed package later.
Hello, Bug #1040375 in simplescreenrecorder reported by you has been fixed in the Git repository and is awaiting an upload. You can see the commit message below and you can check the diff of the fix at: https://salsa.debian.org/multimedia-team/simplescreenrecorder/-/commit/469d4dff951437e022d39bff10e9c4a3cbf8a0d4 ------------------------------------------------------------------------ Added 0010-plthook.patch from upstream to fix segfault in libssr-glinject.so. Closes: #1040375 ------------------------------------------------------------------------ (this message was generated automatically) -- Greetings https://bugs.debian.org/1040375
We believe that the bug you reported is fixed in the latest version of
simplescreenrecorder, 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 1040375@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Petter Reinholdtsen <pere@debian.org> (supplier of updated simplescreenrecorder 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: Tue, 07 May 2024 16:20:28 +0200
Source: simplescreenrecorder
Architecture: source
Version: 0.4.4-4
Distribution: unstable
Urgency: medium
Maintainer: Debian Multimedia Maintainers <debian-multimedia@lists.debian.org>
Changed-By: Petter Reinholdtsen <pere@debian.org>
Closes: 1040375
Changes:
simplescreenrecorder (0.4.4-4) unstable; urgency=medium
.
* Reordered patches according to classfication in README.
* Fixed typo in 1020-appstream-metadata-category.patch.
* Extended build rule to validate appstream metadata during build.
* Renamed build dependencies libgl1-mesa-dev->libgl-dev and
pkg-config->pkgconf on lintians request.
* Added 0010-plthook.patch from upstream to fix segfault in libssr-glinject.so
(Closes: #1040375).
* Updated Standards-Version from 4.6.2 to 4.7.0.
* Extended Appstream validator step and fix all issues reported.
Checksums-Sha1:
8b90d18d0f3c71f60dfe96637f394572bbd701ae 2631 simplescreenrecorder_0.4.4-4.dsc
a7c3e2de27b43a2eb339419402a4bf6b2d370e09 26980 simplescreenrecorder_0.4.4-4.debian.tar.xz
d6405cb94d2ac4e8213d4822027155a95f05fb35 16110 simplescreenrecorder_0.4.4-4_source.buildinfo
Checksums-Sha256:
db02e47e511e2087c13b39dbaeead4954702c546af01a4aae8482858f2fdb26d 2631 simplescreenrecorder_0.4.4-4.dsc
a1f725267c6778eaad6d813ce47a1c5b18295960cac99607f3a82a3b986c084c 26980 simplescreenrecorder_0.4.4-4.debian.tar.xz
6f8f295ed6d458a34668ecf12cdb23799225ca0a6e5e87111e3b00d6892956ae 16110 simplescreenrecorder_0.4.4-4_source.buildinfo
Files:
408fb0e0df7e0864293fb699a04b3c71 2631 video optional simplescreenrecorder_0.4.4-4.dsc
c59d3266eebc6f14a0b53dc806d859cd 26980 video optional simplescreenrecorder_0.4.4-4.debian.tar.xz
152f44dfcf20d3be1f827370b88ede5c 16110 video optional simplescreenrecorder_0.4.4-4_source.buildinfo
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEERqLf4owIeylOb9kkgSgKoIe6+w4FAmY6OR8ACgkQgSgKoIe6
+w5kXA//X61zFXXONPHwDFnel2DqYf7k/AiOeMihqvV0+ItqajkwsdYRKWxrPyev
Gett4eMVM0eH0yf7RbclW/QHr6MRq0dM6yhIrIYEf6ix9ipq09GfroPtVXMT9Pp8
UDHqCikuE4rU3fsxQfUD8CexGD2V0KVOMyP9orCu8Le0II9nHqkLxN88CTVnoLL7
H05XzLn08+Y44c1ncPtNvlpFzQ/t4xzLoQVXXCyddXpKO7NMAiIq1ydVny4TWLA2
DzXKefOXkOXFccLmU4wRsYJdAqPJU8QZy2DKmYFLtVi9D4w7DhVOemJC7AKta+VP
ngWhwoRaNyjhXjx7pvpzRkPCkwmoDIoImOf3V67xVK2FZgbHYfoOufg9ceLhlnpc
Zi+LJCzHZtLVEFpT5WXNe0PrvVRdJnRa9GZYvcrHAnZIcZHQdem/YsWYwo7ZNtXQ
qRUTUcopONMnZrN3e5fQplH3aGrHpSpkqbYJuhsLDL0Cc+DFaNSBH7Ra+d1IqGU7
pjb0c/U958AZ5EPaZgEStGbrBOc5GkiwJ6QPIg3kd7HYQbiI6DNQkNkveJU53VzU
rPrNnNsyloh44Oqse68EjJcYl0Zz5h2BUGXaO61afZw9DhXQxYvC1LT4FQfgwmB8
FE9AJ+AA9+pSy3h3w8sWIQfLdpMAu399LdIhrnakDQq+H8mYbxk=
=qoPR
-----END PGP SIGNATURE-----