Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!rice!sun-spots-request From: torgerse@udel.edu, , torger@uncecs.edu (Todd Torgersen) Newsgroups: comp.sys.sun Subject: Sparcstation problems with malloc Keywords: Miscellaneous Message-ID: <2144@brazos.Rice.edu> Date: 11 Oct 89 21:43:00 GMT Sender: root@rice.edu Organization: Sun-Spots Lines: 52 Approved: Sun-Spots@rice.edu X-Sun-Spots-Digest: Volume 8, Issue 161, message 10 of 17 We recently got two SPARCstation 1 workstations and found a problem building very long linked lists with "malloc". The following program crashes our SPARCstations when n=200000 The program runs fine on the sun - 4/110's and also on our host (a sun - 4 / 280). Has anyone out there experienced this ? Does anyone have a clue why the machine crashes ? When this program is run on other sun-4's (not SPARCstations) it will do the sensible thing when n exceeds the available memory. On a SPARCstation, the machine crashes long before the memory limit is approached. All machines here are diskless except the server. Thanks in advance for your help. Todd (919) 759-5536 #include #define CHECKIT 1000 main(argc,argv) int argc ; char * argv[] ; { struct block { int data ; struct block * next ; } blk ; struct block *temp ; struct block *list ; int count,flag,n ; /* begin executable code. */ list = NULL ; flag = (0==0) ; count = 0 ; printf("Enter n : ") ; scanf( "%d", &n ) ; while ( (count < n) && flag ) { temp = list ; list = (struct block *) malloc( sizeof(blk) ) ; flag = (NULL != list) ; if (flag) { if ( 0 == (count % CHECKIT)) printf("%s: count = %d\n",argv[0],count) ; list->data = count ; list->next = temp ; ++count ; } else printf("malloc returns NULL with count = %d\n",count) ; } }