[問題] glibc
我自己寫的包含自訂class的c++程式,test_file
執行到new該class時,會發生memory error
Error msg如下:
*** glibc detected *** ~/test_dir/test_file: malloc(): memory corruption:
0x08657678 ***
======= Backtrace: =========
[0x80f75ae]
[0x80f98d3]
[0x80faf62]
[0x80c5847]
[0x8048a8a]
[0x80dcad8]
[0x8048151]
======= Memory map: ========
08048000-0817f000 r-xp 00000000 00:15 23693231 ~/test_dir/test_file
0817f000-08181000 rw-p 00137000 00:15 23693231 ~/test_dir/test_file
08181000-08674000 rw-p 08181000 00:00 0 [heap]
b7d00000-b7d24000 rw-p b7d00000 00:00 0
b7d24000-b7e00000 ---p b7d24000 00:00 0
b7e96000-b7f97000 rw-p b7e96000 00:00 0
bfd90000-bfda5000 rw-p bffeb000 00:00 0 [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
已經終止
-------
我的情況是
class myclass{
myclass(char *filename){ initialize(filename); }
void initialize(char *filename){
cerr << "error!" << endl; // 這行也出不來
...
}
};
...
int main(){
myclass *a;
a = new myclass(fn); => 顯然是在這行就出錯了
}
非常詭異的是,同樣的檔案,改成不同檔名就能吃
WHY?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.230.185.207
※ 編輯: Leeng 來自: 61.230.185.207 (04/05 21:51)
推
04/06 00:40, , 1F
04/06 00:40, 1F
→
04/06 07:22, , 2F
04/06 07:22, 2F
→
04/06 07:23, , 3F
04/06 07:23, 3F
→
04/06 07:24, , 4F
04/06 07:24, 4F
推
04/07 01:11, , 5F
04/07 01:11, 5F