NetBSD Problem Report #8463

Received: (qmail 12447 invoked from network); 21 Sep 1999 11:26:27 -0000
Message-Id: <199909211126.XAA21605@city-art.mcs.vuw.ac.nz>
Date: Tue, 21 Sep 1999 23:26:22 +1200 (NZST)
From: Mark Davies <mark@MCS.VUW.AC.NZ>
Reply-To: mark@MCS.VUW.AC.NZ
To: gnats-bugs@gnats.netbsd.org
Subject: problem with construtors for globals in shared libraries
X-Send-Pr-Version: 3.95

>Number:         8463
>Category:       port-i386
>Synopsis:       Constructors not run for globals in shared libraries
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-i386-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 21 04:35:01 +0000 1999
>Closed-Date:    Fri Mar 01 11:17:58 +0000 2002
>Last-Modified:  Fri Mar 01 11:17:58 +0000 2002
>Originator:     Mark Davies
>Release:        1.4.1
>Organization:
Comp. Sci., Victoria Uni. of Wellington, New Zealand.
>Environment:

System: NetBSD city-art.mcs.vuw.ac.nz 1.4.1 NetBSD 1.4.1 (MCS_WORKSTATION) #0: Thu Sep 2 16:42:54 PDT 1999 root@pigeon:/usr/src/sys/arch/i386/compile/MCS_WORKSTATION i386


>Description:
	Global variables that need constructers, declared in shared libraries,
	fail to have the constructer run on program startup causing seg faults
	when the variable is referenced.

	This was noticed building KDE-1.1.2.  The application "kab" core dumps
	at the following point:

int main(int argc, char** argv)
{
  register bool GUARD; GUARD=true;
  LG(GUARD, "addressbook main: starting.\n");
  // ########################################################  
  KApplication *app=new KApplication(argc, argv, "kab");
  int rc;
  // -----
  AuthorEmailAddress="mirko@kde.org"; // static, public  <<< Core dumps here

Core dumps as "AuthorEmailAddress" has not had its constructor applied so
dereferences a NULL pointer.
"AuthorEmailAddress" is declared as a global in "libkab" as follows:

	string AuthorEmailAddress;

Moving this declaration into the program source (rather than the library) fixes
the problem, as does building the library statically.


>How-To-Repeat:
	Build a shared library that declares a global that requires a C++
constructor to initialise then reference it from a sample program.

>Fix:
	My workaround at the moment is to build the library static :-(


cheers
mark
>Release-Note:
>Audit-Trail:

From: Mark Davies <mark@MCS.VUW.AC.NZ>
To: gnats-bugs@netbsd.org
Cc:  Subject: port-i386/8463
Date: Thu, 21 Oct 1999 14:46:03 +1300

 This problem doesn't occur with current so I presume its an a.out problem and 
 with the move to elf may not be worth trying to fix.

 cheers
 mark


State-Changed-From-To: open->feedback 
State-Changed-By: fair 
State-Changed-When: Sun Jan 20 03:05:25 PST 2002 
State-Changed-Why:  
Submitter reported some time ago that this problem was resolved... 
State-Changed-From-To: feedback->closed 
State-Changed-By: markd 
State-Changed-When: Fri Mar 1 03:16:33 PST 2002 
State-Changed-Why:  
Definitely this was an a.out problem so doesn't apply on current (or 1.5). 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.