NetBSD Problem Report #49333

From he@smistad.uninett.no  Wed Oct 29 10:25:39 2014
Return-Path: <he@smistad.uninett.no>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 6E725A669A
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 29 Oct 2014 10:25:39 +0000 (UTC)
Message-Id: <20141029102533.6FEB33D0B5@smistad.uninett.no>
Date: Wed, 29 Oct 2014 11:25:33 +0100 (CET)
From: he@NetBSD.org
Reply-To: he@NetBSD.org
To: gnats-bugs@gnats.NetBSD.org
Subject: libgpg-error 1.15 may cause apache and php to segfault
X-Send-Pr-Version: 3.95

>Number:         49333
>Category:       pkg
>Synopsis:       libgpg-error 1.15 may cause apache and php to segfault
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 29 10:30:00 +0000 2014
>Closed-Date:    Wed Oct 29 14:38:19 +0000 2014
>Last-Modified:  Wed Oct 29 20:15:01 +0000 2014
>Originator:     Havard Eidnes
>Release:        NetBSD 6.1_STABLE
>Organization:
	None
>Environment:
System: NetBSD smistad.uninett.no 6.1_STABLE NetBSD 6.1_STABLE (MAANEN) #0: Mon Sep 1 14:42:18 CEST 2014 root@smistad.uninett.no:/usr/obj/sys/arch/i386/compile/MAANEN i386
Architecture: i386
Machine: i386
>Description:
	libgpg-error at least in version 1.15 makes use of atexit() to
	flush its error stream (it seems).

	However, libgpg-error ends up being used as a dynamically
	loaded library in several circumstances, two examples I've
	come across are php and apache.  These programs tend to do
	dlclose() on its libraries before they do exit(), cauisng the
	latter's atexit handling to try to call into now invalidated
	address space, causing a segfault.

>How-To-Repeat:
	Make use of modules which cause libgpg-error to be loaded in
	php and/or apache, and see php segfault on exit, or get
	occasional segfaults from apache processes when they exit.

>Fix:
	This is probably the wrong fix (is there a right one?), but to
	stop the segfaults from happening, I've added this local patch:

$NetBSD$

Avoid this library causing segfaults in apache and php,
since these can unload the libgpg-error library before doing exit().

--- src/estream.c.orig  2014-09-11 09:38:21.000000000 +0000
+++ src/estream.c
@@ -503,7 +503,9 @@ _gpgrt_es_init (void)
   if (!initialized)
     {
       initialized = 1;
+#if 0  /* May be unloaded as a library before exit() is called... */
       atexit (do_deinit);
+#endif
     }
   return 0;
 }

>Release-Note:

>Audit-Trail:
From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/49333: libgpg-error 1.15 may cause apache and php to segfault
Date: Wed, 29 Oct 2014 11:38:24 +0100

 On Wed, Oct 29, 2014 at 10:30:00AM +0000, he@NetBSD.org wrote:
 > 	This is probably the wrong fix (is there a right one?), but to
 > 	stop the segfaults from happening, I've added this local patch:

 Mark do_deinit as destructor via attribute.

 Joerg

From: "Havard Eidnes" <he@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49333 CVS commit: pkgsrc/security/libgpg-error
Date: Wed, 29 Oct 2014 12:28:50 +0000

 Module Name:	pkgsrc
 Committed By:	he
 Date:		Wed Oct 29 12:28:50 UTC 2014

 Modified Files:
 	pkgsrc/security/libgpg-error: Makefile distinfo
 Added Files:
 	pkgsrc/security/libgpg-error/patches: patch-src_estream.c

 Log Message:
 Use __attribute__((destructor)) instead of atexit(), so that the
 library wind-down function is both called on dlclose() and exit().
 Should avoid segfault when trying to call the atexit function after
 dlclose() which unmaps the library.  Fixes PR pkg/49333, thanks to
 joerg@ for the suggested fix.

 Also, the IRIX and NetBSD tool name to get at nawk is just "awk",
 flagged by pkglint.

 Bump PKGREVISION.


 To generate a diff of this commit:
 cvs rdiff -u -r1.43 -r1.44 pkgsrc/security/libgpg-error/Makefile
 cvs rdiff -u -r1.20 -r1.21 pkgsrc/security/libgpg-error/distinfo
 cvs rdiff -u -r0 -r1.1 \
     pkgsrc/security/libgpg-error/patches/patch-src_estream.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: he@NetBSD.org
State-Changed-When: Wed, 29 Oct 2014 14:38:19 +0000
State-Changed-Why:
A fix was committed which should fix this problem.


From: "Matthias Scheler" <tron@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49333 CVS commit: [pkgsrc-2014Q3] pkgsrc/security/libgpg-error
Date: Wed, 29 Oct 2014 20:11:31 +0000

 Module Name:	pkgsrc
 Committed By:	tron
 Date:		Wed Oct 29 20:11:31 UTC 2014

 Modified Files:
 	pkgsrc/security/libgpg-error [pkgsrc-2014Q3]: Makefile distinfo
 Added Files:
 	pkgsrc/security/libgpg-error/patches [pkgsrc-2014Q3]:
 	    patch-src_estream.c

 Log Message:
 Pullup ticket #4531 - requested by he
 security/libgpg-error: bug fix patch

 Revisions pulled up:
 - security/libgpg-error/Makefile                                1.44 via patch
 - security/libgpg-error/distinfo                                1.21 via patch
 - security/libgpg-error/patches/patch-src_estream.c             1.1

 ---
    Module Name:	pkgsrc
    Committed By:	he
    Date:		Wed Oct 29 12:28:50 UTC 2014

    Modified Files:
    	pkgsrc/security/libgpg-error: Makefile distinfo
    Added Files:
    	pkgsrc/security/libgpg-error/patches: patch-src_estream.c

    Log Message:
    Use __attribute__((destructor)) instead of atexit(), so that the
    library wind-down function is both called on dlclose() and exit().
    Should avoid segfault when trying to call the atexit function after
    dlclose() which unmaps the library.  Fixes PR pkg/49333, thanks to
    joerg@ for the suggested fix.

    Also, the IRIX and NetBSD tool name to get at nawk is just "awk",
    flagged by pkglint.

    Bump PKGREVISION.


 To generate a diff of this commit:
 cvs rdiff -u -r1.40 -r1.40.2.1 pkgsrc/security/libgpg-error/Makefile
 cvs rdiff -u -r1.18 -r1.18.2.1 pkgsrc/security/libgpg-error/distinfo
 cvs rdiff -u -r0 -r1.1.2.2 \
     pkgsrc/security/libgpg-error/patches/patch-src_estream.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>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.