Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!bruce!merlin!ianh From: ianh@bhpmrl.oz.au (Ian Hoyle) Newsgroups: comp.sys.sgi Subject: problem with malloc (Irix 3.3.1) Message-ID: <1658@merlin.bhpmrl.oz.au> Date: 24 Oct 90 06:53:51 GMT Sender: usenet@bhpmrl.oz.au Lines: 61 I've got an ongoing (well it was there with 3.2.2 and we just went to 3.3.1 today) problem with malloc. The application in question is Rich Burridge's mp postscript filter program, patchlevel 13. The following code fragment is causing problems: len = strlen(ptr) ; FPRINTF(stderr, "%s [] %s [] %i\n", ptr, whoami,strlen(whoami)) ; timenow = malloc((unsigned)(len + 6 + strlen(whoami) + 1)) ; FPRINTF(stderr,"After that error\n"); If I run mp using a news article that I know has been causing problems (mail1) I get the following: morgana-> ./mp -a < mail1 | lp 8 Oct 90 23:26:48 GMT [] root [] 4 lp: standard input is empty lp: request not accepted Segmentation fault (core dumped) morgana-> morgana-> dbx ./mp dbx version 2.0 8/6/90 14:02 Copyright 1987 Silicon Graphics Inc. Copyright 1987 MIPS Computer Systems Inc. Type 'help' for help. Reading symbolic information of `./mp' . . . Process name from core dump: mp Process died at pc 0x40340c of signal : segmentation violation [using memory image in core] (dbx) t > 0 .malloc.malloc(0x10000bd4, 0x100005a0, 0x100086f8, 0x21, 0x16, 0x10) ["mall oc.c":120, 0x403408] 1 do_date() ["misc.c":45, 0x401978] 2 set_defs() ["print.c":144, 0x402cfc] 3 startpage() ["print.c":194, 0x402f40] 4 printfile() ["main.c":193, 0x4014f4] 5 .main.main(argc = 2, argv = 0x7fffc794) ["main.c":154, 0x401388] (dbx) quit The FPRINTF is correct before the malloc call, but it then crashes with a core dump before it can print "After that error". This error though is not consistent. Some news articles can be printed, but others mysteriously cause mp to bomb. I linked it using -lmalloc. I'm completely at a loss to what may be occuring. Perhaps differing int arguments to malloc are causing it to go haywire. Any suggestions anyone ?? ian -- Ian Hoyle /\/\ Image Processing & Data Analysis Group / / /\ BHP Melbourne Research Laboratories / / / \ 245 Wellington Rd, Mulgrave, 3170 / / / /\ \ AUSTRALIA \ \/ / / / \ / / / Phone : +61-3-560-7066 \/\/\/ FAX : +61-3-561-6709 E-mail : ianh@bhpmrl.oz.au