This is the mail archive of the cygwin 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]
Other format: [Raw text]

Re: seg fault on file write in cygwin, please help!!!


On Thu, 18 Mar 2004 scyudits@MIT.EDU wrote:

> Hi,
>
> I am getting the following seg fault at the point in my C++ code where
> data gets written to a file.
>
> First, here is the code that is the source of the problem (should be
> correct):
>
> FILE *outfile = fopen("/home/Sophia/ns-allinone-2.27/ns-2.27/myfile.tcl", "w");
> fprintf(outfile, "%s", output);
>
> ...where output is a regular string (character array).
>
> Here is the backtrace from the seg fault, on running this code:
>
> (gdb) run
> Starting program: /home/Sophia/ns-allinone-2.27/ns-2.27/a.exe
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x610cfaa9 in wmemset () from /usr/bin/cygwin1.dll
> (gdb) backtrace
> [useless backtrace snipped]
>
> What's going on, and how do I fix this?
>
> Thanks,
> Sophia

Sophia,

First, please review the Cygwin problem reporting guidelines at
<http://cygwin.com/problems.html>, particularly the bit about attaching
(as an uncompressed text attachment) the output of "cygcheck -svr".

Second, please provide a simple (but complete) testcase program that
reproduces the problem on your machine, along with the exact compilation
instructions (preferably as a Makefile).  Make the testcase as small as
possible (e.g., output can be a constant string).

Third, please answer some questions about the context:
Does the crash happen with any filename?  Does the file exist?  If not, is
it created? Do all the intermediate directories exist?  What are the
permissions on the file and on the containing directory (both the "ls -l"
and the "getfacl" would be useful).

Once we have the information that would allow us to try to reproduce the
problem (and eliminate the obvious mistakes), we can start diagnosing what
can be wrong.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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