Bug 20813 - pthread_exit is inconsistent between libc and libpthread
Summary: pthread_exit is inconsistent between libc and libpthread
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: nptl (show other bugs)
Version: 2.23
: P2 normal
Target Milestone: 2.34
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-12 23:49 UTC by Ralph Loader
Modified: 2021-05-31 18:10 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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).