Skip to content

Instantly share code, notes, and snippets.

@uilianries
Created June 3, 2021 17:09
Show Gist options
  • Save uilianries/5bd54d33872976b7b8ec5ca48bcf5fec to your computer and use it in GitHub Desktop.
Save uilianries/5bd54d33872976b7b8ec5ca48bcf5fec to your computer and use it in GitHub Desktop.
Clang 9 + libstdc++.so.6.0.29
root@2a0a244cef6f:/tmp/bin# gdb ./foobar_cpp_libstdcpp
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./foobar_cpp_libstdcpp...done.
(gdb) run
Starting program: /tmp/bin/foobar_cpp_libstdcpp
warning: Error disabling address space randomization: Operation not permitted
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[2021-06-03 17:05:43.371] [info] Welcome to spdlog version 1.8.5 !
[2021-06-03 17:05:43.371] [warning] Easy padding in numbers like 00000012
[2021-06-03 17:05:43.371] [critical] Support for int: 42; hex: 2a; oct: 52; bin: 101010
[2021-06-03 17:05:43.371] [info] Support for floats 1.23
[2021-06-03 17:05:43.371] [info] Positional args are supported too..
[2021-06-03 17:05:43.371] [info] right aligned, left aligned
[2021-06-03 17:05:43.371] [debug] This message should be displayed..
[17:05:43 +00:00] [I] [thread 524] This an info message with custom format
[2021-06-03 17:05:43.371] [info] ****************** Backtrace Start ******************
[2021-06-03 17:05:43.371] [debug] Backtrace message 90
[2021-06-03 17:05:43.371] [debug] Backtrace message 91
[2021-06-03 17:05:43.371] [debug] Backtrace message 92
[2021-06-03 17:05:43.371] [debug] Backtrace message 93
[2021-06-03 17:05:43.371] [debug] Backtrace message 94
[2021-06-03 17:05:43.371] [debug] Backtrace message 95
[2021-06-03 17:05:43.371] [debug] Backtrace message 96
[2021-06-03 17:05:43.371] [debug] Backtrace message 97
[2021-06-03 17:05:43.371] [debug] Backtrace message 98
[2021-06-03 17:05:43.371] [debug] Backtrace message 99
[2021-06-03 17:05:43.371] [info] ****************** Backtrace End ********************
[New Thread 0x7f7ed002b700 (LWP 528)]
[2021-06-03 17:05:43.374] [info] Binary example:
0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
0060: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
0080: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
[2021-06-03 17:05:43.374] [info] Another binary example: 00 00 00 00 00 00 00 00 00 00
[multi_sink_example] [warning] this should appear in both console and file
[2021-06-03 17:05:43.374] [info] user defined type: [my_type i=14]
[New Thread 0x7f7ecf82a700 (LWP 529)]
Thread 2 "foobar_cpp_libs" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f7ed002b700 (LWP 528)]
0x00007f7ed0f1adca in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0 0x00007f7ed0f1adca in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x00007f7ed12576ba in start_thread (arg=0x7f7ed002b700) at pthread_create.c:333
#2 0x00007f7ed087e51d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
(gdb) frame 0
#0 0x00007f7ed0f1adca in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) info threads
Id Target Id Frame
1 Thread 0x7f7ed167b740 (LWP 524) "foobar_cpp_libs" clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:81
* 2 Thread 0x7f7ed002b700 (LWP 528) "foobar_cpp_libs" 0x00007f7ed0f1adca in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
3 Thread 0x7f7ecf82a700 (LWP 529) "foobar_cpp_libs" 0x0000000000000000 in ?? ()
(gdb)
root@2a0a244cef6f:/tmp/bin# ldd foobar_cpp_libstdcpp
linux-vdso.so.1 => (0x00007ffcad1e6000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f67cdd41000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f67cd93b000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f67cd632000)
libllvm-unwind.so.1 => /usr/lib/x86_64-linux-gnu/libllvm-unwind.so.1 (0x00007f67ce171000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f67cd268000)
/lib64/ld-linux-x86-64.so.2 (0x00007f67cdf5e000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f67cd052000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f67cce4e000)
root@2a0a244cef6f:/tmp/bin# ./foobar_cpp_libstdcpp
[2021-06-03 17:02:47.674] [info] Welcome to spdlog version 1.8.5 !
[2021-06-03 17:02:47.674] [warning] Easy padding in numbers like 00000012
[2021-06-03 17:02:47.674] [critical] Support for int: 42; hex: 2a; oct: 52; bin: 101010
[2021-06-03 17:02:47.674] [info] Support for floats 1.23
[2021-06-03 17:02:47.674] [info] Positional args are supported too..
[2021-06-03 17:02:47.674] [info] right aligned, left aligned
[2021-06-03 17:02:47.674] [debug] This message should be displayed..
[17:02:47 +00:00] [I] [thread 19] This an info message with custom format
[2021-06-03 17:02:47.674] [info] ****************** Backtrace Start ******************
[2021-06-03 17:02:47.674] [debug] Backtrace message 90
[2021-06-03 17:02:47.674] [debug] Backtrace message 91
[2021-06-03 17:02:47.674] [debug] Backtrace message 92
[2021-06-03 17:02:47.674] [debug] Backtrace message 93
[2021-06-03 17:02:47.674] [debug] Backtrace message 94
[2021-06-03 17:02:47.674] [debug] Backtrace message 95
[2021-06-03 17:02:47.674] [debug] Backtrace message 96
[2021-06-03 17:02:47.674] [debug] Backtrace message 97
[2021-06-03 17:02:47.674] [debug] Backtrace message 98
[2021-06-03 17:02:47.674] [debug] Backtrace message 99
[2021-06-03 17:02:47.674] [info] ****************** Backtrace End ********************
Segmentation fault
root@2a0a244cef6f:/tmp/bin# valgrind --track-origins=yes -v ./foobar_cpp_libstdcpp
==530== Memcheck, a memory error detector
==530== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==530== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==530== Command: ./foobar_cpp_libstdcpp
==530==
--530-- Valgrind options:
--530-- --track-origins=yes
--530-- -v
--530-- Contents of /proc/version:
--530-- Linux version 5.4.72-microsoft-standard-WSL2 (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Oct 28 23:40:43 UTC 2020
--530--
--530-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-avx-avx2-bmi
--530-- Page sizes: currently 4096, max supported 4096
--530-- Valgrind library directory: /usr/lib/valgrind
--530-- Reading syms from /tmp/bin/foobar_cpp_libstdcpp
--530-- ELF section outside all mapped regions
--530-- Reading syms from /lib/x86_64-linux-gnu/ld-2.23.so
--530-- Considering /lib/x86_64-linux-gnu/ld-2.23.so ..
--530-- .. CRC mismatch (computed ceb73aaf wanted 8cb7c5ee)
--530-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so ..
--530-- .. CRC is valid
--530-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux
--530-- Considering /usr/lib/valgrind/memcheck-amd64-linux ..
--530-- .. CRC mismatch (computed eea41ea9 wanted 2009db78)
--530-- object doesn't have a symbol table
--530-- object doesn't have a dynamic symbol table
--530-- Scheduler: using generic scheduler lock implementation.
--530-- Reading suppressions file: /usr/lib/valgrind/default.supp
==530== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-530-by-???-on-2a0a244cef6f
==530== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-530-by-???-on-2a0a244cef6f
==530== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-530-by-???-on-2a0a244cef6f
==530==
==530== TO CONTROL THIS PROCESS USING vgdb (which you probably
==530== don't want to do, unless you know exactly what you're doing,
==530== or are doing some strange experiment):
==530== /usr/lib/valgrind/../../bin/vgdb --pid=530 ...command...
==530==
==530== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==530== /path/to/gdb ./foobar_cpp_libstdcpp
==530== and then give GDB the following command
==530== target remote | /usr/lib/valgrind/../../bin/vgdb --pid=530
==530== --pid is optional if only one valgrind process is running
==530==
--530-- REDIR: 0x401cf40 (ld-linux-x86-64.so.2:strlen) redirected to 0x3809e181 (???)
--530-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so
--530-- Considering /usr/lib/valgrind/vgpreload_core-amd64-linux.so ..
--530-- .. CRC mismatch (computed 2567ccf6 wanted 49420590)
--530-- object doesn't have a symbol table
--530-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so
--530-- Considering /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so ..
--530-- .. CRC mismatch (computed 0e27c9a8 wanted ac585421)
--530-- object doesn't have a symbol table
==530== WARNING: new redirection conflicts with existing -- ignoring it
--530-- old: 0x0401cf40 (strlen ) R-> (0000.0) 0x3809e181 ???
--530-- new: 0x0401cf40 (strlen ) R-> (2007.0) 0x04c31020 strlen
--530-- REDIR: 0x401b890 (ld-linux-x86-64.so.2:index) redirected to 0x4c30bc0 (index)
--530-- REDIR: 0x401bab0 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4c320d0 (strcmp)
--530-- REDIR: 0x401dca0 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4c35270 (mempcpy)
--530-- Reading syms from /lib/x86_64-linux-gnu/libpthread-2.23.so
--530-- Considering /usr/lib/debug/.build-id/c5/57b8146e8079af46310b549de6912d1fc4ea86.debug ..
--530-- .. build-id is valid
--530-- Reading syms from /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.29
--530-- object doesn't have a symbol table
--530-- Reading syms from /lib/x86_64-linux-gnu/libm-2.23.so
--530-- Considering /lib/x86_64-linux-gnu/libm-2.23.so ..
--530-- .. CRC mismatch (computed 9ca17cae wanted 80886b26)
--530-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libm-2.23.so ..
--530-- .. CRC is valid
--530-- Reading syms from /usr/lib/x86_64-linux-gnu/libunwind.so.1.0
--530-- ELF section outside all mapped regions
--530-- Reading syms from /usr/lib/x86_64-linux-gnu/libunwind.so.1.0
--530-- ELF section outside all mapped regions
--530-- Reading syms from /lib/x86_64-linux-gnu/libc-2.23.so
--530-- Considering /lib/x86_64-linux-gnu/libc-2.23.so ..
--530-- .. CRC mismatch (computed 2c57cb29 wanted 6e6a411e)
--530-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so ..
--530-- .. CRC is valid
--530-- Reading syms from /lib/x86_64-linux-gnu/libgcc_s.so.1
--530-- Considering /lib/x86_64-linux-gnu/libgcc_s.so.1 ..
--530-- .. CRC mismatch (computed b9a68419 wanted 29d51b00)
--530-- object doesn't have a symbol table
--530-- REDIR: 0x401ddf0 (ld-linux-x86-64.so.2:stpcpy) redirected to 0x4c342c0 (stpcpy)
--530-- Reading syms from /lib/x86_64-linux-gnu/libdl-2.23.so
--530-- Considering /lib/x86_64-linux-gnu/libdl-2.23.so ..
--530-- .. CRC mismatch (computed 352992f5 wanted 897c40c5)
--530-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libdl-2.23.so ..
--530-- .. CRC is valid
--530-- REDIR: 0x57f5a80 (libc.so.6:strcasecmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--530-- REDIR: 0x57f1300 (libc.so.6:strcspn) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--530-- REDIR: 0x57f7d70 (libc.so.6:strncasecmp) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--530-- REDIR: 0x57f3770 (libc.so.6:strpbrk) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--530-- REDIR: 0x57f3b00 (libc.so.6:strspn) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--530-- REDIR: 0x57f51cb (libc.so.6:memcpy@GLIBC_2.2.5) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--530-- REDIR: 0x57f3480 (libc.so.6:rindex) redirected to 0x4c308a0 (rindex)
--530-- REDIR: 0x57ea180 (libc.so.6:malloc) redirected to 0x4c2db20 (malloc)
--530-- REDIR: 0x57f17a0 (libc.so.6:strlen) redirected to 0x4c30f60 (strlen)
--530-- REDIR: 0x50fea30 (libstdc++.so.6:operator new(unsigned long)) redirected to 0x4c2e080 (operator new(unsigned long))
--530-- REDIR: 0x57fa470 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--530-- REDIR: 0x58b3fa0 (libc.so.6:__memcpy_avx_unaligned) redirected to 0x4c324a0 (memcpy@@GLIBC_2.14)
--530-- REDIR: 0x57f5230 (libc.so.6:memset) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--530-- REDIR: 0x58d8a70 (libc.so.6:__memset_avx2) redirected to 0x4c344c0 (memset)
--530-- REDIR: 0x57f5430 (libc.so.6:__GI_mempcpy) redirected to 0x4c34fa0 (__GI_mempcpy)
--530-- REDIR: 0x57f1bf0 (libc.so.6:__GI_strncmp) redirected to 0x4c31710 (__GI_strncmp)
--530-- REDIR: 0x57f46b0 (libc.so.6:strstr) redirected to 0x4a286f0 (_vgnU_ifunc_wrapper)
--530-- REDIR: 0x58100f0 (libc.so.6:__strstr_sse2_unaligned) redirected to 0x4c35460 (strstr)
--530-- REDIR: 0x57f48e0 (libc.so.6:memchr) redirected to 0x4c32170 (memchr)
--530-- REDIR: 0x57ea540 (libc.so.6:free) redirected to 0x4c2ed80 (free)
--530-- REDIR: 0x57fa4f0 (libc.so.6:__GI_memcpy) redirected to 0x4c32b00 (__GI_memcpy)
--530-- REDIR: 0x58b3ab0 (libc.so.6:__memmove_avx_unaligned) redirected to 0x4c32230 (memcpy@GLIBC_2.2.5)
[2021-06-03 17:06:41.604] [info] Welcome to spdlog version 1.8.5 !
[2021-06-03 17:06:41.680] [warning] Easy padding in numbers like 00000012
[2021-06-03 17:06:41.700] [critical] Support for int: 42; hex: 2a; oct: 52; bin: 101010
[2021-06-03 17:06:41.727] [info] Support for floats 1.23
[2021-06-03 17:06:41.736] [info] Positional args are supported too..
[2021-06-03 17:06:41.748] [info] right aligned, left aligned
[2021-06-03 17:06:41.756] [debug] This message should be displayed..
--530-- REDIR: 0x50fcdc0 (libstdc++.so.6:operator delete(void*)) redirected to 0x4c2f1e0 (operator delete(void*))
[17:06:41 +00:00] [I] [thread 530] This an info message with custom format
[2021-06-03 17:06:41.917] [info] ****************** Backtrace Start ******************
[2021-06-03 17:06:41.915] [debug] Backtrace message 90
[2021-06-03 17:06:41.915] [debug] Backtrace message 91
[2021-06-03 17:06:41.915] [debug] Backtrace message 92
[2021-06-03 17:06:41.915] [debug] Backtrace message 93
[2021-06-03 17:06:41.915] [debug] Backtrace message 94
[2021-06-03 17:06:41.915] [debug] Backtrace message 95
[2021-06-03 17:06:41.916] [debug] Backtrace message 96
[2021-06-03 17:06:41.916] [debug] Backtrace message 97
[2021-06-03 17:06:41.916] [debug] Backtrace message 98
[2021-06-03 17:06:41.916] [debug] Backtrace message 99
[2021-06-03 17:06:41.927] [info] ****************** Backtrace End ********************
--530-- REDIR: 0x57f40e0 (libc.so.6:__GI_strstr) redirected to 0x4c354d0 (__strstr_sse2)
--530-- REDIR: 0x57ead80 (libc.so.6:calloc) redirected to 0x4c2faa0 (calloc)
==530== Thread 2:
==530== Use of uninitialised value of size 8
==530== at 0x5127DCA: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.29)
==530== by 0x4E416B9: start_thread (pthread_create.c:333)
==530== by 0x586D51C: clone (clone.S:109)
==530== Uninitialised value was created by a stack allocation
==530== at 0x40B8A0: ??? (in /tmp/bin/foobar_cpp_libstdcpp)
==530==
==530== Invalid read of size 8
==530== at 0x5127DCA: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.29)
==530== by 0x4E416B9: start_thread (pthread_create.c:333)
==530== by 0x586D51C: clone (clone.S:109)
==530== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==530==
==530==
==530== Process terminating with default action of signal 11 (SIGSEGV)
==530== Access not within mapped region at address 0x0
==530== at 0x5127DCA: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.29)
==530== by 0x4E416B9: start_thread (pthread_create.c:333)
==530== by 0x586D51C: clone (clone.S:109)
==530== If you believe this happened as a result of a stack
==530== overflow in your program's main thread (unlikely but
==530== possible), you can try to increase the size of the
==530== main thread stack using the --main-stacksize= flag.
==530== The main thread stack size used in this run was 8388608.
==530==
==530== HEAP SUMMARY:
==530== in use at exit: 3,446,954 bytes in 86 blocks
==530== total heap usage: 205 allocs, 119 frees, 3,455,945 bytes allocated
==530==
==530== Searching for pointers to 86 not-freed blocks
==530== Checked 11,949,408 bytes
==530==
==530== LEAK SUMMARY:
==530== definitely lost: 0 bytes in 0 blocks
==530== indirectly lost: 0 bytes in 0 blocks
==530== possibly lost: 304 bytes in 1 blocks
==530== still reachable: 3,446,650 bytes in 85 blocks
==530== of which reachable via heuristic:
==530== stdstring : 978 bytes in 29 blocks
==530== suppressed: 0 bytes in 0 blocks
==530== Rerun with --leak-check=full to see details of leaked memory
==530==
==530== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
==530==
==530== 1 errors in context 1 of 2:
==530== Invalid read of size 8
==530== at 0x5127DCA: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.29)
==530== by 0x4E416B9: start_thread (pthread_create.c:333)
==530== by 0x586D51C: clone (clone.S:109)
==530== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==530==
==530==
==530== 1 errors in context 2 of 2:
==530== Use of uninitialised value of size 8
==530== at 0x5127DCA: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.29)
==530== by 0x4E416B9: start_thread (pthread_create.c:333)
==530== by 0x586D51C: clone (clone.S:109)
==530== Uninitialised value was created by a stack allocation
==530== at 0x40B8A0: ??? (in /tmp/bin/foobar_cpp_libstdcpp)
==530==
==530== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Killed
root@2a0a244cef6f:/tmp/bin#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment