[haiku-bugs] Re: [Haiku] #3883: [patch] please implement pthread_attr_getstack()

  • From: "phoudoin" <trac@xxxxxxxxxxxx>
  • Date: Tue, 18 May 2010 10:23:49 -0000

#3883: [patch] please implement pthread_attr_getstack()
-------------------------------+--------------------------------------------
 Reporter:  mjw                |       Owner:  axeld        
     Type:  enhancement        |      Status:  new          
 Priority:  normal             |   Milestone:  R1           
Component:  System/libroot.so  |     Version:  R1/pre-alpha1
 Keywords:                     |    Platform:  All          
Blockedby:                     |       Patch:  1            
 Blocking:                     |  
-------------------------------+--------------------------------------------

Comment(by phoudoin):

 Dunno myself.

 Anyway, I may be wrong but I think the current patch's
 pthread_getattr_np() implementation will leak memory when called with a
 dst parameter already initialized by pthread_attr_init(), as recommended,
 like in this example:

 {{{
 #!c
 size_t
 get_thread_stack_size(pthread_t pid)
 {
     pthread_attr_t attr;
     size_t size;

     pthread_attr_init(&attr);
     pthread_attr_get_np(pid, &attr);
     pthread_attr_getstacksize(&attr, &size);
     pthread_attr_destroy(&attr);

     return(size);
 }
 }}}

 Otherwise, Ingo raised concern about caching thread stack base address in
 thread internal attributes when such info can already be retrieved with
 get_thread_info(), wich will avoid to extent private pthread_attr struct.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/3883#comment:10>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: