[Bug 2089693] [NEW] Division by 0 in GDB when printing std::string with custom TBB memory allocator
Stéphane Perras
2089693 at bugs.launchpad.net
Tue Nov 26 16:22:21 UTC 2024
Public bug reported:
I wrote a simple C++ application that links with TBB::tbbmalloc. I have
defined a class called TBBAllocator that implements the std::allocator
archetype, and that calls TBB's scalable_malloc and scalable_free to
deal with memory allocations. Then I have instantiated a
std::string<char, char_traits<char>, TBBAllocator>> local variable named
'str', initialized it with "Hello World", and output it through cout.
Given you build the executable with debug information, if you put a
breakpoint on the "cout << str" line and break in gdb, and try to print
the string's value with the command "p str", GDB crashes on a "floating
point exception", but that is really a division by 0 happening in a
function named "val_print_string" in GDB.
If I download GDB 12.1 source code and build it manually, it fixes the
issue. The "p str" command completes successfully and prints all the
fields of the std::string.
If I install GDB from sources using apt, the crash remains, and it is
possible to launch GDB on a second instance of GDB which then debugs the
sample program.
# lsb_release -rd
Description: Ubuntu 22.04.5 LTS
Release: 22.04
# apt-cache policy gdb
gdb:
Installed: 12.1-0ubuntu1~22.04.2
Candidate: 12.1-0ubuntu1~22.04.2
Version table:
*** 12.1-0ubuntu1~22.04.2 500
500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
100 /var/lib/dpkg/status
12.0.90-0ubuntu1 500
500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
# apt-cache policy gcc
gcc:
Installed: 4:11.2.0-1ubuntu1
Candidate: 4:11.2.0-1ubuntu1
Version table:
*** 4:11.2.0-1ubuntu1 500
500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
100 /var/lib/dpkg/status
# apt-cache policy libtbb12
libtbb12:
Installed: 2021.5.0-7ubuntu2
Candidate: 2021.5.0-7ubuntu2
Version table:
*** 2021.5.0-7ubuntu2 500
500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
100 /var/lib/dpkg/status
# apt-cache policy libtbbmalloc2
libtbbmalloc2:
Installed: 2021.5.0-7ubuntu2
Candidate: 2021.5.0-7ubuntu2
Version table:
*** 2021.5.0-7ubuntu2 500
500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
100 /var/lib/dpkg/status
# apt-cache policy libtbb-dev
libtbb-dev:
Installed: 2021.5.0-7ubuntu2
Candidate: 2021.5.0-7ubuntu2
Version table:
*** 2021.5.0-7ubuntu2 500
500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
100 /var/lib/dpkg/status
ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: gdb 12.1-0ubuntu1~22.04.2
ProcVersionSignature: Ubuntu 5.15.0-126.136-generic 5.15.167
Uname: Linux 5.15.0-126-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.6
Architecture: amd64
CasperMD5CheckResult: unknown
Date: Tue Nov 26 15:42:56 2024
ProcEnviron:
TERM=xterm
LD_LIBRARY_PATH=<set>
PATH=(custom, user)
RebootRequiredPkgs: Error: path contained symlinks.
SourcePackage: gdb
UpgradeStatus: No upgrade log present (probably fresh install)
** Affects: gdb (Ubuntu)
Importance: Undecided
Status: New
** Tags: amd64 apport-bug jammy
** Attachment added: "gdbtestcrash.cpp"
https://bugs.launchpad.net/bugs/2089693/+attachment/5840595/+files/gdbtestcrash.cpp
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gdb in Ubuntu.
https://bugs.launchpad.net/bugs/2089693
Title:
Division by 0 in GDB when printing std::string with custom TBB memory
allocator
Status in gdb package in Ubuntu:
New
Bug description:
I wrote a simple C++ application that links with TBB::tbbmalloc. I
have defined a class called TBBAllocator that implements the
std::allocator archetype, and that calls TBB's scalable_malloc and
scalable_free to deal with memory allocations. Then I have
instantiated a std::string<char, char_traits<char>, TBBAllocator>>
local variable named 'str', initialized it with "Hello World", and
output it through cout. Given you build the executable with debug
information, if you put a breakpoint on the "cout << str" line and
break in gdb, and try to print the string's value with the command "p
str", GDB crashes on a "floating point exception", but that is really
a division by 0 happening in a function named "val_print_string" in
GDB.
If I download GDB 12.1 source code and build it manually, it fixes the
issue. The "p str" command completes successfully and prints all the
fields of the std::string.
If I install GDB from sources using apt, the crash remains, and it is
possible to launch GDB on a second instance of GDB which then debugs
the sample program.
# lsb_release -rd
Description: Ubuntu 22.04.5 LTS
Release: 22.04
# apt-cache policy gdb
gdb:
Installed: 12.1-0ubuntu1~22.04.2
Candidate: 12.1-0ubuntu1~22.04.2
Version table:
*** 12.1-0ubuntu1~22.04.2 500
500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
100 /var/lib/dpkg/status
12.0.90-0ubuntu1 500
500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
# apt-cache policy gcc
gcc:
Installed: 4:11.2.0-1ubuntu1
Candidate: 4:11.2.0-1ubuntu1
Version table:
*** 4:11.2.0-1ubuntu1 500
500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
100 /var/lib/dpkg/status
# apt-cache policy libtbb12
libtbb12:
Installed: 2021.5.0-7ubuntu2
Candidate: 2021.5.0-7ubuntu2
Version table:
*** 2021.5.0-7ubuntu2 500
500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
100 /var/lib/dpkg/status
# apt-cache policy libtbbmalloc2
libtbbmalloc2:
Installed: 2021.5.0-7ubuntu2
Candidate: 2021.5.0-7ubuntu2
Version table:
*** 2021.5.0-7ubuntu2 500
500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
100 /var/lib/dpkg/status
# apt-cache policy libtbb-dev
libtbb-dev:
Installed: 2021.5.0-7ubuntu2
Candidate: 2021.5.0-7ubuntu2
Version table:
*** 2021.5.0-7ubuntu2 500
500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
100 /var/lib/dpkg/status
ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: gdb 12.1-0ubuntu1~22.04.2
ProcVersionSignature: Ubuntu 5.15.0-126.136-generic 5.15.167
Uname: Linux 5.15.0-126-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.6
Architecture: amd64
CasperMD5CheckResult: unknown
Date: Tue Nov 26 15:42:56 2024
ProcEnviron:
TERM=xterm
LD_LIBRARY_PATH=<set>
PATH=(custom, user)
RebootRequiredPkgs: Error: path contained symlinks.
SourcePackage: gdb
UpgradeStatus: No upgrade log present (probably fresh install)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/2089693/+subscriptions
More information about the foundations-bugs
mailing list