乙個malloc的crash問題

2021-06-04 18:38:54 字數 2312 閱讀 1287

專案中遇到乙個crash問題,crash時生成了core dump,除錯core dump,gdb bt 後發現崩潰的執行緒中,呼叫棧深度總共有28層,下面貼的是頂部的12層,再往下就是專案**,第13層(#11)是std::list::push_back(...)操作,經檢查,#11層往下的資料都沒有錯,從其他執行緒上也看不出異常。從 bt 結果來看,貌似crash執行緒的棧並沒有被寫亂。

初步判斷,是該執行緒的棧上的memory溢位導致crash(64bit centos)。經測試,在和crash發生時相同的環境下,主線程棧上消耗memory超過12,568,257 bytes時,程序crash;從執行緒棧上消耗memory超過10,479,656 bytes時,程序crash。

這只是猜測,也可能其他執行緒中某項操作導致crash執行緒訪問記憶體越界。

#0  0xffffe410 in __kernel_vsyscall ()

#1  0xf7ad4df0 in raise () from /lib/libc.so.6

#2  0xf7ad6701 in abort () from /lib/libc.so.6

#3  0xf7b0d3ab in __libc_message () from /lib/libc.so.6

#4  0xf7b16d96 in _int_malloc () from /lib/libc.so.6

#5  0xf7b17fb7 in malloc () from /lib/libc.so.6

#6  0xf7cec517 in operator new(unsigned int) () from /usr/lib/libstdc++.so.6

#7  0x080901a2 in __gnu_cxx::new_allocator, std::allocator> > >::allocate

(this=0xf6e56e0c, __n=1) at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:88

#8  0x080901c5 in std::_list_base, std::allocator>, std::allocator, std::allocator> > >::_m_get_node (this=0xf6e56e0c)

at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_list.h:316

#9  0x080919ac in std::list, std::allocator>, std::allocator, std::allocator> > >::_m_create_node (this=0xf6e56e0c, __x="************************************x \r\n")

at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_list.h:448

#10 0x08091a62 in std::list, std::allocator>, std::allocator, std::allocator> > >::_m_insert (this=0xf6e56e0c, __position=traceback (most recent call last):

file "/usr/share/gdb/python/libstdcxx/v6/printers.py", line 469, in to_string

return self.val['_m_dataplus']['_m_p'].string (encoding, length = len)

runtimeerror: cannot access memory at address 0xeb

, __x="************************************x \r\n") at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_list.h:1139

#11 0x080aae18 in std::list, std::allocator>, std::allocator, std::allocator> > >::push_back (this=0xf6e56e0c, __x="set-cookie: sslgwsvrid=%s; expires=%s \r\n")

at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_list.h:761

解決第乙個crash

除錯程式出現異常,用debug看到的是空指標異常。debug真的好用啊,沒有它還真不行。但是 出現的空指標?通過斷點跟蹤,沒有找 到 行。可能斷點的地方設定不對。出現問題的時候,求助於網路是個很好的方法。看了很多帖子,覺得 乙個帖子比較符合我遇到的情況。這個帖子分析了應用crash的三種情況,其中一...

CakePHP View Cache的乙個問題

最近一直在使用cakephp,感覺挺不錯。不過這幾天在使用view cache的時候卻發現乙個問題 url帶查詢引數時總是不命中快取。檢視 後發現問題所在,原來在view中使用cachehelper類來處理快取,每次儲存快取時採用的檔案路徑是 cache cache php return cache...

CRASH 乙個賭博小遊戲的編寫

初步實現了本人從面向過程到物件導向程式設計的轉變 程式功能 可以玩n回合 bout 每回合 bout 只要未分勝負就可以繼續玩下去,或中途退出。crashgame.h 乙個簡單的賭博遊戲,遊戲規則如下 玩家擲兩個骰子,點數為1到6,如果第一次點數和為7或11,則玩家勝,如果點數和為2 3或12,則玩...