public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/16299] New: pthread_attr_setstacksize ignored
@ 2013-12-06 20:33 knielson at adaptivecomputing dot com
  2013-12-06 20:53 ` [Bug libc/16299] " bugdal at aerifal dot cx
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: knielson at adaptivecomputing dot com @ 2013-12-06 20:33 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16299

            Bug ID: 16299
           Summary: pthread_attr_setstacksize ignored
           Product: glibc
           Version: 2.18
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: knielson at adaptivecomputing dot com
                CC: drepper.fsp at gmail dot com

The stack size value set with pthread_attr_setstacksize is ignored when a
thread is started using pthread_create.

For example, if ulimit -s is set to 8192 and then you try to set the stack size
to 4096 the call to pthread_attr_setstacksize succeeds.
pthread_attr_getstacksize will return 4096 as well. But when the thread is
created it uses the 8192 value as the basis for the stack.

It does not make a difference if you try to increase or decrease the stack size
of the thread. The default value is always used.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/16299] pthread_attr_setstacksize ignored
  2013-12-06 20:33 [Bug libc/16299] New: pthread_attr_setstacksize ignored knielson at adaptivecomputing dot com
@ 2013-12-06 20:53 ` bugdal at aerifal dot cx
  2013-12-06 21:10 ` knielson at adaptivecomputing dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bugdal at aerifal dot cx @ 2013-12-06 20:53 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16299

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #1 from Rich Felker <bugdal at aerifal dot cx> ---
Please submit a minimal test case and explain how you're measuring the stack
size. It's possible that you're also including the guard page
(pthread_attr_setguardsize could eliminate that) or including space reserved
for TLS as part of the stack (while it's adjacent in memory, it's not "stack"
and should not consume part of what you request with
pthread_attr_setstacksize).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/16299] pthread_attr_setstacksize ignored
  2013-12-06 20:33 [Bug libc/16299] New: pthread_attr_setstacksize ignored knielson at adaptivecomputing dot com
  2013-12-06 20:53 ` [Bug libc/16299] " bugdal at aerifal dot cx
@ 2013-12-06 21:10 ` knielson at adaptivecomputing dot com
  2013-12-06 21:15 ` bugdal at aerifal dot cx
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: knielson at adaptivecomputing dot com @ 2013-12-06 21:10 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16299

--- Comment #2 from Ken Nielson <knielson at adaptivecomputing dot com> ---
Following is a sample of the code we are using. I have removed some of the
ancillary code to help make it easier to see how we are using the pthread
library.



#define MINIMUM_STACK_SIZE 16777216
#define MAX_STACK_SIZE MINIMUM_STACK_SIZE * 2
/*extern int    LOGLEVEL;*/
sigset_t      fillset;

threadpool_t *request_pool;

static void *work_thread(void *);

int create_work_thread(void)

  {
  int             rc;
  sigset_t        oldset;
  pthread_t       wthread;
  pthread_attr_t  attr;
  size_t          stack_size;
  char            log_buf[LOG_BUF_SIZE];

  if ((rc = pthread_attr_init(&attr)) != 0)
    {
    sprintf(log_buf, "pthread_attr_init failed. errno %d. Could not start
worker thread", errno);
    perror(log_buf);
    log_err(-1, __func__, log_buf);
    return(PBSE_SYSTEM);
    }

  pthread_attr_getstacksize(&attr, &stack_size);
  if (stack_size < MINIMUM_STACK_SIZE)
    stack_size = MINIMUM_STACK_SIZE;
  if (stack_size > MAX_STACK_SIZE)
    stack_size = MAX_STACK_SIZE;

  pthread_attr_setstacksize(&attr, stack_size);

  /* save old signal mask */
  pthread_sigmask(SIG_SETMASK,&fillset,&oldset);
  rc = pthread_create(&wthread,&request_pool->tp_attr,work_thread, &attr);
  pthread_sigmask(SIG_SETMASK,&oldset,NULL);

  return(rc);
  } /* END create_work_thread() */

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/16299] pthread_attr_setstacksize ignored
  2013-12-06 20:33 [Bug libc/16299] New: pthread_attr_setstacksize ignored knielson at adaptivecomputing dot com
  2013-12-06 20:53 ` [Bug libc/16299] " bugdal at aerifal dot cx
  2013-12-06 21:10 ` knielson at adaptivecomputing dot com
@ 2013-12-06 21:15 ` bugdal at aerifal dot cx
  2013-12-06 21:18 ` knielson at adaptivecomputing dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bugdal at aerifal dot cx @ 2013-12-06 21:15 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16299

--- Comment #3 from Rich Felker <bugdal at aerifal dot cx> ---
And how are you measuring the resulting stack size?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/16299] pthread_attr_setstacksize ignored
  2013-12-06 20:33 [Bug libc/16299] New: pthread_attr_setstacksize ignored knielson at adaptivecomputing dot com
                   ` (2 preceding siblings ...)
  2013-12-06 21:15 ` bugdal at aerifal dot cx
@ 2013-12-06 21:18 ` knielson at adaptivecomputing dot com
  2013-12-06 21:32 ` knielson at adaptivecomputing dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: knielson at adaptivecomputing dot com @ 2013-12-06 21:18 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16299

--- Comment #4 from Ken Nielson <knielson at adaptivecomputing dot com> ---
We measure the size using the ps command. We use both ps -ef  and I also use 
ps -eo uid,pid,ppid,sess,user,c,stime,vsz,rss,cmd

We grep for our program which is pbs_mom in this case. We allocate two threads
and when the ulimit -s is set to 300000 we see the rss size increase by 300 meg
for each thread. When done our program is using over 600 meg of memory.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/16299] pthread_attr_setstacksize ignored
  2013-12-06 20:33 [Bug libc/16299] New: pthread_attr_setstacksize ignored knielson at adaptivecomputing dot com
                   ` (3 preceding siblings ...)
  2013-12-06 21:18 ` knielson at adaptivecomputing dot com
@ 2013-12-06 21:32 ` knielson at adaptivecomputing dot com
  2013-12-06 22:31 ` carlos at redhat dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: knielson at adaptivecomputing dot com @ 2013-12-06 21:32 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16299

--- Comment #5 from Ken Nielson <knielson at adaptivecomputing dot com> ---
I should point out that if the ulimit -s size is smaller then the rss size of
pbs_mom is also smaller. The ulimit -s 300000 makes it clear where the memory
is coming from.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/16299] pthread_attr_setstacksize ignored
  2013-12-06 20:33 [Bug libc/16299] New: pthread_attr_setstacksize ignored knielson at adaptivecomputing dot com
                   ` (4 preceding siblings ...)
  2013-12-06 21:32 ` knielson at adaptivecomputing dot com
@ 2013-12-06 22:31 ` carlos at redhat dot com
  2013-12-06 22:44 ` knielson at adaptivecomputing dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: carlos at redhat dot com @ 2013-12-06 22:31 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16299

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING
                 CC|                            |carlos at redhat dot com

--- Comment #6 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Ken Nielson from comment #2)
>   pthread_attr_setstacksize(&attr, stack_size);

You set the stack size in `attr'

>   rc = pthread_create(&wthread,&request_pool->tp_attr,work_thread, &attr);

... but then ask the runtime to use `&request_pool->tp_attr' as the attributes
to create the thread.

You pass `&attr' as the argument to the thread function which will not change
the stack size used by the runtime.

This looks like a defect in your program?

Please confirm.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/16299] pthread_attr_setstacksize ignored
  2013-12-06 20:33 [Bug libc/16299] New: pthread_attr_setstacksize ignored knielson at adaptivecomputing dot com
                   ` (5 preceding siblings ...)
  2013-12-06 22:31 ` carlos at redhat dot com
@ 2013-12-06 22:44 ` knielson at adaptivecomputing dot com
  2013-12-06 22:45 ` carlos at redhat dot com
  2014-06-13 11:28 ` fweimer at redhat dot com
  8 siblings, 0 replies; 10+ messages in thread
From: knielson at adaptivecomputing dot com @ 2013-12-06 22:44 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16299

--- Comment #7 from Ken Nielson <knielson at adaptivecomputing dot com> ---
Thanks for taking the time to look at this. You are correct. We are using the
wrong attribute. Glad to know it is our code and not yours.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/16299] pthread_attr_setstacksize ignored
  2013-12-06 20:33 [Bug libc/16299] New: pthread_attr_setstacksize ignored knielson at adaptivecomputing dot com
                   ` (6 preceding siblings ...)
  2013-12-06 22:44 ` knielson at adaptivecomputing dot com
@ 2013-12-06 22:45 ` carlos at redhat dot com
  2014-06-13 11:28 ` fweimer at redhat dot com
  8 siblings, 0 replies; 10+ messages in thread
From: carlos at redhat dot com @ 2013-12-06 22:45 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16299

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |INVALID

--- Comment #8 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Ken Nielson from comment #7)
> Thanks for taking the time to look at this. You are correct. We are using
> the wrong attribute. Glad to know it is our code and not yours.

Thanks Ken! Marking resolved invalid.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug libc/16299] pthread_attr_setstacksize ignored
  2013-12-06 20:33 [Bug libc/16299] New: pthread_attr_setstacksize ignored knielson at adaptivecomputing dot com
                   ` (7 preceding siblings ...)
  2013-12-06 22:45 ` carlos at redhat dot com
@ 2014-06-13 11:28 ` fweimer at redhat dot com
  8 siblings, 0 replies; 10+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 11:28 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16299

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-06-13 11:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-06 20:33 [Bug libc/16299] New: pthread_attr_setstacksize ignored knielson at adaptivecomputing dot com
2013-12-06 20:53 ` [Bug libc/16299] " bugdal at aerifal dot cx
2013-12-06 21:10 ` knielson at adaptivecomputing dot com
2013-12-06 21:15 ` bugdal at aerifal dot cx
2013-12-06 21:18 ` knielson at adaptivecomputing dot com
2013-12-06 21:32 ` knielson at adaptivecomputing dot com
2013-12-06 22:31 ` carlos at redhat dot com
2013-12-06 22:44 ` knielson at adaptivecomputing dot com
2013-12-06 22:45 ` carlos at redhat dot com
2014-06-13 11:28 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).