Skip Menu |

This queue is for tickets about the threads CPAN distribution.

Report information
The Basics
Id: 18419
Status: resolved
Priority: 0/
Queue: threads

People
Owner: Nobody in particular
Requestors: jdhedden [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.19
Fixed in: (no value)



Subject: pthread_attr_setstacksize failures under Linux
There have been a number of failed test reports with the following error message: Thread creation failed: pthread_attr_setstacksize(2097152) returned 22 (Note: The error message is descriptive - the actual function call is below). This shows that the pthread_attr_setstacksize function was called with the stack size of 2MB (2*1024*1024), and that the function returned EINVAL. The architectures (and failure reports) under which this has been reported so far include: linux lappy 2.4.22 (Perl 5.8.7 with use64bitint=define) http://www.nntp.perl.org/group/perl.cpan.testers/302925 linux penguin 2.4.26 (Perl 5.8.6 and 5.9.3 with use64bitint=define) http://www.nntp.perl.org/group/perl.cpan.testers/302934 http://www.nntp.perl.org/group/perl.cpan.testers/302459 linux promomail 2.4.27-2-386 (Perl 5.8.8 with use64bitint=undef) debian 3.1 stable Checking the source code for the pthread_attr_setstacksize function in glibc shows that the only cause for the EINVAL error code is too small of a stack size: /* Catch invalid sizes. */ if (stacksize < PTHREAD_STACK_MIN) return EINVAL; Usually that minimum is 16K, however, the threads module code checks against whatever PTHREAD_STACK_MIN is set to, so 2MB should be valid. Within the threads module code, stack size is carried as an IV (64-bit int): typedef struct ithread_s { ... IV stack_size; } ithread; IV stack_size; And the call to pthread_attr_setstacksize casts it to size_t: # ifdef _POSIX_THREAD_ATTR_STACKSIZE /* Set thread's stack size */ if (thread->stack_size > 0) { rc_stack_size = pthread_attr_setstacksize(&attr, (size_t)thread->stack_size); } # endif The fact that one architecture which doesn't use 64-bit ints (linux promomail 2.4.27-2-386 (Perl 5.8.8 with use64bitint=undef)) and yet still reports the failure shows that the problem is not related to casting the IV to size_t. This bug is 'stalled' until someone can shed some more light on the issue.