On Sat, 8 Dec 2007, Tom Hughes wrote: >> I think it is a problem with the fast comparison. I've reproduced the bug, >> and when I added an explicit slow comparison function, it behaves correctly. >> I'll keep looking... > > I came to that conclusion as well, but had to go out before I had a > chance to send another mail. > > Thinking about it as I was walking to the station I suddenly realised > that the fast case comparison is treating the addresses as Word types > which are signed, so the high address in this case becomes negative > and appears to come before the other address.
The thing is, as long as the comparison is always done the same way, it should work. The ordering won't be right if we treat the values as unsigned addresses, but they will be right if we treat the values as signed words. I thought I had reproduced the bug, but all I've reproduced is the unexpected ordering -- I can't actually get the assertion failure on the lookup. AFAICT, 'fast_cmp' and 'avl_lookup' are the only two functions that do the fast comparisons. And they seem to be doing the same thing -- they treat the words as signed, do a subtraction, the result is treated as signed, and the result is checked for < 0 or > 0. Tom, can you try the following. In createSecVBitTable(), change the NULL parameter passed to OSetGen_Create to 'mycmp', and define 'mycmp' as follows: Word mycmp( void* key, void* elem ) { Addr a1 = *(Addr*)key; SecVBitNode* n = (SecVBitNode*)elem; Addr a2 = n->a; if (a1 < a2) return -1; if (a1 > a2) return 1; return 0; } This does give the ordering that we expect for Addrs. Does the assertion still occur in this case? Nick ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Valgrind-developers mailing list Valgrind-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-developers