[Bug libc/31730] New: backtrace_symbols_fd prints different strings than backtrace_symbols returns
bruno at clisp dot org
sourceware-bugzilla@sourceware.org
Sun May 12 13:50:01 GMT 2024
https://sourceware.org/bugzilla/show_bug.cgi?id=31730
Bug ID: 31730
Summary: backtrace_symbols_fd prints different strings than
backtrace_symbols returns
Product: glibc
Version: 2.39
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: bruno at clisp dot org
CC: drepper.fsp at gmail dot com
Target Milestone: ---
Created attachment 15516
--> https://sourceware.org/bugzilla/attachment.cgi?id=15516&action=edit
test case foo.c
The documentation of backtrace_symbols_fd in
https://www.gnu.org/software/libc/manual/html_node/Backtraces.html says: "The
backtrace_symbols_fd function performs the same translation as the function
backtrace_symbols function. Instead of returning the strings to the caller, it
writes the strings to the file descriptor fd, one per line."
But in glibc 2.39, it prints different strings.
How to reproduce:
============================= foo.c =============================
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
static void
test_backtrace (void)
{
void *buffer[10];
int size;
char **symbols;
size = backtrace (buffer, 10);
backtrace_symbols_fd (buffer, size, 1);
printf ("\n");
symbols = backtrace_symbols (buffer, size);
if (symbols != NULL)
{
for (int i = 0; i < size; ++i)
printf ("%s\n", symbols[i]);
free (symbols);
}
}
int
main (void)
{
test_backtrace ();
}
================================================================
$ gcc -Wall foo.c
$ ./a.out
./a.out[0x40118f]
./a.out[0x40121a]
/lib64/libc.so.6(+0x2a088)[0x7fc7bf945088]
/lib64/libc.so.6(__libc_start_main+0x8b)[0x7fc7bf94514b]
./a.out[0x4010b5]
./a.out() [0x40118f]
./a.out() [0x40121a]
/lib64/libc.so.6(+0x2a088) [0x7fc7bf945088]
/lib64/libc.so.6(__libc_start_main+0x8b) [0x7fc7bf94514b]
./a.out() [0x4010b5]
As you can see, the strings printed by backtrace_symbols_fd lack
1. a substring "()" when the offset is not known,
2. a space before the '[' character.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list