[1.7] Weird error "grep: writing output: Cannot allocate memory"

Dave Korn dave.korn.cygwin@googlemail.com
Mon May 4 15:09:00 GMT 2009

Christopher Faylor wrote:

>>  The attached STC reproduces the problem, and apparently:
>> gcc-3 -mno-cygwin stc.c -o stc -W -Wall -g -O0 -o stc-mingw.exe
>> gcc-4 stc.c -o stc -W -Wall -g -O0
>> .. it is cygwin independent, since both executables produce similar results:
> A test case which demonstrates a failing Windows call fail isn't really
> interesting as far as Cygwin is concerned.  Do you have a stc which
> fails using Cygwin's API?

  For completeness' sake, here is a testcase at the cygwin api level; note the
lack of any output and the ENOMEM return.

admin@ubik /tmp/console
$ gcc-4 stc-cyg.c -Wall -W -Wextra
stc-cyg.c:20: warning: unused parameter 'argc'
stc-cyg.c:20: warning: unused parameter 'argv'

admin@ubik /tmp/console
$ ./a.exe
Len is 29462
error B1 12 -1
error B2 12 1
Actual: 29446

admin@ubik /tmp/console

  The earlier testcase I posted based on the win32 api was reduced from what
eventually takes place inside fhandler_console::write_normal():


Breakpoint 11, fhandler_console::write_normal (this=0x6122c42c,
    src=0x6ab898 "  411  ./libtool --tag=CXX --mode=link
/gnu/gcc/obj4/./gcc/xgcc -shared-libgcc -B/gnu/gcc/obj4/./gcc -nostdinc++
    end=0x6b2b9e "") at /gnu/winsup/src/winsup/cygwin/fhandler_console.cc:1549
1549              if (!WriteConsoleW (get_output_handle (), buf, buf_len,
&done, 0))
(gdb) print buf
$15 = (PWCHAR) 0x6680a8
(gdb) print buf_len
$16 = <value optimized out>
(gdb) bt
#0  fhandler_console::write_normal (this=0x6122c42c,
    src=0x6ab898 "  411  ./libtool --tag=CXX --mode=link
/gnu/gcc/obj4/./gcc/xgcc -shared-libgcc -B/gnu/gcc/obj4/./gcc -nostdinc++
    end=0x6b2b9e "") at /gnu/winsup/src/winsup/cygwin/fhandler_console.cc:1549
#1  0x610331e8 in fhandler_console::write (this=0x6122c42c, vsrc=0x6ab898,
    len=29446) at /gnu/winsup/src/winsup/cygwin/fhandler_console.cc:1653
#2  0x610cb4f9 in writev (fd=1, iov=0x22c9e4, iovcnt=1)
    at /gnu/winsup/src/winsup/cygwin/syscalls.cc:926
#3  0x610cb61f in write (fd=1, ptr=0x6ab898, len=29446)
    at /gnu/winsup/src/winsup/cygwin/syscalls.cc:805
#4  0x61139b89 in _write_r (ptr=0x22d008, fd=1, buf=0x6ab898, cnt=29446)
    at /gnu/winsup/src/newlib/libc/reent/writer.c:58
#5  0x611074f4 in _fflush_r (ptr=0x22d008, fp=0x61146780)
    at /gnu/winsup/src/newlib/libc/stdio/fflush.c:200
#6  0x61124fcc in __sfvwrite_r (ptr=0x22d008, fp=0x61146780, uio=0x22ca98)
    at /gnu/winsup/src/newlib/libc/stdio/fvwrite.c:257
#7  0x61107e9a in _fwrite_r (ptr=0x22d008, buf=0x6944e4, size=1, count=29446,
    fp=0x61146780) at /gnu/winsup/src/newlib/libc/stdio/fwrite.c:124
#8  0x61107f55 in fwrite (buf=0x6944e4, size=1, count=29446, fp=0x61146780)
    at /gnu/winsup/src/newlib/libc/stdio/fwrite.c:141
#9  0x610b2148 in _sigfe () from /usr/bin/cygwin1.dll

  I'll get on with trying a freshly built DLL now.


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/

More information about the Cygwin mailing list