Liste des Groupes | Revenir à cl c |
=?UTF-8?Q?Josef_M=C3=B6llers?= <josef@invalid.invalid> writes:On 11.06.25 15:32, Mateusz Viste wrote: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.
valgrind.
Les messages affichés proviennent d'usenet.