Topic: Why did NEW or MALLOC fail


Author: jtrsmith@garnet.berkeley.edu ()
Date: 28 Mar 1994 18:28:14 GMT
Raw View
Hi,
     I run into a segmentation fault error with my C++ code. I used to
have such problems in Fortran when my array index was out of range or
I passed a wrong array.
     But this time it happened during memory allocation (malloc) and I
have no idea why it happened. I suppose Malloc returns a NULL if it
fails to get memory. But it seems I was wrong about this.
    Since I am not an experienced C++ programmer (I started to use C++
this month), I hope you can give me some ideas about what might
cause a NEW or MALLOC failure.
    Thanks.

    John
-------------------------------------------------
Script started on Tue Mar 22 12:50:03 1994
pepeat3 107% dbx a.out
dbx version 2.40 6/5/92 0:57
Type 'help' for help.
Reading symbolic information of `a.out' . . .
Process name from core dump: a.out
Process died at pc 0x49756c of signal : Segmentation fault
[using memory image in core]
(dbx) where
>  0 .malloc.malloc(0x2ee0, 0x10582380, 0x0, 0x1042aa38, 0x7fffb6d8, 0x7fffb6d8) ["malloc.c":120, 0x497568]
   1 ::operator new(unsigned int)(0x2ee0, 0x10582380, 0x0, 0x1042aa38, 0xbb8, 0x0) ["../new/_new.c":25, 0x48e334]
   2 ScalarspMat::CreateInternalVectors()(0x7fffb790, 0x10582380, 0x0, 0x1042aa38, 0x3ff00000, 0x0) ["S.spfactor.c":552, 0x45a964]
   3 ScalarspMat::OrderAndFactor(ScalarAVec*,double,double,int)(0x7fffb790, 0x0, 0x0, 0x0, 0x0, 0x0) ["S.spfactor.c":236, 0x459c90]
   4 ScalarspMat::Factor()(0x7fffb790, 0x10582380, 0x0, 0x1042aa38, 0x7fffb860, 0x0) ["S.spfactor.c":317, 0x459f48]
   5 ::jhf(int,int,int,double,double)(0x7fffc4fc, 0xbb8, 0xa, 0x0, 0x3fe921fb, 0x54442d18) ["jhf.c":58, 0x485cd8]
   6 main(0x1, 0x7fffc79c, 0x0, 0x1042aa38, 0x0, 0x0) ["jhfie.c":37, 0x487ebc]
(dbx) quit