Bug 283374 (alloca)

Summary: monitoring alloca calls
Product: [Developer tools] valgrind Reporter: Zohar Gofer <zoharg>
Component: sgcheckAssignee: Julian Seward <jseward>
Status: RESOLVED DUPLICATE    
Severity: wishlist CC: tom
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Zohar Gofer 2011-10-05 07:32:25 UTC
Code like this:

int mvCmp(unsigned char* a_pKey1, unsigned char* a_pKey2, size_t a_iSize) const
{
  void* str1 = alloca(a_iSize);
  void* str2 = alloca(a_iSize);

  memcpy(str1, a_pKey1, a_iSize);
  memcpy(str2, a_pKey2, a_iSize);
...
}

Generates a false error of: Invalid write of size 4
and comment that: Address 0x22003700 is not derived from any known block
and suppression like this:
{
   <insert_a_suppression_name_here>
   exp-ptrcheck:Heap
   fun:memcpy
...
}

This means that ptrcheck thinks that memory is allocated on the heap instead of the stack. alloca calls should add the memory allocated to the stack analysis.
Comment 1 Tom Hughes 2011-10-05 07:41:59 UTC

*** This bug has been marked as a duplicate of bug 206618 ***