* Core dumping in malloc -- and I'm not even calling malloc!!!
@ 1993-10-18 13:40 Christopher Phillips
0 siblings, 0 replies; only message in thread
From: Christopher Phillips @ 1993-10-18 13:40 UTC (permalink / raw)
The following results in a core dump in malloc:
1) Replace write.o in libc.a with the following
write.c:
#include <unistd.h>
#include <syscall.h>
ssize_t
write(int fd, const void *buf, size_t len)
{
return syscall(SYS_write, fd, buf, len);
}
From the shell,
% cc -g -c -std1 write.c
% cp /lib/libc.a .
% ar rv libc.a write.o
2) Fortran code prints an integer
fprint.f:
subroutine fprint(i)
print *, i
return
end
3) The main program just calls fprint
main.c:
extern void fprint_(int *);
int
main(void)
{
int number = 100;
fprint_(&number);
}
If you compile, link with required FORTRAN libraries and our new libc.a,
and run, you get
% f77 -g -c fprint.f
% cc -g -c -std1 main.c
% cc -g -o fprint main.o fprint.o -lUfor -lfor -lFutil -lm -lots -L.
% ./fprint
Segmentation fault (core dumped)
% dbx fprint core
dbx version 3.11.1
Type 'help' for help.
Core file created by program "fprint"
signal Segmentation fault at [morecore:355 ,0x120008f8c] Source not available
(dbx) where
> 0 morecore(0x3ff00000001, 0x3ffc000d760, 0x3ff80006394, 0x3ffc0001c28, 0x3ff00000013) ["../../../../../../src/usr/ccs/lib/libc/malloc.c":355, 0x120008f8c]
1 malloc(0xb, 0x3ffc0024000, 0x3ffc0017800, 0x3ffc0016400, 0x2) ["../../../../../../src/usr/ccs/lib/libc/malloc.c":277, 0x120008db8]
2 for__get_vm(0x14001c000, 0x0, 0x14001c068, 0x11ffff448, 0x3ffc000d2a8) ["for_vm.c":173, 0x3ff80908520]
3 for__open_proc(0x11ffff8d8, 0x14001c000, 0x3ff80908524, 0x3ffc0016000, 0x3ff800bc214) ["for_open_proc.c":991, 0x3ff808f6e70]
4 for__open_default(0x14001c000, 0x1, 0x4, 0x1, 0x12000eba8) ["for_open.c":425, 0x3ff808f53f4]
5 for_write_seq_lis(0x11ffffab0, 0x6, 0x0, 0x140008c00, 0x11ffffae0) ["for_wseq_lis.c":379, 0x3ff8090e634]
6 fprint(I = 100) ["fprint.f":2, 0x120006ddc]
(dbx)
If write.o is not changed, all works fine. If malloc is replaced with
code that hands out chunks of a static array, all works fine. The calls
that result are
malloc(48) 12 times
malloc(272)
malloc(11) 2 times
malloc(120)
malloc(8192)
======> 100 gets printed here <======
free(<result of 11th malloc(48)>)
free(<result of 12th malloc(48)>)
With the system malloc, the core dump occurs during the first malloc(11)
call.
Someone else recently asked in comp.lang.c about problems with the
system malloc for Ultrix. Is the OSF/1 malloc the same?
All help is appreciated.
Chris
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1993-10-18 13:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-10-18 13:40 Core dumping in malloc -- and I'm not even calling malloc!!! Christopher Phillips
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox