Overview
| Artifact ID: | 6e1e249d0e9830ac7b970f00885f7d0d718226b3 |
|---|---|
| Ticket: | 1618411fffffffffffffffffffffffffffffffff
TclpCheckStackSpace() fails on recent linux system |
| User & Date: | arekm on 2007-01-22 14:51:09 |
Changes
- icomment:
Logged In: YES user_id=139606 Originator: YES This test program reports stack size correctly so this works. In tcl pthread_getattr_np(pthread_self(), &threadAttr) fills threadAttr with crap. I can easily reproduce that by calling pthread_getattr_np NOT from thread. Let's strace tclsh: [root@db01new bin]# strace -o WYNIK -f -F -s 200 ./tclsh8.5 xyz 46955385561024 thread stack size is 93782034972672. % exit and now see what it did: [root@db01new bin]# grep -E "(clone|thread stack size)" WYNIK 13270 clone(child_stack=0x40200270, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED, parent_tidptr=0x402009f0, tls=0x40200960, child_tidptr=0x402009f0) = 13271 13270 write(1, "thread stack size is 93782034972672.\n", 37) = 37 For me it looks like main process 13270 called pthread_create() which created thread with pid 13271 and later called pthread_getattr_np() from main process instead of from newly created thread... which leads to crap being filled, right? [root@db01new ~]# ulimit -a time(cpu-seconds) unlimited file(blocks) unlimited coredump(blocks) 0 data(kbytes) unlimited stack(kbytes) unlimited lockedmem(kbytes) 32 memory(kbytes) unlimited nofiles(descriptors) 1024 processes unlimited vmemory(kbytes) unlimited flocks unlimited [root@db01new ~]# ./a.out xyz 1075841376 thread stack size is 2101248. #define _GNU_SOURCE=1 #include <stdio.h> #include <pthread.h> #include <sys/time.h> #include <sys/resource.h> void *testme(void *threadid) { size_t stackSize = 0; pthread_attr_t threadAttr; printf("xyz %ld\n", pthread_self()); if (pthread_getattr_np(pthread_self(), &threadAttr) != 0) { pthread_attr_destroy(&threadAttr); pthread_exit(NULL); return NULL; } if (pthread_attr_getstacksize(&threadAttr, &stackSize) != 0) { pthread_attr_destroy(&threadAttr); pthread_exit(NULL); return NULL; } printf("thread stack size is %Zu.\n", stackSize); pthread_attr_destroy(&threadAttr); pthread_exit(NULL); } int main() { int rc; long t; pthread_t thr; struct rlimit r; r.rlim_cur = RLIM_INFINITY; r.rlim_max = RLIM_INFINITY; rc = setrlimit(RLIMIT_STACK, &r); if (rc) { printf("ERROR; setrlimit failed %d\n", rc); return -1; } rc = pthread_create(&thr, NULL, testme, (void *)t); if (rc){ printf("ERROR; return code from pthread_create() is %d\n", rc); return -1; } pthread_exit(NULL); return 0; } ps, from nptl headers: /* Initialize thread attribute *ATTR with attributes corresponding to the already running thread TH. It shall be called on unitialized ATTR and destroyed with pthread_attr_destroy when no longer needed. */ extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW __nonnull ((2)); while currently tcl initializes pthread_attr_t prior to calling pthread_getattr_np. - login: "arekm"
- mimetype: "text/plain"
- username: "arekm"