Menu ▾ ▴

#2 Segmentation Fault

open
nobody
Other (2)
5
2008-04-04
2008-04-04
Anonymous
No

Using diffh caused me to cause a segmentation fault with the following error output.

localhost:~/Desktop/schemacrawler-5.5-distrib/schemacrawler uto$ diff -u venkatdb.txt venkatdb_new.txt | diffh > diffh.html
diffh(1940) malloc: *** error for object 0x302250: incorrect checksum for freed object - object was probably modified after being freed, break at szone_error to debug
diffh(1940) malloc: *** set a breakpoint in szone_error to debug
Segmentation fault

Discussion

  • Jim Quinlan

    Jim Quinlan - 2008-04-04

    Logged In: YES
    user_id=1790121
    Originator: NO

    I had a segfault too. I entered gdb, found the segfault at output.c:158. Looked at the code, and the malloc_size determination was broken (ie the new size was > 2x the old size). The fix worked for me, see below.

    JimQ

    >> /usr/bin/diff output.c~ output.c
    355,356c355,360
    < if (retsize_new+1 >= malloc_size)
    < ret = realloc(ret, (malloc_size*=2) * sizeof(char));
    ---
    > if (retsize_new+1 >= malloc_size) {
    > do {
    > malloc_size*=2;
    > } while (retsize_new+1 >= malloc_size);
    > ret = realloc(ret, malloc_size * sizeof(char));
    > }
    363c367,370
    < if (retsize_new+1 >= malloc_size)
    ---
    > if (retsize_new+1 >= malloc_size) {
    > do {
    > malloc_size*=2;
    > } while (retsize_new+1 >= malloc_size);
    364a372
    > }

     

Log in to post a comment.