[Bug 278551] pthread_join() kills the process with a return code of 134

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 23 Apr 2024 19:05:16 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278551

--- Comment #3 from Mohammed Goder <mohammedgoder@gmail.com> ---
(In reply to Konstantin Belousov from comment #2)

I apologize; this is the first time I've ever filed a bug report to a project.
I'm aware of the return code message. I'm 100 percent sure that this has to do
with the FreeBSD or it's compiler toolchain/libraries.

main.cpp:
#include "iostream" // iostream's static library has issues on freebsd.
#include "cstdio"
#include "pthread.h"
#include "pthread_np.h"

void* kernel(void* par) {
    printf("kernel\n");
    return NULL;
}

int main(int argc, const char* const* args){
    pthread_t thread;
    pthread_create(
        &thread,
        NULL,
        kernel,
        NULL
    );

    pthread_join(thread, NULL);

    printf("FreeBSD RELEASE 14.0 doesn't reach here.\n");

    return 0;
}

build.sh:
#!/bin/sh
g++ -std=c++20 -static-libgcc -static-libstdc++ -static -pthread -O3 "main.cpp"
-o "main_g++"
clang++ -std=c++20 -static-libgcc -static-libstdc++ -static -pthread -O3
"main.cpp" -o "main_clang++"

Problem:
I've narrowed the issue down to "iostream" and it's static libraries causing
problems. The issue goes away if you remove the flags to statically link
libraries or remove the "iostream" header from the list of includes. Also,
please keep in mind that this is all still being done in a virtual machine so I
don't know if the issue persists on bare metal.

-- 
You are receiving this mail because:
You are the assignee for the bug.