Bug 133735

Summary: Multi-threaded 32 bit cores can't be used on 64 bit systems
Product: Base System Reporter: Stephen Sanders <ssanders>
Component: threadsAssignee: attilio
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Stephen Sanders 2009-04-14 22:00:04 UTC
The following program will produce a core file.  

Running the program on a FreeBSD 6.3/64 bit system will produce a core
file.  Attempts to use gdb on the core will fail on the following error:

Core was generated by `threadcore'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib32/libpthread.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib32/libpthread.so.2
Reading symbols from /usr/lib32/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib32/libc.so.6
Reading symbols from /libexec/ld-elf.so.1...(no debugging symbols found)...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x0804d100 in ?? ()
[New Thread 0x805301408053200 (runnable)]
[New Thread 0x280a05a808053000 (runnable)]
Cannot get thread info: generic error
(gdb) 

--------------------------- The Program ------------------
#include <sys/types.h>
#include <signal.h>
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <err.h>

void *thr(void *a)
{
    int *ip = (int *)a;
    printf("started thread %d\n", *ip);
    pause();
    return 0;
}

int main(int argc, char **argv)
{
    const int THREADCOUNT =4;
    int i;
    pthread_t threads[THREADCOUNT];

    for (i =0; i < THREADCOUNT; i++)
       if (pthread_create(&threads[i], 0, thr, (void *)&i) != 0)
           errx(-1, "cannot create thread");

    sleep(1);
    kill(0, SIGBUS);
    return 0;
}

How-To-Repeat: Compile the program in the description section on a FreeBSD 6.3/32 bit
system.  Run it on a 6.3/64 bit system and attempt to look at the core
file ('info threads' for example)
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2009-04-14 22:38:07 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-threads

Over to maintainer(s).
Comment 2 Ed Maste freebsd_committer freebsd_triage 2009-04-15 04:14:25 UTC
State Changed
From-To: open->patched

This should be fixed in HEAD now (by marcel's changes).  There are plans 
to MFC to 6 & 7. 


Comment 3 Ed Maste freebsd_committer freebsd_triage 2009-04-15 04:14:25 UTC
Responsible Changed
From-To: freebsd-threads->emaste

Grab to keep track of this.
Comment 4 Ed Maste freebsd_committer freebsd_triage 2009-04-27 14:23:57 UTC
Responsible Changed
From-To: emaste->attilio

Assign to Attilio for tracking; he will MFC (some of) Marcel's changes 
to libthread_db for this support.
Comment 5 attilio freebsd_committer freebsd_triage 2010-08-09 14:38:37 UTC
State Changed
From-To: patched->closed

Fixed by r189416, r192320, r192098, r193789, r181651, r193838.