This patch fixes the problem of elkhound segfaulting while generating cc.gr.gen.cc on Cygwin. To apply the patch: $ cd elkhound $ patch < fix.emitcode.patch Index: emitcode.cc =================================================================== RCS file: /home/cvs-repository/elkhound/emitcode.cc,v retrieving revision 1.5 diff -c -r1.5 emitcode.cc *** emitcode.cc 1 Mar 2005 11:34:32 -0000 1.5 --- emitcode.cc 28 Jun 2005 09:58:49 -0000 *************** *** 5,10 **** --- 5,11 ---- #include "syserr.h" // xsyserror #include "srcloc.h" // SourceLoc #include "trace.h" // tracingSys + #include // memcpy EmitCode::EmitCode(rostring f) : stringBuilder(), *************** *** 41,47 **** p++; } ! os << *this; setlength(0); } --- 42,76 ---- p++; } ! #if 0 ! // this is the original code ! os << *this; ! #else ! // 2005-06-28: There is a bug in the cygwin implementation of ! // ofstream::operator<< that causes a stack overflow segfault ! // when writing strings longer than about 2MB. So, I will ! // manually break up the string into little chunks to write it. ! ! // how long is the string? ! int len = p - c_str(); ! ! enum { SZ = 0x1000 }; // write in 4k chunks ! p = c_str(); ! ! while (len >= SZ) { ! char buf[SZ+1]; ! memcpy(buf, p, SZ); ! buf[SZ] = 0; ! ! os << buf; ! ! p += SZ; ! len -= SZ; ! } ! ! os << p; ! #endif ! setlength(0); }