From nobody@FreeBSD.org  Mon Jan 29 08:50:49 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id CC41D37B698
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Jan 2001 08:50:41 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f0TGofU88365;
	Mon, 29 Jan 2001 08:50:41 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200101291650.f0TGofU88365@freefall.freebsd.org>
Date: Mon, 29 Jan 2001 08:50:41 -0800 (PST)
From: dor@cwnt.com
To: freebsd-gnats-submit@FreeBSD.org
Subject: libgcc_r problem - library precedence with libstdc++
X-Send-Pr-Version: www-1.0

>Number:         24721
>Category:       bin
>Synopsis:       libgcc_r problem - library precedence with libstdc++
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 29 09:00:01 PST 2001
>Closed-Date:    Wed Jan 16 14:58:13 PST 2002
>Last-Modified:  Wed Jan 16 14:58:49 PST 2002
>Originator:     Dor Laor
>Release:        4.2-release
>Organization:
Charlotte WEB
>Environment:
FreeBSD simba.cwnt.co.il 4.2-RELEASE FreeBSD 4.2-RELEASE #2: Wed Jan 17 16:22:29 GMT 2001     barak@simba.cwnt.co.il:/usr/src/sys/compile/COMPAQ_DL360  i386

>Description:
The attached program creates cores using normal compilation & linking .
The compilation command is:
g++ -g3 try.cpp -pthread -o try

// file try.cpp

#include <sys/types.h>
#include <strstream.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <pthread.h>


class a {
public:
    a() {
        a1 = 0;
    }
    ~a() {
        int i;
        int a2[100];
        for (i = 0; i < 100 ; i++) {
            a2[i] = i;
        }
        a1 = a2[0];
    }
    int a1;
};

class b : a {
    int b1;
};

void func(void* arg) {
    int i;
    for (i=0;i<100000;i++) {
        b obj;
        b* p;
        p = &obj;
    }
    printf("thread done\n");
}

void thread_creation(int i) {
    int rtn = 0;

    pthread_t id;
    if (rtn = pthread_create(&id, 0, (void * (*)(void *))func,NULL)) {
        printf(" could create thread\n");
    }
}


int main() {

    for (int i=0; i< 100; i++) {
        thread_creation(i);
    }


    sleep(10);

    return 0;
}



>How-To-Repeat:
Just run the program several times.
>Fix:
Link libgcc_r implictly with the executable- use command

g++ -g3 try.cpp -pthread -lgcc_r -o try


Note that if you put libstdc++ before gcc_r the problem remains


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: ashp 
State-Changed-When: Wed Jan 16 14:58:13 PST 2002 
State-Changed-Why:  
Following the instructions in the PR, I had no problems running 
the program in question.  It gives 'thread done' numerous times. 


http://www.FreeBSD.org/cgi/query-pr.cgi?pr=24721 
>Unformatted:
