Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 5df77cc66bfc60c7690b2cf5cfe560d06daff818
Ticket: 1618411fffffffffffffffffffffffffffffffff
TclpCheckStackSpace() fails on recent linux system
User & Date: arekm on 2007-01-21 19:26:03
Changes

  1. icomment:
    Logged In: YES 
    user_id=139606
    Originator: YES
    
    
    With this test app below:
    
    [arekm@arm ~]$ gcc -O2 -Wall test1.c -pthread && ./a.out
    test1.c:1:20: warning: missing whitespace after the macro name
    thread stack size is 800000.
    thread stack size2 is 800000.
    [arekm@arm ~]$ gcc -O2 -Wall test1.c -pthread && ./a.out
    test1.c:1:20: warning: missing whitespace after the macro name
    thread stack size is 800000.
    thread stack size2 is 800000.
    [arekm@arm ~]$ gcc -O2 -Wall test1.c -pthread && ./a.out
    test1.c:1:20: warning: missing whitespace after the macro name
    thread stack size is 800000.
    thread stack size2 is 800000.
    [arekm@arm ~]$ gcc -O2 -Wall test1.c -pthread && ./a.out
    test1.c:1:20: warning: missing whitespace after the macro name
    thread stack size is 800000.
    thread stack size2 is 800000.
    
    stack size seems contant but... let set rlimit to unlimited value
    
    [arekm@arm ~]$ ulimit -s unlimited
    [arekm@arm ~]$ ulimit -a
    -t: cpu time (seconds)         unlimited
    -f: file size (blocks)         unlimited
    -d: data seg size (kbytes)     unlimited
    -s: stack size (kbytes)        unlimited
    -c: core file size (blocks)    0
    -m: resident set size (kbytes) unlimited
    -u: processes                  unlimited
    -n: file descriptors           1024
    -l: locked-in-memory size (kb) 32
    -v: address space (kb)         unlimited
    -x: file locks                 unlimited
    -i: pending signals            8183
    -q: bytes in POSIX msg queues  819200
    -N 13:                         0
    -N 14:                         0
    [arekm@arm ~]$ gcc -O2 -Wall test1.c -pthread && ./a.out
    test1.c:1:20: warning: missing whitespace after the macro name
    thread stack size is 54FBAD179000.
    thread stack size2 is 54FBAD179000.
    [arekm@arm ~]$ gcc -O2 -Wall test1.c -pthread && ./a.out
    test1.c:1:20: warning: missing whitespace after the macro name
    thread stack size is 5466D4277000.
    thread stack size2 is 5466D4277000.
    [arekm@arm ~]$ gcc -O2 -Wall test1.c -pthread && ./a.out
    test1.c:1:20: warning: missing whitespace after the macro name
    thread stack size is 548C6FDFD000.
    thread stack size2 is 548C6FDFD000.
    [arekm@arm ~]$ gcc -O2 -Wall test1.c -pthread && ./a.out
    test1.c:1:20: warning: missing whitespace after the macro name
    thread stack size is 550306109000.
    thread stack size2 is 550306109000.
    
    
    and that's exactly what make does (that's why it wasn't visible without using make):
    
    [arekm@arm ~]$ ulimit -s 8192
    [arekm@arm ~]$ gcc -DMAX -O2 -Wall test1.c -pthread && ./a.out
    test1.c:1:20: warning: missing whitespace after the macro name
    thread stack size is 5553305D8000.
    thread stack size2 is 5553305D8000.
    [arekm@arm ~]$ gcc -DMAX -O2 -Wall test1.c -pthread && ./a.out
    test1.c:1:20: warning: missing whitespace after the macro name
    thread stack size is 5502E3DFE000.
    thread stack size2 is 5502E3DFE000.
    [arekm@arm ~]$ gcc -DMAX -O2 -Wall test1.c -pthread && ./a.out
    test1.c:1:20: warning: missing whitespace after the macro name
    thread stack size is 5537F5E02000.
    thread stack size2 is 5537F5E02000.
    
    
    
    #define _GNU_SOURCE=1
    
    #include <stdio.h>
    #include <pthread.h>
    #include <sys/time.h>
    #include <sys/resource.h>
    
    int main() {
    
        size_t stackSize = 0;
        size_t stackSize2 = 0;
    
        pthread_attr_t threadAttr;  /* This will hold the thread attributes for
                                     * the current thread. */
    
    #ifdef MAX
        struct rlimit r;
    
        r.rlim_cur = RLIM_INFINITY;
        r.rlim_max = RLIM_INFINITY;
    
        setrlimit(RLIMIT_STACK, &r);
    #endif
    
    
        if (pthread_attr_init(&threadAttr) != 0) {
            return -1;
        }
    
        if (pthread_getattr_np(pthread_self(), &threadAttr) != 0) {
            pthread_attr_destroy(&threadAttr);
            return -1;
        }
    
        if (pthread_attr_getstacksize(&threadAttr, &stackSize) != 0) {
            pthread_attr_destroy(&threadAttr);
            return -1;
        }
    
        if (pthread_attr_getstacksize(&threadAttr, &stackSize2) != 0) {
            pthread_attr_destroy(&threadAttr);
            return  -1;
        }
    
        printf("thread stack size is %ZX.\n", stackSize);
        printf("thread stack size2 is %ZX.\n", stackSize2);
    
        pthread_attr_destroy(&threadAttr);
    
        return 0;
    }
    
    
    
  2. login: "arekm"
  3. mimetype: "text/plain"
  4. username: "arekm"