Bug in ln / cygwin1.dll
Sat May 4 08:48:00 GMT 2002
> >> >When I run 'make -f Makefile.cvs' with QT3, I find that ln segfaults
> >> >to create a symlink. I've included the output of strace showing the
> >> >output of cygcheck and also the stackdump ln produces. I can reproduce
> >> >so if you need any more information, please ask. The problem occurs
> >> >latest Cygwin CVS.
> >> >ln is 'ln (fileutils) 4.1'.
> >> >cygwin is 'CYGWIN_NT-5.0 ADVENT02 1.3.11(0.52/3/2) 2002-05-03 15:18
> >> >unknown'
> >> You're using a locally built version of cygwin. Please run it under
> >> and pinpoint where the problem is occurring. You may find the
> >> in how-to-debug-cygwin.txt useful.
> >This patch fixes the problem.
In the destructor, the code checks if normalized_path is non-NULL before
callin cfree on it. However, normalized_path is never initialised to NULL,
so it seems that sometimes cfree gets called on some memory that was never
allocated and that is what is causing the segfault.
My reasoning for this is as follows: I ran ln under gdb and found where the
segfault is (in cfree). I used the stack backtrace to find that cfree was
being called in path_conv::clear_normalized_path. gdb reported that the
normalized_path variable in this scope was an illegal non-NULL pointer. The
only time normalized_path is set is in path_conv::check, where it is
assigned to cstrdup (path_copy);
I guessed that only one of three things could have happened:
i) cstrdup() was returning an illegal pointer
ii) the pointer was getting corrupted somehow
iii) the pointer was never initialised to NULL in the first place
Looking at the constructor for path_conv I saw that indeed iii) was true.
Now one of the other points may have been true as well, but by initialising
normalized_path to NULL in the constructor of path_conv, the problem went
I hope this explaination is satisfactory.
More information about the Cygwin-patches