Thread overview
pthread_create oddity
Aug 07, 2015
Daniel Kozak
August 07, 2015
I ran into an oddity of pthread_create, see https://github.com/D-Programming-Language/druntime/pull/1340. It appears that if stack size is not explicitly set, the 32-bit version of pthread_create fails. That's happening at least on Ubuntu64 under VMWare hosted on Linux.

Unrelated: what's the deal with the build fail by CyberShadow/DAutoTest?


Andrei
August 07, 2015
On 8/7/15 1:36 PM, Andrei Alexandrescu wrote:
> I ran into an oddity of pthread_create, see
> https://github.com/D-Programming-Language/druntime/pull/1340. It appears
> that if stack size is not explicitly set, the 32-bit version of
> pthread_create fails. That's happening at least on Ubuntu64 under VMWare
> hosted on Linux.

What is the stack size using pthread_getstacksize before the setting of it?

I would think with pthread_attr_init, it should be a reasonable default.

-Steve
August 07, 2015
V Fri, 07 Aug 2015 14:20:59 -0400
Steven Schveighoffer via Digitalmars-d <digitalmars-d@puremagic.com>
napsáno:

> On 8/7/15 1:36 PM, Andrei Alexandrescu wrote:
> > I ran into an oddity of pthread_create, see https://github.com/D-Programming-Language/druntime/pull/1340. It appears that if stack size is not explicitly set, the 32-bit version of pthread_create fails. That's happening at least on Ubuntu64 under VMWare hosted on Linux.
> 
> What is the stack size using pthread_getstacksize before the setting of it?
> 
> I would think with pthread_attr_init, it should be a reasonable default.

Yes it is a default, which is zero, so problem is somewhere else

> 
> -Steve


August 08, 2015
On 8/7/15 2:20 PM, Steven Schveighoffer wrote:
> On 8/7/15 1:36 PM, Andrei Alexandrescu wrote:
>> I ran into an oddity of pthread_create, see
>> https://github.com/D-Programming-Language/druntime/pull/1340. It appears
>> that if stack size is not explicitly set, the 32-bit version of
>> pthread_create fails. That's happening at least on Ubuntu64 under VMWare
>> hosted on Linux.
>
> What is the stack size using pthread_getstacksize before the setting of it?
>
> I would think with pthread_attr_init, it should be a reasonable default.

pthread_getstacksize indicates 8,388,608 bytes. It doesn't seem excessive, but the 32-bit build does find that too big. If I try to set stack size to that value with pthread_setstacksize, indeed the thread fails. So it's not that you need to call pthread_setstacksize, you need to call it with a smaller value. -- Andrei
August 10, 2015
On 8/8/15 8:40 AM, Andrei Alexandrescu wrote:

> pthread_getstacksize indicates 8,388,608 bytes. It doesn't seem
> excessive, but the 32-bit build does find that too big. If I try to set
> stack size to that value with pthread_setstacksize, indeed the thread
> fails. So it's not that you need to call pthread_setstacksize, you need
> to call it with a smaller value. -- Andrei

Does the failure always happen with any thread create? Or only after you have created X threads?

8MB doesn't seem like that much, but if you created 100 threads at 8MB a piece...

What about an equivalent C program? something doesn't seem right when the default value isn't working...

-Steve