Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 69acc88f0b1316b470af7d225e1d2eabb71fb44f
Ticket: 1654104fffffffffffffffffffffffffffffffff
broken stack checking code
User & Date: mmaslano on 2007-02-07 12:46:56
Changes

  1. assignee changed to: "hobbs"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    on x86_64 kernel, 32-bit mock root, pthread_getattr_np returns in the initial thread how much the stack can actually grow at that point, if I try say:
    extern int TclpThreadGetStackSize(void); int main (void) { __builtin_printf
    ("%x\n", TclpThreadGetStackSize ()); }
    linked against -ltcl8.5 it prints aa650000
    
    TclpThreadGetStackSize it must return size_t
    
    TclpCheckStackSpace 
    if (tsdPtr->initialised == 0) we didn't compute stack size before. But, when GetStackSize was computed using pthread_getattr_np rather than say getrlimit this  assumption is wrong for the initial thread.  There
    pthread_getattr_np changes over time, as memory is mmapped/unmapped, with RLIMIT_STACK being the upper limit for it.
    
    TclpCheckStackSpace ptrdiff_t is a signed type and if tsdPtr->stackSize is bigger than half of the address space. For Linux and most other targets ptrdiff_t is the same size as size_t, only
    size_t is unsigned, so guess just
    -    if (stackUsed < (ptrdiff_t) tsdPtr->stackSize) {
    +    if ((size_t) stackUsed < tsdPtr->stackSize) {
    and a fix for TclpThreadGetStackSize return value could be enough.
    
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "mmaslano"
  10. subsystem changed to: "41. Memory Allocation"
  11. title changed to: "broken stack checking code"
  12. type changed to: "Patch"