2012-02-03 It seems as if I've found the reason to my problem: ==10523== Invalid write of size 4 ==10523== at 0x80581C9: seq_addmsg (seq_add.c:161) ==10523== by 0x805659C: seq_setcur (seq_setcur.c:16) ==10523== by 0x80530C8: m_draft (m_draft.c:68) ==10523== by 0x804A2A5: main (comp.c:177) ==10523== Address 0x41d1444 is 4 bytes before a block of size 400 alloc'd This is part of the output of valgrind. Using valgrind is easy: Install it; compile with `-g -O0'; run `valgrind ./a.out' and watch the messages appearing. There's no need to link special libraries and stuff. It's just too easy. :-) Having eliminated this illegal memory access, the program runs fine. And here's something cute. Although this didn't helped me in the end, it may be useful in other cases: #define free(x) \ fprintf(stderr, "freeing %p at %s: %d\n", (x), __FILE__, __LINE__); \ free(x); http://marmaro.de/lue/ markus schnalke