Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Steven White <srw@isis.ps.uci.edu>
Subject: A problem porting sbrk
Date: Fri, 21 Feb 1997 18:01:50 -0800 (PST)	[thread overview]
Message-ID: <199702220201.SAA22132@hedrock.ps.uci.edu> (raw)

I have a problem for you sophisticated linux-alpha kernel hackers...

I'm trying to port some code compiled on a Digital UNIX V3.2C 
machine to an 500 MHz 21164 alpha linux machine, running Red Hat 
Linux 4.1, Kernel 2.0.27. It appears that sbrk doesn't work
right when I do this. Here is a simple test:

file tbrk.c:
#include <stdio.h>

extern void * sbrk(long inc);

int main()
    {

    double *pa;
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);
    pa = sbrk(20000000); printf("%ld\n",(long)pa); printf("%f\n",*pa);

    }

Now run on the Digital Unix machine:
5368734016
0.000000
5388734016
0.000000
5408734016
0.000000
5428734016
0.000000
5448734016
0.000000
5468734016
0.000000
5488734016
0.000000
5508734016
0.000000
5528734016
0.000000
5548734016
0.000000
-1
Segmentation fault

This does what you expect. It gets lots of memory (200 Meg, on a 160 Meg
machine), then dies in the appropriate fashion. 

Now I compile with 
cc -g -non_shared tbrk.c -o tbrk, 
move it to the 256 Meg linux machine, and I get

5368734016
0.000000
5388734016
0.000000
5408734016
0.000000
5428734016
0.000000
5448734016
0.000000
5468734016
Segmentation fault

It gets about 100 Meg of memory, then dies.
The last address is out of bounds, and I didn't get the -1 error
indicator.

Does anyone understand this or have any suggestions?

		Steve White
		UC Irvine Dept of Physics

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

             reply	other threads:[~1997-02-22  2:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-22  2:01 Steven White [this message]
1997-02-23  2:45 ` A problem porting sbrk Richard Henderson
1997-03-04 19:02 ` gcc-2.7.2.2 / g77-0.5.20 on RH4.1 Lev D Gelb
     [not found] <199702230245.UAA27778@atheist.tamu.edu>
1997-02-23 17:12 ` A problem porting sbrk Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
1997-02-23 23:01 Steven White
     [not found] <199702232301.PAA30446@hedrock.ps.uci.edu>
1997-02-24 17:29 ` Richard Henderson
1997-02-24 19:38 Steven White
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox