Skip to content

pthread_key_create does not initialize thread local variable with null #8740

@AndreasReich

Description

@AndreasReich

The following code fails with emscripten right now:

pthread_key_t k;
pthread_key_create(&k, NULL);
assert(pthread_getspecific(k) == 0); // fine

pthread_setspecific(k, (void*)1);
pthread_key_delete(k);

pthread_key_create(&k, NULL);
assert(pthread_getspecific(k) == 0); // fails

According to POSIX specification, after creation of a thread local key, the value should be zero on key creation on all threads.
See: http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_key_create.html

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions