From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <199702220201.SAA22132@hedrock.ps.uci.edu> Date: Fri, 21 Feb 1997 18:01:50 -0800 (PST) From: Steven White Subject: A problem porting sbrk 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 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