Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: brk() missing under CYgwin



Cygwin does not have brk() and --enable-zsh-mem fails. Unfortunately, after I
recompiled with sbrk() and zsh-mem and zsh-secure-free I got tons of

BUG: attempt to free storage at invalid address

The first one is in createparamtable() at lime 500 (zfree(hostnam, 256);)

This GDB was configured as "i686-pc-cygwin"...
(gdb) break mem.c:960
Breakpoint 1 at 0x4366cc: file /usr/src/zsh/Src/mem.c, line 960.
(gdb) break mem.c:992
Breakpoint 2 at 0x43682d: file /usr/src/zsh/Src/mem.c, line 992.
(gdb) break mem.c:1066
Breakpoint 3 at 0x436e2b: file /usr/src/zsh/Src/mem.c, line 1066.
(gdb) run -f
Starting program: /usr/build/zsh/Src/zsh.exe -f

Breakpoint 3, zfree (p=0xa05c380, sz=0) at /usr/src/zsh/Src/mem.c:1066
1066    /usr/src/zsh/Src/mem.c: No such file or directory.
(gdb) where
#0  zfree (p=0xa05c380, sz=0) at /usr/src/zsh/Src/mem.c:1066
#1  0x43e22c in createparamtable () at /usr/src/zsh/Src/params.c:500
#2  0x4260c7 in setupvals () at /usr/src/zsh/Src/init.c:712
#3  0x4012ba in main (argc=2, argv=0xa057fd8) at /usr/src/zsh/Src/main.c:90
#4  0x610024a2 in _size_of_stack_reserve__ ()
#5  0x61002775 in _size_of_stack_reserve__ ()
#6  0x610027b4 in _size_of_stack_reserve__ ()
#7  0x4c075c in cygwin_crt0 ()

This does not happen on Unix, so I presume this indicates some  problem in
Cygwin; at least, it does not depend on my environment patch :-)

I'm not sure what to do. Could anybody who knows Zsh memory allocator better
look at it? Reporting to Cygwin guys at this stage hardly helps.

This is with cygwin-1.1.3-1 (prerelease) and latest binutils (downloaded
today).

-andrej

Have a nice DOS!
B >>

Index: configure.in
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.in,v
retrieving revision 1.14
diff -u -r1.14 configure.in
--- configure.in        2000/07/26 10:09:47     1.14
+++ configure.in        2000/07/27 16:53:30
@@ -861,7 +861,9 @@
               getrlimit \
               setlocale \
               uname \
-              signgam)
+              signgam\
+              putenv getenv \
+              brk sbrk)
 AC_FUNC_STRCOLL

 if test $ac_cv_func_setpgrp = yes; then
Index: Src/mem.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/mem.c,v
retrieving revision 1.1.1.19
diff -u -r1.1.1.19 mem.c
retrieving revision 1.1.1.19
diff -u -r1.1.1.19 mem.c
--- Src/mem.c   2000/03/16 01:49:19     1.1.1.19
+++ Src/mem.c   2000/07/27 16:53:39
@@ -1118,7 +1118,12 @@
        long n = (m_lfree->len - M_MIN - M_KEEP) & ~(m_pgsz - 1);

        m_lfree->len -= n;
+#ifdef HAVE_BRK
        if (brk(m_high -= n) == -1) {
+#else
+       m_high -= n;
+       if (sbrk(-n) == (void *)-1) {
+#endif /* HAVE_BRK */
            DPUTS(1, "MEM: allocation error at brk.");
        }



Messages sorted by: Reverse Date, Date, Thread, Author