Module Name:    src
Committed By:   kamil
Date:           Thu Nov  2 18:37:15 UTC 2017

Modified Files:
        src/lib/libc/stdlib: atexit.c

Log Message:
Correct handling of __cxa_atexit(a,b,NULL) in libc

In the NetBSD implementation and suggested by Itanium C++ ABI, we wrap
the atexit(x) call as __cxa_atexit(x,NULL,NULL).

__cxa_atexit() is an internal function for the usage of C++.

Correct a bug that __cxa_atexit(x,y,NULL) is handled in the same way as
atexit(x) (which is simplified to __cxa_atexit(x,NULL,NULL).

This misbehavior has been detected in the Thread Sanitizer port to NetBSD.

Patch reviewed by <christos>

Sponsored by <The NetBSD Foundation>


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libc/stdlib/atexit.c

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

Modified files:

Index: src/lib/libc/stdlib/atexit.c
diff -u src/lib/libc/stdlib/atexit.c:1.29 src/lib/libc/stdlib/atexit.c:1.30
--- src/lib/libc/stdlib/atexit.c:1.29	Sun Apr 19 18:15:26 2015
+++ src/lib/libc/stdlib/atexit.c	Thu Nov  2 18:37:14 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: atexit.c,v 1.29 2015/04/19 18:15:26 joerg Exp $	*/
+/*	$NetBSD: atexit.c,v 1.30 2017/11/02 18:37:14 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: atexit.c,v 1.29 2015/04/19 18:15:26 joerg Exp $");
+__RCSID("$NetBSD: atexit.c,v 1.30 2017/11/02 18:37:14 kamil Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "reentrant.h"
@@ -205,7 +205,7 @@ again:
 		if (dso == NULL || dso == ah->ah_dso || ah->ah_atexit == NULL) {
 			if (ah->ah_atexit != NULL) {
 				void *p = atexit_handler_stack;
-				if (ah->ah_dso != NULL) {
+				if (ah->ah_dso != NULL || ah->ah_arg != NULL) {
 					cxa_func = ah->ah_cxa_atexit;
 					ah->ah_cxa_atexit = NULL;
 					(*cxa_func)(ah->ah_arg);

Reply via email to