Processed: Re: Bug#1012311: libc6: invalid debug symbol for optind

2022-06-10 Thread Debian Bug Tracking System
Processing control commands:

> reassign -1 gdb
Bug #1012311 [libc6] libc6: invalid debug symbol for optind
Bug reassigned from package 'libc6' to 'gdb'.
No longer marked as found in versions glibc/2.31-13+deb11u3.
Ignoring request to alter fixed versions of bug #1012311 to the same values 
previously set
> found -1 gdb/10.1-1.7
Bug #1012311 [gdb] libc6: invalid debug symbol for optind
Marked as found in versions gdb/10.1-1.7.
> found -1 gdb/11.2-1
Bug #1012311 [gdb] libc6: invalid debug symbol for optind
Marked as found in versions gdb/11.2-1.
> affects -1 gdb
Bug #1012311 [gdb] libc6: invalid debug symbol for optind
Added indication that 1012311 affects gdb

-- 
1012311: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1012311
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



Bug#1012311: libc6: invalid debug symbol for optind

2022-06-10 Thread Aurelien Jarno
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 
> 
> 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 *) 0x77fa1344 
> (gdb) disassemble 
> Dump of assembler code for function main:
>0x5125 <+0>:   push   %rbp
>0x5126 <+1>:   mov%rsp,%rbp
>0x5129 <+4>:   movl   $0x2,0x2ef5(%rip)# 
> 0x8028 
>0x5133 <+14>:  mov$0x0,%eax
> => 0x5138 <+19>:  pop%rbp
>0x5139 <+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 (0x77fa1344 vs 0x8028).

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
aurel...@aurel32.net http://www.aurel32.net



Bug#1012311: libc6: invalid debug symbol for optind

2022-06-03 Thread Mathis MARION
Package: libc6
Version: 2.31-13+deb11u3
Severity: normal

Dear Maintainer,

Here is a simple example program:


#include 

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 *) 0x77fa1344 
(gdb) disassemble 
Dump of assembler code for function main:
   0x5125 <+0>: push   %rbp
   0x5126 <+1>: mov%rsp,%rbp
   0x5129 <+4>: movl   $0x2,0x2ef5(%rip)# 
0x8028 
   0x5133 <+14>:mov$0x0,%eax
=> 0x5138 <+19>:pop%rbp
   0x5139 <+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 (0x77fa1344 vs 0x8028).

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.

I originally made the silly mistake of believing that 'optind' provided the
index of the current option being processed, while it actually contains the next
option to be processed. When debugging, gdb would show me a value of 1 in optind
(as I wrongly expected) instead of the real value of 3, which led to a difficult
debugging experience.

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.

-- System Information:
Debian Release: 11.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 
'stable-debug'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.16.0-0.bpo.4-amd64 (SMP w/12 CPU threads; PREEMPT)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libc6 depends on:
ii  libcrypt1  1:4.4.18-4
ii  libgcc-s1  10.2.1-6

Versions of packages libc6 recommends:
ii  libidn2-0   2.3.0-5
pn  libnss-nis  
pn  libnss-nisplus  

Versions of packages libc6 suggests:
ii  debconf [debconf-2.0]  1.5.77
pn  glibc-doc  
ii  libc-l10n  2.31-13+deb11u3
ii  locales2.31-13+deb11u3

-- debconf information:
  glibc/kernel-not-supported:
  glibc/disable-screensaver:
  glibc/upgrade: true
  glibc/restart-services:
  libraries/restart-without-asking: false
  glibc/kernel-too-old:
  glibc/restart-failed: