Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdlib Correct handling of __cxa_atexit(a, b, NULL) i...



details:   https://anonhg.NetBSD.org/src/rev/f9832497b076
branches:  trunk
changeset: 357249:f9832497b076
user:      kamil <kamil%NetBSD.org@localhost>
date:      Thu Nov 02 18:37:14 2017 +0000

description:
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>

diffstat:

 lib/libc/stdlib/atexit.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r d6b967c03b7a -r f9832497b076 lib/libc/stdlib/atexit.c
--- a/lib/libc/stdlib/atexit.c  Thu Nov 02 16:09:33 2017 +0000
+++ b/lib/libc/stdlib/atexit.c  Thu Nov 02 18:37:14 2017 +0000
@@ -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 @@
                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);



Home | Main Index | Thread Index | Old Index