3.5.2 Valid-address (A) bits
Notice that the previous subsection describes how the validity of values is established and maintained without having to say whether the program does or does not have the right to access any particular memory location. We now consider the latter issue.
As described above, every bit in memory or in the CPU has an associated valid-value (V) bit. In addition, all bytes in memory, but not in the CPU, have an associated valid-address (A) bit. This indicates whether or not the program can legitimately read or write that location. It does not give any indication of the validity or the data at that location -- that's the job of the V bits -- only whether or not the location may be accessed.
Every time your program reads or writes memory, Memcheck checks the A bits associated with the address. If any of them indicate an invalid address, an error is emitted. Note that the reads and writes themselves do not change the A bits, only consult them.
So how do the A bits get set/cleared? Like this:
When the program starts, all the global data areas are marked as accessible.
When the program does malloc/new, the A bits for the exactly the area allocated, and not a byte more, are marked as accessible. Upon freeing the area the A bits are changed to indicate inaccessibility.
When the stack pointer register (%esp) moves up or down, A bits are set. The rule is that the area from %esp up to the base of the stack is marked as accessible, and below %esp is inaccessible. (If that sounds illogical, bear in mind that the stack grows down, not up, on almost all Unix systems, including GNU/Linux.) Tracking %esp like this has the useful side-effect that the section of stack used by a function for local variables etc is automatically marked accessible on function entry and inaccessible on exit.
When doing system calls, A bits are changed appropriately. For example, mmap() magically makes files appear in the process's address space, so the A bits must be updated if mmap() succeeds.
Optionally, your program can tell Valgrind about such changes explicitly, using the client request mechanism described above.
이런 말이 있는거 봐서는 mmap 도 체크가 되는 듯 하네요
궁금한게 있으면, 테스트 코드를 작성해서 에러가 검출 되나 테스트 해보시는 것도 괜찮을 듯 하네요.
[quote]3.5.2 Valid-address (A) bitsNo
이런 말이 있는거 봐서는 mmap 도 체크가 되는 듯 하네요
궁금한게 있으면, 테스트 코드를 작성해서 에러가 검출 되나 테스트 해보시는 것도 괜찮을 듯 하네요.
답변 감사드립니다. ^^
좋은 하루되세요.
OTL 즐!!!! (좌절 금지!!!)
[다른 질문] valgrind 쓰시는분들 옵션은 어떻게 넣으시나요?
안녕하세요.
valgrind 쓰시는분들 쓰실때 옵션은 어떻게 설정해놓고
쓰시나요?
OTL 즐!!!! (좌절 금지!!!)
댓글 달기