Re: pthread?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Israel Fdez Cabrera <israel@xxxxxxxxxx> writes:

> Hi, may be this question is offtopic, sorry if this is the case, any way I'll 
> appresiate if someone tell me where to find a good mailing list about Linux 
> programming.

comp.os.linux.development.apps
comp.os.linux.development.system

> 
> Any way, my problem is with the following test code:
> 
> typedef void*(*ftype)(void*);
> 
> void *thread_test( void *arg ){
>      std::cout << "New Thread: " << *((int*)arg) << std::endl;
>      delete arg;

Calling delete on void* has undefined behavior, and may corrupt your
    heap. Do not do it.

> }
> 
> int main(int argc, char *argv[]){
>      
>      ftype function = thread_test;
>      for ( int i = 0; i < 10; i++ ){
>           pthread_t thread_handler;
>           int * _ni = new int;
>           *_ni = i;
>           int res = pthread_create( &thread_handler, NULL, function, _ni );
>           std::cout << "Main Thread" << std::endl;
>      }
> 
> 
>      return EXIT_SUCCESS;
> }
> 
> It compiles well, but when I run it, I get a signal 11, at debbug time I 
> notice the signal is generated when the pthread_create is called. Any hint?, 
> any linux-prog mailing list?
[snip]

Well, I am not running linux, but on freebsd5 using gcc 3.3 it prints:

    Main Thread
    Main Thread
    Main Thread
    Main Thread
    Main Thread
    Main Thread
    Main Thread
    Main Thread
    Main Thread
    Main Thread

So please post the output of gcc -v, your glibc version, and the
    output of uname -a . I suspect your gcc is misconfigured somehow. 


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux