search for: pthread_key_t

Displaying 20 results from an estimated 27 matches for "pthread_key_t".

2008 May 22
0
[PATCH] stubdom: fix and clean pthread minimal support
...include/posix/pthread.h Thu May 22 14:28:40 2008 +0100 +++ b/extras/mini-os/include/posix/pthread.h Thu May 22 16:08:29 2008 +0100 @@ -1,18 +1,56 @@ #ifndef _POSIX_PTHREAD_H #define _POSIX_PTHREAD_H +#include <stdlib.h> + /* Let''s be single-threaded for now. */ -typedef void *pthread_key_t; -typedef struct {} pthread_mutex_t, pthread_once_t; +typedef struct { + void *ptr; +} *pthread_key_t; +static inline int pthread_key_create(pthread_key_t *key, void (*destr_function)(void*)) +{ + *key = malloc(sizeof(**key)); + (*key)->ptr = NULL; + return 0; +} +static inline int p...
2017 Nov 16
2
question about xray tls data initialization
I'm learning the xray library and try if it can be built on windows, in xray_fdr_logging_impl.h line 152 , comment written as // Using pthread_once(...) to initialize the thread-local data structures but at line 175, 183, code written as thread_local pthread_key_t key; // Ensure that we only actually ever do the pthread initialization once. thread_local bool UNUSED Unused = [] { new (&TLSBuffer) ThreadLocalData(); auto result = pthread_key_create(&key, +[](void *) { auto &TLD = *reinterpret_cast<ThreadLocalData *>(&TL...
2023 Mar 09
2
[PATCH libnbd v3] lib/errors.c: Fix assert fail in exit path in multi-threaded code
...or, and inside libnbd the library calls set_error(). (4) The call to set_error() calls pthread_getspecific which returns NULL (since the key has already been destroyed in step (2)), and this causes us to call pthread_setspecific which returns EINVAL because glibc is able to detect invalid use of a pthread_key_t after it has been destroyed. In any case, the error message is lost, and any subsequent call to nbd_get_error() will return NULL. (5) We enter the %DEAD state, where there is an assertion that nbd_get_error() is not NULL. This assertion is supposed to be for checking that the code called set_err...
2017 Nov 21
2
question about xray tls data initialization
...#39;m learning the xray library and try if it can be built on windows, in > xray_fdr_logging_impl.h > > line 152 , comment written as > // Using pthread_once(...) to initialize the thread-local data structures > > > but at line 175, 183, code written as > > thread_local pthread_key_t key; > > // Ensure that we only actually ever do the pthread initialization once. > thread_local bool UNUSED Unused = [] { > new (&TLSBuffer) ThreadLocalData(); > auto result = pthread_key_create(&key, +[](void *) { > auto &TLD = *reinterpret_cast<Threa...
2012 Jun 04
2
[LLVMdev] probleam about ThreadLocalImpl of llvm
...3 0x7c94108f in ntdll!RtlMapGenericMask () from C:\WINDOWS\system32\ntdll.dll #24 0x7c92e437 in ntdll!LdrCreateOutOfProcessImage () from C:\WINDOWS\system32\ntdll.dll (gdb) At last, I print some information in ThreadLocalImpl function: 44 ThreadLocalImpl::ThreadLocalImpl() : data(0) { 45 pthread_key_t* key = new pthread_key_t; 46 printf("IN %s, line = %d key: 0x%x\n", __FUNCTION__, __LINE__, key); 47 int errorcode = pthread_key_create(key, NULL); 48 printf("In %s, line = %d\n", __FUNCTION__, __LINE__); 49 assert(errorcode == 0); 50 (void) errorcode; 51 data...
2023 Mar 09
1
[PATCH libnbd v3] lib/errors.c: Fix assert fail in exit path in multi-threaded code
This version simply removes the call to pthread_key_destroy. It fixes the problem and allows us to leave the asserts alone so we can still catch real errors. Of course this leaks pthread_key_t in the case where you dlclose() the library. glibc has a limit of 128 thread-specific keys (and the first 32 are somehow "fast" in a way I could quite follow), so that's a thing. Rich.
2023 Mar 09
1
[PATCH libnbd v3] lib/errors.c: Fix assert fail in exit path in multi-threaded code
...library calls set_error(). > > (4) The call to set_error() calls pthread_getspecific which returns > NULL (since the key has already been destroyed in step (2)), and this > causes us to call pthread_setspecific which returns EINVAL because > glibc is able to detect invalid use of a pthread_key_t after it has > been destroyed. In any case, the error message is lost, and any > subsequent call to nbd_get_error() will return NULL. > > (5) We enter the %DEAD state, where there is an assertion that > nbd_get_error() is not NULL. This assertion is supposed to be for > checkin...
2012 Jun 04
0
[LLVMdev] probleam about ThreadLocalImpl of llvm
...enericMask () > from C:\WINDOWS\system32\ntdll.dll > #24 0x7c92e437 in ntdll!LdrCreateOutOfProcessImage () > from C:\WINDOWS\system32\ntdll.dll > (gdb) > > At last, I print some information in ThreadLocalImpl function: > 44 ThreadLocalImpl::ThreadLocalImpl() : data(0) { > 45 pthread_key_t* key = new pthread_key_t; > 46 printf("IN %s, line = %d key: 0x%x\n", __FUNCTION__, __LINE__, key); > 47 int errorcode = pthread_key_create(key, NULL); > 48 printf("In %s, line = %d\n", __FUNCTION__, __LINE__); > 49 assert(errorcode == 0); > 50 (void) errorcode; &...
2012 Sep 04
1
Repeated Asterisk 10.7.0 crashes
I'm getting cycles of repeated crashes which occur and then stop occurring. Looking at the dumps via gdb shows that something peculiar is happening that looks like memory corruption: Program terminated with signal 6, Aborted. #0 0x0000003686e30285 in raise () from /lib64/libc.so.6 (gdb) up #1 0x0000003686e31d30 in abort () from /lib64/libc.so.6 (gdb) up #2 0x0000003686e6971b in
2023 Mar 09
1
[PATCH libnbd v4] lib/errors.c: Fix assert fail in exit path in multi-threaded code
...library calls set_error(). > > (4) The call to set_error() calls pthread_getspecific which returns > NULL (since the key has already been destroyed in step (2)), and this > causes us to call pthread_setspecific which returns EINVAL because > glibc is able to detect invalid use of a pthread_key_t after it has > been destroyed. In any case, the error message is lost, and any > subsequent call to nbd_get_error() will return NULL. > > (5) We enter the %DEAD state, where there is an assertion that > nbd_get_error() is not NULL. This assertion is supposed to be for > checkin...
2023 Mar 09
1
[PATCH libnbd v4] lib/errors.c: Fix assert fail in exit path in multi-threaded code
...or, and inside libnbd the library calls set_error(). (4) The call to set_error() calls pthread_getspecific which returns NULL (since the key has already been destroyed in step (2)), and this causes us to call pthread_setspecific which returns EINVAL because glibc is able to detect invalid use of a pthread_key_t after it has been destroyed. In any case, the error message is lost, and any subsequent call to nbd_get_error() will return NULL. (5) We enter the %DEAD state, where there is an assertion that nbd_get_error() is not NULL. This assertion is supposed to be for checking that the code called set_err...
2023 Mar 08
2
[PATCH libnbd] lib/errors.c: Fix assert fail in exit path in multi-threaded code
...or, and inside libnbd the library calls set_error(). (4) The call to set_error() calls pthread_getspecific which returns NULL (since the key has already been destroyed in step (2)), and this causes us to call pthread_setspecific which returns EINVAL because glibc is able to detect invalid use of a pthread_key_t after it has been destroyed. In any case, the error message is lost, and any subsequent call to nbd_get_error() will return NULL. (5) We enter the %DEAD state, where there is an assertion that nbd_get_error() is not NULL. This assertion is supposed to be for checking that the code called set_err...
2019 Apr 23
0
[PATCH nbdkit v2 2/2] server: Use a thread-local pread/pwrite buffer to avoid leaking heap data.
...r. */ diff --git a/server/threadlocal.c b/server/threadlocal.c index e556dbc..49ae1ac 100644 --- a/server/threadlocal.c +++ b/server/threadlocal.c @@ -58,6 +58,8 @@ struct threadlocal { struct sockaddr *addr; socklen_t addrlen; int err; + void *buffer; + size_t buffer_size; }; static pthread_key_t threadlocal_key; @@ -69,6 +71,7 @@ free_threadlocal (void *threadlocalv) free (threadlocal->name); free (threadlocal->addr); + free (threadlocal->buffer); free (threadlocal); } @@ -189,3 +192,37 @@ threadlocal_get_error (void) errno = err; return threadlocal ? threadlo...
2020 May 07
1
[PATCH nbdkit] vddk: Suppress errors in can_extents test (RHBZ#1709211).
...#include "cleanup.h" @@ -76,6 +77,7 @@ int vddk_debug_datapath = 1; static void *dl; /* dlopen handle */ static bool init_called; /* was InitEx called */ static char *reexeced; /* orig LD_LIBRARY_PATH on reexec */ +static pthread_key_t error_suppression; /* threadlocal error suppression */ static char *config; /* config */ static const char *cookie; /* cookie */ @@ -108,6 +110,35 @@ static bool is_remote; if (vddk_debug_datapath) \ nbdkit_de...
2017 Jul 10
2
Re: [PATCH v3 3/5] threads: Use thread-local storage for errors.
On Tuesday, 27 June 2017 13:55:57 CEST Richard W.M. Jones wrote: > We permit the following constructs in libguestfs code: > > if (guestfs_some_call (g) == -1) { > fprintf (stderr, "failed: error is %s\n", guestfs_last_error (g)); > } > > and: > > guestfs_push_error_handler (g, NULL, NULL); > guestfs_some_call (g); >
2017 Jan 26
0
[nbdkit PATCH v2 4/6] plugins: Add new nbdkit_set_error() utility function
...e client + * in a reply. * * The main thread does not have any associated TLS, *unless* it is * serving a request (the '-s' option). @@ -56,6 +58,7 @@ struct tls { size_t instance_num; /* Can be 0. */ struct sockaddr *addr; socklen_t addrlen; + int err; }; static pthread_key_t tls_key; @@ -150,3 +153,24 @@ tls_get_instance_num (void) return tls->instance_num; } + +void +tls_set_error (int err) +{ + struct tls *tls = pthread_getspecific (tls_key); + + if (tls) + tls->err = err; + else + errno = err; +} + +int +tls_get_error (void) +{ + int err = errno...
2018 Jun 08
4
vanilla build of 7.7p1 release on linux/4.17 fails with gcc8 @ "/usr/bin/ld: unrecognized option '-Wl,-z,retpolineplt'"
On 8 June 2018 at 11:21, PGNet Dev <pgnet.dev at gmail.com> wrote: > fyi > > add'l -- and looks unrelated -- issue > /usr/include/pthread.h:251:12: note: previous declaration of ?pthread_join? was here > extern int pthread_join (pthread_t __th, void **__thread_return); What included pthread.h? That's explicitly not supported by sshd: $ grep THREAD
2020 Jun 02
0
[PATCH nbdkit 2/5] vddk: Move reexec code to a new file.
...quot; /* Debug flags. */ @@ -76,13 +75,12 @@ int vddk_debug_datapath = 1; static void *dl; /* dlopen handle */ static bool init_called; /* was InitEx called */ -static char *reexeced; /* orig LD_LIBRARY_PATH on reexec */ static pthread_key_t error_suppression; /* threadlocal error suppression */ static char *config; /* config */ static const char *cookie; /* cookie */ static const char *filename; /* file */ -static char *libdir; /* libdir */ +char *libdir...
2023 Mar 08
2
[libnbd PATCH v2] lib/errors.c: Fix assert fail in exit path in multi-threaded code
...(h, &h->cmds_to_issue); nbd_internal_abort_commands (h, &h->cmds_in_flight); diff --git a/lib/errors.c b/lib/errors.c index 8b77650e..133c752b 100644 --- a/lib/errors.c +++ b/lib/errors.c @@ -34,6 +34,8 @@ struct last_error { /* Thread-local storage of the last error. */ static pthread_key_t errors_key; +/* Zero if errors_key is invalid, else 1 + threads using errors_key. */ +static _Atomic int key_use_count; static void free_errors_key (void *vp) LIBNBD_ATTRIBUTE_NONNULL (1); @@ -51,6 +53,7 @@ errors_key_create (void) strerror (err)); abort (); } + key_use_co...
2019 Apr 23
4
[PATCH nbdkit v2 0/2] Be careful not to leak server heap memory to the client.
Version 1 was here: https://www.redhat.com/archives/libguestfs/2019-April/msg00144.html Version 2 makes a couple of much larger changes: The OCaml patch changes the API of the pread method so it matches what other language bindings are already doing, ie. get the language plugin to return a newly allocated buffer, check it is long enough, copy out the data. The server patch implements a