Liste des Groupes | Revenir à cl c |
=?UTF-8?Q?Josef_M=C3=B6llers?= <josef@invalid.invalid> writes:Sure. Or some people prefer to single-step with a debugger. Such people can make their lives a little easier by surrounding the buffer with sentinel soldiers, setting the sentinel soldiers to a magic number, and putting a watch on them both - the buffer high soldier and the buffer low soldier.On 11.06.25 15:32, Mateusz Viste wrote:valgrind.This might not be a strictly C question, but it definitely concerns all
C programmers.
>
Earlier today, I fixed an out-of-bounds write bug. An obvious issue:
>
static int *socks[0xffff];
>
void update_my_socks(int *sock, int val) {
socks[val & 0xffff] = sock;
}
>
While the presented issue is common knowledge for anyone familiar with
C, *locating* the bug was challenging. The program did not crash at the
moment of the out-of-bounds write but much later - somewhere entirely
different, in a different object file that maintained a static pointer
for tracking a position in a linked list. To my surprise, the pointer
was randomly reset to NULL about once a week, causing a segfault.
Tracing this back to an unrelated out-of-bounds write elsewhere in the
code was tedious, to say the least.
Les messages affichés proviennent d'usenet.