Bug 20813

Summary: pthread_exit is inconsistent between libc and libpthread
Product: glibc Reporter: Ralph Loader <suckfish>
Component: nptlAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: adhemerval.zanella, drepper.fsp, fweimer
Priority: P2 Flags: fweimer: security-
Version: 2.23   
Target Milestone: 2.34   
Host: Target:
Build: Last reconfirmed:

Description Ralph Loader 2016-11-12 23:49:21 UTC
The single-threaded C++ program below compiles with or without -lpthread, but behaves differently.

The issue appears to be that libc.so provides an implementation of pthread_exit() that does not do stack-unwinding, but the libpthread.so version does do stack unwinding.

I believe that either behaviour complies with the standards, but it would be nice if glibc was consistent in its behaviour.

$ g++ -o temp temp.cc -pthread && ./temp
Hi there!
$ g++ -o temp temp.cc && ./temp
(no output)

This is Fedora glibc-2.23.1-10.fc24.x86_64

-----------------------------

#include <pthread.h>
#include <stdio.h>

struct Foo {
    ~Foo() {
        printf("Hi there!\n");
    }
};

int main()
{
    Foo foo;
    pthread_exit(NULL);
    return 0;
}
Comment 1 Adhemerval Zanella 2021-05-31 18:03:42 UTC
With lbipthread move to libc this issue does not happen anymore. Fixed on 2.34 (c62cef023cdcd8349369ef4e0d08290e495659be).