[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1012311: libc6: invalid debug symbol for optind



control: reassign -1 gdb
control: found -1 gdb/10.1-1.7
control: found -1 gdb/11.2-1
control: affects -1 gdb

Hi,

On 2022-06-03 18:34, Mathis MARION wrote:
> Package: libc6
> Version: 2.31-13+deb11u3
> Severity: normal
> 
> Dear Maintainer,
> 
> Here is a simple example program:
> 
> 
> #include <unistd.h>
> 
> int main()
> {
>     optind = 2;
> }
> 
> 
> I compiled it with 'gcc -g -O0' and ran it through gdb:
> 
> 
> (gdb) b main
> Breakpoint 1 at 0x1129: file main.c, line 5.
> (gdb) r
> Starting program: /home/marionm/test/optind/a.out 
> 
> Breakpoint 1, main () at main.c:5
> 5		optind = 2;
> (gdb) n
> 6	}
> (gdb) p optind
> $1 = 1
> (gdb) p &optind
> $2 = (int *) 0x7ffff7fa1344 <optind>
> (gdb) disassemble 
> Dump of assembler code for function main:
>    0x0000555555555125 <+0>:	push   %rbp
>    0x0000555555555126 <+1>:	mov    %rsp,%rbp
>    0x0000555555555129 <+4>:	movl   $0x2,0x2ef5(%rip)        # 0x555555558028 <optind@GLIBC_2.2.5>
>    0x0000555555555133 <+14>:	mov    $0x0,%eax
> => 0x0000555555555138 <+19>:	pop    %rbp
>    0x0000555555555139 <+20>:	ret    
> End of assembler dump.
> (gdb) 
> 
> 
> We can see that the address used by GDB when accessing 'optind' is not the same
> as the one present in the assembly code (0x7ffff7fa1344 vs 0x555555558028).

I confirm the issue.

> When running this experiment on Debian with the packaged gdb version 10 and 11,
> we get the unexpected behavior described above. The same test run on Fedora with
> gdb version 12 results in the expected behavior of seeing the same address on
> both sides.

The problem is reproducible on Debian and Fedora with both version 10
and 11, but not with GDB version 12, so it seems that the problem has
been fixed in that version.

> This issue might also be caused by gdb instead of libc but I don't have
> a deep enough understanding of the problem to ensure one or the other.

This definitely seems a problem with GDB, which appears to be fixed with
GDB 12. Reassigning the bug.

Regards
Aurelien

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net


Reply to: