GMP 5.1.1: Valgrind reports incorrect read in __gmpn_copyd (called from __gmpz_mul_2exp)
bodrato at mail.dm.unipi.it
bodrato at mail.dm.unipi.it
Sat Feb 23 12:09:05 CET 2013
Ciao,
Il Ven, 22 Febbraio 2013 4:30 pm, Alexander Kruppa ha scritto:
> How do you assume that I do not care for efficiency?
Did I?
>> I attach a draft proposal I wrote looking at Valgrind documentation. It
> It marks bytes as addressable even though they do not correspond to
> allocated memory - as far as I can tell, it would have the same effect
> as --partial-loads-ok=yes (it that option were working correctly).
Unfortunately it doesn't, --partial-loads-ok=yes is more appropriate!
The work-around I proposed (you said that unfortunately this Valgrind
option is not working for this specific case) is much worse, because it
hides to Valgrind unconditional read and WRITE access to the area outside
the allocated portion.
> If the code wants to access memory as if it were allocated up to a
> 16-byte-aligned boundry, why not allocate enough up to a
> 16-byte-aligned boundry?
The code only loads in a register (and ignore) some bytes in the same
cache-line the CPU have read from memory. It does not need to have them
reserved "as if it were allocated". Allocating them would waste memory.
By the way, is there a way to ask malloc a 16-byte-aligned block?
> I.e., instead of telling the memory checker
> to ignore those invalid accesses, actually making them valid
You are right, this is not a very good strategy. The best one I can see is:
- patch Valgrind so that --partial-loads-ok=yes works also for SSE etc...;
- patch Valgrind so that this option can be selectively activated on a
per-function basis;
- write a short list (for each ABI) of functions that need this option.
In the meanwhile, there are some possible workaround. I rewrite a line you
may have missed in my previous message.
Try to "rm $(grep -rl fastsse mpn/x86_64)", before "./configure" .
> On a related note: Since _mp_alloc can be larger than _mp_size (and
...
> with valgrind client requests that set the limbs _mp_d[ABS(_mp_size)
> ... _mp_alloc-1] to undefined values on any mpz_t output operand. Mere
An option to enable this behavior can be useful, I agree, details should
be discussed in another thread.
Best regards,
m
--
http://bodrato.it/papers/
More information about the gmp-bugs
mailing list