This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

1.3.2: Seg Fault (seemingly) Caused by fopen / symlink_info / GetFileAttributesA

Hello cygwin experts,

I am attempting to port a large application to the Cygwin environment (1.3.2
release on Windows 2000).  The application has previously been ported to and
run on both Win2000 using Visual C++ and on Redhat using gcc with no
(similar or as catastrophic) problems.  However, I have run into a seg fault
while testing the port to Cygwin that I cannot seem to understand or get

The application opens (ie, dlopen()'s) and uses DLLs from a library.  Calls
to a function in a DLL suddenly stop working during application set up.  I
debugged my program, stepping through it, and narrowed the problem down to a
call to fopen.  The call to fopen returns a valid file pointer (FILE *)
value that can be fscanf'ed with no problem, however any call to the
function in the DLL after that causes a segfault (variables from the DLL are
suddenly "Address 0x... out of bounds").  In simpler words, if I have the
following code:

  fptr = fopen("FGlibaries/boxes/internal/dequeue","r");

where TEST_DLL() tests the function in the DLL:  The first test returns
success and the second test segfaults and crashes the application.

I downloaded the Cygwin sources and compiled them with -g to further
investigate.  I am not sure how to interpret the results of this or what to
try next.  After fast forwarding to the call to fopen in question, I did a

  (gdb) disp TEST_DLL()

and stepped through my application.  The last few lines of the step through
are as follows:

symlink_info::check (this=0x2d0e574,
    path=0x2d0e454 "c:\\gedev\\user\\redhat\\FGlibraries\\boxes\\internal",
    suffixes=0x0, opt=33) at /cygwin/src/winsup/cygwin/
1: TEST_DLL() = 1
1: TEST_DLL() = 1
0x61067d34 in GetFileAttributesA@4 () at
1: TEST_DLL() = 1
0x77e83b81 in _libkernel32_a_iname ()
1: TEST_DLL () = 1
Single stepping until exit from function _libkernel32_a_iname,
which has no line number information.

Breakpoint 2, strncpy (
    dst0=0x2d0e2d4 "v/system/FGlibraries/boxes/internal/dequeue",
    count=260) at /cygwin/src/newlib/libc/string/strncpy.c:91
1: TEST_DLL () =
Program received signal SIGSEGV, Segmentation fault.
Disabling display 1 to avoid infinite recursion.
0x29ed9b68 in internal_offset (name=0x58968a "granularity",
    table=0x5898bd, offsets=0x589b68) at ../../lots_of_dirs/my_C_code_file.c

The call to TEST_DLL() segfaults (after numerous previous calls went through
fine), and it appears as if it seg faults because values in
internal_offset() parameters "table" and "offsets" are corrupted by
something deep inside the fopen() function.

Enclosed is a call to "cygcheck" for all my system setup info.  Does anyone
have any recommendations on where to go from here?  I am not sure how or
whether to try to dig deeper into the GetFileAttributesA() function or

* Is it possible to make -g compiled versions of libkernel32?  Would doing
this provide information I could use to solve this problem?

* Is there a problem related to using a symbolic link (since the function
this error happens in seems to be related to that)?  The file and path to it
do not appear as symbolic links in Cygwin.

Does anyone have any suggestions on workarounds or other possible causes for
my problem?

Any help would be greatly appreciated.  I would very much like to have my
application supported on Cygwin, but I seem to be very stuck currently.

Thank you very much,
jim steed


Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]