|
From: Bert W. <ber...@go...> - 2010-07-19 16:41:50
|
Hi all, I would have expected, that when I do a read access on a memory location (ie. dereference the pointer), which was previously marked with VALGRIND_MAKE_MEM_UNDEFINED(), I get an error message from the memcheck tool. But I don't. I also don't get an error, when I do a read access on a pointer freshly returned from malloc(). I do get the "param write(buf) points to uninitialised byte(s)" warning, when I pass the pointer to write(2), but why not for a simple dereference statement? Thanks, Bert |
|
From: Bart V. A. <bva...@ac...> - 2010-07-19 16:58:55
|
On Mon, Jul 19, 2010 at 6:41 PM, Bert Wesarg <ber...@go...> wrote: > > I would have expected, that when I do a read access on a memory > location (ie. dereference the pointer), which was previously marked > with VALGRIND_MAKE_MEM_UNDEFINED(), I get an error message from the > memcheck tool. But I don't. I also don't get an error, when I do a > read access on a pointer freshly returned from malloc(). I do get the > "param write(buf) points to uninitialised byte(s)" warning, when I > pass the pointer to write(2), but why not for a simple dereference > statement? (resending as plain text) Memcheck doesn't complain at the time an undefined value is read but at the time a conditional jump depends on an uninitialized value. A quote from the memcheck manual (http://valgrind.org/docs/manual/mc-manual.html): It is important to understand that your program can copy around junk (uninitialised) data as much as it likes. Memcheck observes this and keeps track of the data, but does not complain. A complaint is issued only when your program attempts to make use of uninitialised data in a way that might affect your program's externally-visible behaviour. Bart. |
|
From: Bert W. <ber...@go...> - 2010-07-19 17:00:57
|
On Mon, Jul 19, 2010 at 18:51, Bart Van Assche <bar...@gm...> wrote: > On Mon, Jul 19, 2010 at 6:41 PM, Bert Wesarg <ber...@go...> wrote: >> >> I would have expected, that when I do a read access on a memory >> location (ie. dereference the pointer), which was previously marked >> with VALGRIND_MAKE_MEM_UNDEFINED(), I get an error message from the >> memcheck tool. But I don't. I also don't get an error, when I do a >> read access on a pointer freshly returned from malloc(). I do get the >> "param write(buf) points to uninitialised byte(s)" warning, when I >> pass the pointer to write(2), but why not for a simple dereference >> statement? > > Memcheck doesn't complain at the time an undefined value is read but > at the time a conditional jump depends on an uninitialized value. A > quote from the memcheck manual > (http://valgrind.org/docs/manual/mc-manual.html): > > It is important to understand that your program can copy around junk > (uninitialised) data as much as it likes. Memcheck observes this and > keeps track of the data, but does not complain. A complaint is issued > only when your program attempts to make use of uninitialised data in a > way that might affect your program's externally-visible behaviour. Thanks for the explanation. That makes perfectly sense. Bert > > Bart. > |
|
From: WAROQUIERS P. <phi...@eu...> - 2010-07-20 10:58:28
|
>> On Mon, Jul 19, 2010 at 6:41 PM, Bert Wesarg ><ber...@go...> wrote: >>> >>> I would have expected, that when I do a read access on a memory >>> location (ie. dereference the pointer), which was previously marked >>> with VALGRIND_MAKE_MEM_UNDEFINED(), I get an error message from the >>> memcheck tool. But I don't. I also don't get an error, when I do a >>> read access on a pointer freshly returned from malloc(). I I think that if you use VALGRIND_MAKE_MEM_NOACCESS that you should get an error message as soon as you dereference. Philippe ____ This message and any files transmitted with it are legally privileged and intended for the sole use of the individual(s) or entity to whom they are addressed. If you are not the intended recipient, please notify the sender by reply and delete the message and any attachments from your system. Any unauthorised use or disclosure of the content of this message is strictly prohibited and may be unlawful. Nothing in this e-mail message amounts to a contractual or legal commitment on the part of EUROCONTROL, unless it is confirmed by appropriately signed hard copy. Any views expressed in this message are those of the sender. |
|
From: Bert W. <ber...@go...> - 2010-07-20 11:00:04
|
On Tue, Jul 20, 2010 at 12:29, WAROQUIERS Philippe <phi...@eu...> wrote: > > >>> On Mon, Jul 19, 2010 at 6:41 PM, Bert Wesarg >><ber...@go...> wrote: >>>> >>>> I would have expected, that when I do a read access on a memory >>>> location (ie. dereference the pointer), which was previously marked >>>> with VALGRIND_MAKE_MEM_UNDEFINED(), I get an error message from the >>>> memcheck tool. But I don't. I also don't get an error, when I do a >>>> read access on a pointer freshly returned from malloc(). I > > I think that if you use VALGRIND_MAKE_MEM_NOACCESS that you should get > an error message as soon as you dereference. But we have talked about VALGRIND_MAKE_MEM_UNDEFINED(), not VALGRIND_MAKE_MEM_NOACCESS(). Dereferencing a pointer which points into a NOACCESS area produces the correct "Invalid read/write" message. Bert > > Philippe > > ____ > > This message and any files transmitted with it are legally privileged and intended for the sole use of the individual(s) or entity to whom they are addressed. If you are not the intended recipient, please notify the sender by reply and delete the message and any attachments from your system. Any unauthorised use or disclosure of the content of this message is strictly prohibited and may be unlawful. > > Nothing in this e-mail message amounts to a contractual or legal commitment on the part of EUROCONTROL, unless it is confirmed by appropriately signed hard copy. > > Any views expressed in this message are those of the sender. > |