NetBSD Problem Report #48616

From gson@gson.org  Tue Feb 25 08:26:05 2014
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 94118A583A
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 25 Feb 2014 08:26:05 +0000 (UTC)
Message-Id: <20140225082601.A6E8775E3A@guava.gson.org>
Date: Tue, 25 Feb 2014 10:26:01 +0200 (EET)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@gnats.NetBSD.org
Subject: ld.elf_so errno causes confusing gdb output
X-Send-Pr-Version: 3.95

>Number:         48616
>Category:       bin
>Synopsis:       ld.elf_so errno causes confusing gdb output
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 25 08:30:00 +0000 2014
>Closed-Date:    Sun Jun 18 20:26:17 +0000 2017
>Last-Modified:  Sun Jun 18 20:26:17 +0000 2017
>Originator:     Andreas Gustafsson
>Release:        6.1.3
>Organization:
>Environment:
System: NetBSD
Architecture: i386
Machine: i386
>Description:

libc and ld.elf_so both contain a variable called "errno".  If you
debug an ordinary single-threaded dynamically linked program using gdb
and enter "print errno", gdb prints the ld.elf_so errno, which is
confusing for the user who was probably more interested in the libc
one.

>How-To-Repeat:

cat >testcase.c <<EOF
#include <errno.h>
#include <stdlib.h>
int main(int argc, char **argv) {
    errno = 42;
    abort();
    return 0;
}
EOF
cat >test.gdb <<EOF
run
print errno
info variables ^errno$
EOF
cc -g testcase.c -o testcase
gdb --batch -x test.gdb ./testcase

This will output "$1 = 2" rather than the expected "$1 = 42", and the
"info variables" command shows two errno variables at different
addresses:

  0x00007f7ff7e13830  errno
  0x00007f7ff7b3a704  errno

>Fix:

Perhaps rename the ld.elf_so errno?

>Release-Note:

>Audit-Trail:
From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/48616: ld.elf_so errno causes confusing gdb output
Date: Sat, 17 Jun 2017 20:35:10 +0000

 Your test is no longer failure. I'm not sure what changed, though.

From: Andreas Gustafsson <gson@gson.org>
To: coypu@sdf.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: bin/48616: ld.elf_so errno causes confusing gdb output
Date: Sun, 18 Jun 2017 00:03:27 +0300

 coypu@sdf.org wrote:
 >  Your test is no longer failure.

 Indeed, it now prints the correct "42" in -current.

 > I'm not sure what changed, though.

 I'll run a bisection to see what fixed it.
 -- 
 Andreas Gustafsson, gson@gson.org

From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48616: ld.elf_so errno causes confusing gdb output
Date: Sat, 17 Jun 2017 23:20:04 +0200

 On Sat, Jun 17, 2017 at 09:05:00PM +0000, Andreas Gustafsson wrote:
 > The following reply was made to PR bin/48616; it has been noted by GNATS.
 > 
 > From: Andreas Gustafsson <gson@gson.org>
 > To: coypu@sdf.org
 > Cc: gnats-bugs@NetBSD.org
 > Subject: Re: bin/48616: ld.elf_so errno causes confusing gdb output
 > Date: Sun, 18 Jun 2017 00:03:27 +0300
 > 
 >  coypu@sdf.org wrote:
 >  >  Your test is no longer failure.
 >  
 >  Indeed, it now prints the correct "42" in -current.
 >  
 >  > I'm not sure what changed, though.
 >  
 >  I'll run a bisection to see what fixed it.

 Most likely revision 1.136 of src/libexec/ld.elf_so/Makefile.

 Joerg

From: Andreas Gustafsson <gson@gson.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48616: ld.elf_so errno causes confusing gdb output
Date: Sun, 18 Jun 2017 23:14:56 +0300

 Joerg Sonnenberger wrote:
 >  Most likely revision 1.136 of src/libexec/ld.elf_so/Makefile.

 Confirmed by the bisection.  Thank you for the fix!
 -- 
 Andreas Gustafsson, gson@gson.org

State-Changed-From-To: open->closed
State-Changed-By: gson@NetBSD.org
State-Changed-When: Sun, 18 Jun 2017 20:26:17 +0000
State-Changed-Why:
Confirmed fixed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.