NetBSD Problem Report #43801

From www@NetBSD.org  Thu Aug 26 13:17:57 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 6352963BC3B
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 26 Aug 2010 13:17:57 +0000 (UTC)
Message-Id: <20100826131757.2DAE563BC38@www.NetBSD.org>
Date: Thu, 26 Aug 2010 13:17:57 +0000 (UTC)
From: yhl@cpm.com.my
Reply-To: yhl@cpm.com.my
To: gnats-bugs@NetBSD.org
Subject: Statically linked program that calls atomic_cas_ulong crashes with segmentation fault
X-Send-Pr-Version: www-1.0

>Number:         43801
>Category:       port-evbarm
>Synopsis:       Statically linked program that calls atomic_cas_ulong crashes with segmentation fault
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-evbarm-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 26 13:20:01 +0000 2010
>Closed-Date:    Sat Dec 19 02:52:31 +0000 2015
>Last-Modified:  Sat Dec 19 02:52:31 +0000 2015
>Originator:     Y H Loke
>Release:        NetBSD 5.0.2
>Organization:
Computer Protocol Malaysia
>Environment:
NetBSD eufo 5.0.2 NetBSD 5.0.2 (TS7200) #0: Sat Feb  6 15:25:19 UTC 2010  builds@b8.netbsd.org:/home/builds/ab/
netbsd-5-0-2-RELEASE/evbarm/201002061851Z-obj/home/builds/ab/netbsd-5-0-2-RELEASE/src/sys/arch/evbarm/compile/T
S7200 evbarm
>Description:
=== Makefile ===
PROG=atomic_cas
NOMAN=1
LDSTATIC=       -static
CFLAGS+=        -g

.include <bsd.prog.mk>
=== atomic_cas C program ===
#include <stdio.h>
#include <atomic.h>

int main()
{
    unsigned long ul, old, new;

    ul = 3; old = 1; new = 2;
    printf("atomic_cas_ulong=%lu\n", atomic_cas_ulong(&ul, old, new));
    return 0;
}
===
When the above C program is built and then executed, it crashes with segmentation fault. If it is build with LDSTATIC commented out, it runs fine to completion.

This problem is also causing statically linked pthreads programs to crash at start up.

>How-To-Repeat:
This problem occurs on a TS7250 board purchased from http://www.embeddedarm.com/products/board-detail.php?product=TS-7250

>Fix:
I don't know how to fix it because I don't have enough knowledge on NetBSD linker and how atomic library works.

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-evbarm/43801: Statically linked program that calls atomic_cas_ulong crashes with segmentation fault
Date: Thu, 26 Aug 2010 15:49:57 +0200

 FWIW: I can reproduce it on some slightly aged netbsd-5 shark, but it seems
 to be fixed in -current.

 Martin

From: "YoonHoe LOKE" <yhl@cpm.com.my>
To: <gnats-bugs@NetBSD.org>, <port-evbarm-maintainer@NetBSD.org>,
        <gnats-admin@NetBSD.org>, <netbsd-bugs@NetBSD.org>
Cc: 
Subject: RE: port-evbarm/43801: Statically linked program that calls atomic_cas_ulong crashes with segmentation fault
Date: Sat, 4 Sep 2010 16:59:28 +0800

 I've found the fix in the netbsd cvs at
 http://cvsweb.netbsd.org/bsdweb.cgi/src/common/lib/libc/atomic/atomic_ini=
 t_t
 estset.c?only_with_tag=3DMAIN

 I pulled up atomic_init_testset.c to 1.7 trunk, rebuilt and statically
 linked program that calls atomic_cas_ulong worked after applying the =
 update.
 =20
 The fix hit the CVS on 30 Jan 2009 ! How I wish someone had pulled it up =
 to
 netbsd5. Can someone please pull it up to 5.1 ?

 For statically linked pthreads to work,
 http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=3D37454 may =
 need to
 be pulled up to 5.1 too.

 Thanks Martin for the clue that it's been fixed in current.

 YH Loke

 -----Original Message-----
 From: Martin Husemann [mailto:martin@duskware.de]=20
 Sent: Thursday, 26 August 2010 9:50 PM
 To: port-evbarm-maintainer@NetBSD.org; gnats-admin@NetBSD.org;
 netbsd-bugs@NetBSD.org; yhl@cpm.com.my
 Subject: Re: port-evbarm/43801: Statically linked program that calls
 atomic_cas_ulong crashes with segmentation fault


 The following reply was made to PR port-evbarm/43801; it has been noted =
 by
 GNATS.

 From: Martin Husemann <martin@duskware.de>
 To: gnats-bugs@NetBSD.org
 Cc:=20
 Subject: Re: port-evbarm/43801: Statically linked program that calls
 atomic_cas_ulong crashes with segmentation fault
 Date: Thu, 26 Aug 2010 15:49:57 +0200

  FWIW: I can reproduce it on some slightly aged netbsd-5 shark, but it =
 seems
 to be fixed in -current.
 =20
  Martin
 =20

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 19 Dec 2015 02:52:31 +0000
State-Changed-Why:
netbsd-5 is now EOL


>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-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.