Print

Print


I think you overestimate valgind. Consider the following example:

]=[czw 13/10/10 15:50 CEST]=[ljanyst@idefix:/tmp]
]==> cat malloctest.cc 

#include <iostream>
#include <cstring>

int main( int argc, char **argv )
{
  char *a = new char[100];
  char *b = new char[100];
  memset( a, 0, 100 );
  memset( b, 0, 100 );
  a[b-a+10] = 10;
  std::cout << (int)b[10] << std::endl;
  delete [] a;
  delete [] b;
}
]=[czw 13/10/10 15:50 CEST]=[ljanyst@idefix:/tmp]
]==> g++ malloctest.cc
]=[czw 13/10/10 15:50 CEST]=[ljanyst@idefix:/tmp]
]==> ./a.out   
10

This checks up fine with valgrind, even though it's obviously writing past the memory boundry.

If it comes to our case: the int holding socket descriptor got overwritten and we kept getting "invalid address" errors from the write syscall.


Reply to this email directly or view it on GitHub.



Use REPLY-ALL to reply to list

To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1