From: Sebastian <sc...@nb...> - 2003-03-28 19:44:43
|
Hi, On Fri, Mar 28, 2003 at 01:43:16PM -0500, Peter H Smith wrote: > When I run a program under valgrind, pthread_self() will return a number > between 1 and 50. This doesn't catch some latent errors. Consider this > simplification of some bone-headed trace code: > #define PENNY_WISE 5 > char header[PENNY_WISE]; > sprintf(header, "%d: ", pthread_self()); > fprintf(stderr, "%s%s\n", header, message); > There is a latent buffer overrun here that won't be tripped under Valgrind > because thread ids are always small. I'd like to be able to set the base > thread id to something like 0x800000000 or 0xFFFF0000 and test to be sure > this buffer nonsense is not a problem. While configurability might be a nice thing in general, this might be too much. I have never seen code like the one you gave as example (and I have audited quite a lot open source applications). What might be nice in general would be to simulate a behaviour similar to the native implementation. I.e. if libpthread gives high TID's, then valgrind should, too. But as I have never dabbled with this features of valgrind, this might be off the road, though. Also, the program might also just misbehave on small TID's and behave correctly at large TID's. Or produce a buffer overflow at small TID's. Or negative ones. Etc. That quickly leads to "fuzzing" the application with random data that might produce faults. One can use other examples such as "malloc(0)", which I have seen in real code to produce process-wide unique-id's. Valgrind or any other malloc implementation might change this and return a constant (as zero bytes can never be used), hence break the program. Or they do not. The point is, if programs are broken without valgrind, valgrind should not try to produce specific bordercases that might cause trouble. (My point of view, but maybe the valgrind developers can support/nullify my points ;-) > Peter H. Smith > Advisory Software Engineer > xSeries Systems Management > IBM Server Group ciao, Sebastian -- -. sc...@nb... -. + http://segfault.net/~scut/ `--------------------. -' segfault.net/~scut/pgp `' 5453 AC95 1E02 FDA7 50D2 A42D 427E 6DEF 745A 8E07 `- 4 BLU-82/MOAB articles offered, payment due. hi echelon! -----------------' |