diff options
| author | kettenis <> | 2014-06-18 19:01:10 +0000 |
|---|---|---|
| committer | kettenis <> | 2014-06-18 19:01:10 +0000 |
| commit | 944d3fa89a8a293a3a963cbf422a1e085e7f25df (patch) | |
| tree | 25ba00731ee7e34a8f0bb9da9731d10eba63a790 /src/regress/lib/libc | |
| parent | 1720390075b52ae14cd5f46d93b100d9bcb81dc5 (diff) | |
| download | openbsd-944d3fa89a8a293a3a963cbf422a1e085e7f25df.tar.gz openbsd-944d3fa89a8a293a3a963cbf422a1e085e7f25df.tar.bz2 openbsd-944d3fa89a8a293a3a963cbf422a1e085e7f25df.zip | |
Always call atexit handlers as if they were registered with __cxa_atexit.
The extra argument doesn't hurt genuine atexit handlers and this fixes a
bug where we didn't provide the argument (effectively passing garbage) for
functions registered with __cxa_atexit in the main executable.
Pointed out by Dmitriy Ivanov <dimitry@google.com> and Elliott Hughes
<enh@google.com>.
ok matthew@
Diffstat (limited to 'src/regress/lib/libc')
| -rw-r--r-- | src/regress/lib/libc/atexit/atexit_test.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/regress/lib/libc/atexit/atexit_test.c b/src/regress/lib/libc/atexit/atexit_test.c index 3dd0b62c3e..f374dee9eb 100644 --- a/src/regress/lib/libc/atexit/atexit_test.c +++ b/src/regress/lib/libc/atexit/atexit_test.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: atexit_test.c,v 1.6 2007/09/03 14:42:44 millert Exp $ */ | 1 | /* $OpenBSD: atexit_test.c,v 1.7 2014/06/18 19:01:10 kettenis Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2002 Daniel Hartmeier | 4 | * Copyright (c) 2002 Daniel Hartmeier |
| @@ -43,7 +43,7 @@ | |||
| 43 | void handle_first(void); | 43 | void handle_first(void); |
| 44 | void handle_middle(void); | 44 | void handle_middle(void); |
| 45 | void handle_last(void); | 45 | void handle_last(void); |
| 46 | void handle_invalid(void); | 46 | void handle_invalid(void *); |
| 47 | void handle_cleanup(void); | 47 | void handle_cleanup(void); |
| 48 | void handle_signal(int); | 48 | void handle_signal(int); |
| 49 | 49 | ||
| @@ -79,7 +79,7 @@ main(int argc, char *argv[]) | |||
| 79 | /* this is supposed to segfault */ | 79 | /* this is supposed to segfault */ |
| 80 | if (!strcmp(argv[1], "-invalid-atexit")) { | 80 | if (!strcmp(argv[1], "-invalid-atexit")) { |
| 81 | signal(SIGSEGV, handle_signal); | 81 | signal(SIGSEGV, handle_signal); |
| 82 | __atexit->fns[0].fn_ptr.std_func = handle_invalid; | 82 | __atexit->fns[0].fn_ptr = handle_invalid; |
| 83 | } else if (!strcmp(argv[1], "-invalid-cleanup")) { | 83 | } else if (!strcmp(argv[1], "-invalid-cleanup")) { |
| 84 | struct atexit *p = __atexit; | 84 | struct atexit *p = __atexit; |
| 85 | 85 | ||
| @@ -88,7 +88,7 @@ main(int argc, char *argv[]) | |||
| 88 | p = p->next; | 88 | p = p->next; |
| 89 | if (p == NULL) | 89 | if (p == NULL) |
| 90 | fprintf(stderr, "p == NULL, no page found\n"); | 90 | fprintf(stderr, "p == NULL, no page found\n"); |
| 91 | p->fns[0].fn_ptr.std_func = handle_invalid; | 91 | p->fns[0].fn_ptr = handle_invalid; |
| 92 | } | 92 | } |
| 93 | __atexit_register_cleanup(handle_cleanup); | 93 | __atexit_register_cleanup(handle_cleanup); |
| 94 | counter = 0; | 94 | counter = 0; |
| @@ -121,7 +121,7 @@ handle_cleanup(void) | |||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | void | 123 | void |
| 124 | handle_invalid(void) | 124 | handle_invalid(void *arg) |
| 125 | { | 125 | { |
| 126 | fprintf(stderr, "handle_invalid() THIS SHOULD HAVE SEGFAULTED INSTEAD!\n"); | 126 | fprintf(stderr, "handle_invalid() THIS SHOULD HAVE SEGFAULTED INSTEAD!\n"); |
| 127 | } | 127 | } |
