[nhc-bugs] Linux install troubles

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Wed Apr 12 07:18:35 EDT 2006


[ original message delayed through spam filtering ]

Doug McIlroy <doug at cs.dartmouth.edu> wrote:

> On Fedora Linux, I fetched nhc98-1.18.tar.gz (Linux executable).
> 
> Got some relatively innocuous diagnostics from configure and make
> install, but one stood out:
> 
> ./configure: line 594: src/runtime/nhc98heap.c: No such file or
> directory

In the binary tarball, the directory src/runtime does not exist, so
writing a file into it fails.  However, line 594 of the configure script
is protected by a test on the existence of directory src/, so I'm a
little unsure why it even got there.

> Bulling through anyway, I did an installation. and compiled a hello
> world program. The result appears to be related to the configure
> trouble:

It is not related, no.

> OS allocated a heap in high memory (>0x80000000)
>     which breaks this program's run-time system.
>   hpStart=0xb7d96008, hpEnd=0xb7e0b308

This is a known bug, triggered by more recent versions of Linux.  I
attach a source patch which is claimed to work around the problem
(tested on a Fedora system).  It isn't a full fix, but should avoid
high-memory allocation in many circumstances.

Regards,
    Malcolm
-------------- next part --------------
Index: src/runtime/Kernel/collector.c
===================================================================
RCS file: /home/cvs/root/nhc98/src/runtime/Kernel/collector.c,v
retrieving revision 1.24
retrieving revision 1.26
diff -u -r1.24 -r1.26
--- src/runtime/Kernel/collector.c	7 Mar 2005 16:53:38 -0000	1.24
+++ src/runtime/Kernel/collector.c	28 Mar 2006 09:21:11 -0000	1.26
@@ -9,6 +9,7 @@
 
 /*#define HEAPSIZE 100000  -- defined in top-level Makefile at config-time */
 #define GCSTACKSIZE 20000
+#define SBRK 1	/* Use sbrk(2) instead of malloc(3) to allocate the heap */
 
 WHEN_DYNAMIC(int ractive = 0;)
 
@@ -46,7 +47,13 @@
   Int totalSize = hpSize+spSize;
   Int tableSize = (totalSize+WORDSIZE)/(WORDSIZE+1)+1; /* Last one for end of marked */
 
-  if(NULL == (hpStart = malloc ((int)totalSize * sizeof(Node)))) {
+  if (
+#if SBRK
+      ((NodePtr)-1)== (hpStart = (NodePtr)sbrk((int)totalSize * sizeof(Node)))
+#else
+      NULL == (hpStart = malloc ((int)totalSize * sizeof(Node)))
+#endif
+     ) {
     fprintf(stderr,"Not enough memory for heap and stack.\n");
     exit(-1);
   }


More information about the Nhc-bugs mailing list