ルギア君の戯言

雑多な記事。

kTechLab

というわけで

[lugia@raralu-ra pkgs]$ ../tools/OmoiKondara -G qt3

で qt3 もデバッグバージョンを作成してから、デバッグしてみる。


余談だが、まだ正式リリースしてないけど、Development ヴァージョンのスナップには MOSFET とかあったから早く正式にリリースしてほしいな。


にしても qt3 のビルドは長いな。

QEventLoop::processEvents (this=0x844d9e8, flags=0) at kernel/qeventloop_x11.cpp:147        
147             while ( XPending( QPaintDevice::x11AppDisplay() ) ) {                       
(gdb) until                                                                         

198         if ( d->shortcut ) {
(gdb)                           
202         QApplication::sendPostedEvents();
(gdb)                                        
204         const uint exclude_all = ExcludeSocketNotifiers | 0x08;
(gdb)                                                              
206         if ( nevents > 0 && ( flags & exclude_all ) == exclude_all &&
(gdb)                                                                    

... (中略) ...

(gdb)                                  
383             nevents += activateSocketNotifiers();
(gdb)                                                
387         if ( ! ( flags & 0x08 ) ) {              
(gdb)                                                
389             nevents += activateTimers();         
(gdb)                                                
warning: (Internal error: pc 0x82768a8 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x82768a8 in read in psymtab, but not in symtab.)


Program received signal SIGSEGV, Segmentation fault.
warning: (Internal error: pc 0x82768a8 in read in psymtab, but not in symtab.)

んー、これはどうしようか?


ここでまた step-in したら泥沼にはまりそうだな・・・


ただなんで Battery とかの時だけ落ちるのかは未だに不明。


結局 step-in する羽目に。

QEventLoop::activateTimers (this=0x84549b0) at kernel/qeventloop_unix.cpp:550        
550             if ( t->timeout < currentTime )                                      
(gdb) watch t 
Hardware watchpoint 10: t                                                            
(gdb) until
551                 t->timeout = currentTime + t->interval;
(gdb)                                                      
552             insertTimer( t );                       // relink timer
(gdb)                                                                  
553             if ( t->interval.tv_usec > 0 || t->interval.tv_sec > 0 )
(gdb)                                                                   
555             QTimerEvent e( t->id );                                 
(gdb)                                                                   
556             QApplication::sendEvent( t->obj, &e );  // send event   
(gdb) step                                                              
warning: (Internal error: pc 0x827d3d4 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d3d4 in read in psymtab, but not in symtab.)


Program received signal SIGSEGV, Segmentation fault.

あれ? なんでこの関数入れないんだ?


ちなみに、例の行を削除しても別の場所で呼び出しているらしく、SIGSEGV は変わりません。


そうか、BackTrace という手があったか!


BackTrace もしてみたところ、これは有益な情報が得られたかもしれないな。
step-in しきれないからな。

warning: (Internal error: pc 0x827d438 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d438 in read in psymtab, but not in symtab.)

#0  0x0827d438 in ~vector (this=warning: (Internal error: pc 0x827d438 in read in psymtab, but not in symtab.)

0x51) at /usr/lib/gcc/i686-momonga-linux/4.3.1/../../../../include/c++/4.3.1/bits/stl_vector.h:300
warning: (Internal error: pc 0x827d47e in read in psymtab, but not in symtab.)                    

warning: (Internal error: pc 0x827d47d in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d47d in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d47d in read in psymtab, but not in symtab.)

#1  0x0827d47e in std::_Destroy<std::vector<unsigned int, std::allocator<unsigned int> > > (__pointer=warning: (Internal error: pc 0x827d47d in read in psymtab, but not in symtab.)                                                                                              

warning: (Internal error: pc 0x827d461 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d47d in read in psymtab, but not in symtab.)

0x51)
    at /usr/lib/gcc/i686-momonga-linux/4.3.1/../../../../include/c++/4.3.1/bits/stl_construct.h:88
warning: (Internal error: pc 0x827d4a3 in read in psymtab, but not in symtab.)                    

warning: (Internal error: pc 0x827d4a2 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d4a2 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d4a2 in read in psymtab, but not in symtab.)

#2  0x0827d4a3 in std::_Destroy<std::vector<unsigned int, std::allocator<unsigned int> >*> (__first=warning: (Internal error: pc 0x827d4a2 in read in psymtab, but not in symtab.)                                                                                                

warning: (Internal error: pc 0x827d484 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d4a2 in read in psymtab, but not in symtab.)

0x51, __last=warning: (Internal error: pc 0x827d4a2 in read in psymtab, but not in symtab.)

0x1556ae8)
    at /usr/lib/gcc/i686-momonga-linux/4.3.1/../../../../include/c++/4.3.1/bits/stl_construct.h:103
warning: (Internal error: pc 0x827d4d9 in read in psymtab, but not in symtab.)                     

warning: (Internal error: pc 0x827d4d8 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d4d8 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d4d8 in read in psymtab, but not in symtab.)

#3  0x0827d4d9 in std::_Destroy<std::vector<unsigned int, std::allocator<unsigned int> >*, std::vector<unsigned int, std::allocator<unsigned int> > > (__first=warning: (Internal error: pc 0x827d4d8 in read in psymtab, but not in symtab.)                                     

warning: (Internal error: pc 0x827d4b5 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d4d8 in read in psymtab, but not in symtab.)

0x51, __last=warning: (Internal error: pc 0x827d4d8 in read in psymtab, but not in symtab.)

0x1556ae8)
    at /usr/lib/gcc/i686-momonga-linux/4.3.1/../../../../include/c++/4.3.1/bits/stl_construct.h:128
warning: (Internal error: pc 0x827d518 in read in psymtab, but not in symtab.)                     

warning: (Internal error: pc 0x827d517 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d517 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d517 in read in psymtab, but not in symtab.)

#4  0x0827d518 in std::vector<std::vector<unsigned int, std::allocator<unsigned int> >, std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >::_M_erase_at_end (this=warning: (Internal error: pc 0x827d517 in read in psymtab, but not in symtab.)         

warning: (Internal error: pc 0x827d4e0 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827d517 in read in psymtab, but not in symtab.)

0x86534fc, __pos=warning: (Internal error: pc 0x827d517 in read in psymtab, but not in symtab.)

0x51)
    at /usr/lib/gcc/i686-momonga-linux/4.3.1/../../../../include/c++/4.3.1/bits/stl_vector.h:1091
warning: (Internal error: pc 0x827e8fd in read in psymtab, but not in symtab.)                   

warning: (Internal error: pc 0x827e8fc in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827e8fc in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827e8fc in read in psymtab, but not in symtab.)

#5  0x0827e8fd in std::vector<std::vector<unsigned int, std::allocator<unsigned int> >, std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >::resize (this=warning: (Internal error: pc 0x827e8fc in read in psymtab, but not in symtab.)                  

warning: (Internal error: pc 0x827e8b2 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x827e8fc in read in psymtab, but not in symtab.)

0x86534fc, __new_size=warning: (Internal error: pc 0x827e8fc in read in psymtab, but not in symtab.)

2, __x=warning: (Internal error: pc 0x827e8fc in read in psymtab, but not in symtab.)


          {<std::_Vector_base<unsigned int, std::allocator<unsigned int> >> = {_M_impl = {<std::allocator<unsigned int>> = {<__gnu_cxx::new_allocator<unsigned int>> = {<No data fields>}, <No data fields>}, _M_start = 0xbfffdfcc, _M_finish = 0x67aff4, _M_end_of_storage = 0x8}}, <No data fields>}) at /usr/lib/gcc/i686-momonga-linux/4.3.1/../../../../include/c++/4.3.1/bits/stl_vector.h:507                      
#6  0x0827c146 in Map (this=0x86535f0, size=2) at matrix.cpp:294                                                                         
#7  0x0827caac in Matrix (this=0x864c270, n=1, m=1) at matrix.cpp:35                                                                     
#8  0x0828500b in ElementSet (this=0x8653678, circuit=0x8652df0, n=1, m=1) at elementset.cpp:32                                          
#9  0x0828213f in Circuit::init (this=0x8652df0) at circuit.cpp:203                                                                      
#10 0x08138aa3 in CircuitDocument::assignCircuits (this=0x85df358) at circuitdocument.cpp:472                                            
#11 0x0813a691 in CircuitDocument::qt_invoke (this=0x85df358, _id=47, _o=0xbfffe34c) at circuitdocument.moc:142                          
---Type <return> to continue, or q <return> to quit---                                                                                   
#12 0x010d7b7a in QObject::activate_signal (this=0x85eab18, clist=0x85eab98, o=0xbfffe34c) at kernel/qobject.cpp:2356                    
#13 0x010d865f in QObject::activate_signal (this=0x85eab18, signal=2) at kernel/qobject.cpp:2325                                         
#14 0x0143887c in QTimer::timeout (this=0x85eab18) at .moc/release-shared-mt/moc_qtimer.cpp:82                                           
#15 0x010fde9d in QTimer::event (this=0x85eab18, e=0xbfffe658) at kernel/qtimer.cpp:219                                                  
#16 0x0106dcee in QApplication::internalNotify (this=0xbffff0d4, receiver=0x85eab18, e=0xbfffe658) at kernel/qapplication.cpp:2635       
#17 0x0106f993 in QApplication::notify (this=0xbffff0d4, receiver=0x85eab18, e=0xbfffe658) at kernel/qapplication.cpp:2358               
#18 0x0047ae22 in KApplication::notify () from /usr/lib/libkdecore.so.4                                                                  
#19 0x00d6e6be in QApplication::sendEvent () from /usr/lib/libkdeui.so.4                                                                 
#20 0x01060a54 in QEventLoop::activateTimers (this=0x8457810) at kernel/qeventloop_unix.cpp:556                                          
#21 0x01014b8f in QEventLoop::processEvents (this=0x8457810, flags=0) at kernel/qeventloop_x11.cpp:389                                   
#22 0x01087ef2 in QEventLoop::processEvents (this=0x8457810, flags=0, maxTime=300) at kernel/qeventloop.cpp:258
#23 0x0106f784 in QApplication::processEvents (this=0xbffff0d4, maxtime=300) at kernel/qapplication.cpp:2693
#24 0x081460e8 in ICNDocument::rerouteInvalidatedConnectors (this=0x85df358) at icndocument.cpp:1145
#25 0x0811fdc8 in ItemDocument::processItemDocumentEvents (this=0x85df358) at itemdocument.cpp:705
#26 0x08123a9f in ItemDocument::qt_invoke (this=0x85df358, _id=26, _o=0xbfffeaec) at itemdocument.moc:195
#27 0x081492b5 in ICNDocument::qt_invoke (this=0x85df358, _id=26, _o=0xbfffeaec) at icndocument.moc:134
#28 0x0813a6ac in CircuitDocument::qt_invoke (this=0x85df358, _id=26, _o=0xbfffeaec) at circuitdocument.moc:144
#29 0x010d7b7a in QObject::activate_signal (this=0x85e8850, clist=0x85e8b48, o=0xbfffeaec) at kernel/qobject.cpp:2356
#30 0x010d865f in QObject::activate_signal (this=0x85e8850, signal=2) at kernel/qobject.cpp:2325
#31 0x0143887c in QTimer::timeout (this=0x85e8850) at .moc/release-shared-mt/moc_qtimer.cpp:82
#32 0x010fde9d in QTimer::event (this=0x85e8850, e=0xbfffedf8) at kernel/qtimer.cpp:219
#33 0x0106dcee in QApplication::internalNotify (this=0xbffff0d4, receiver=0x85e8850, e=0xbfffedf8) at kernel/qapplication.cpp:2635
---Type <return> to continue, or q <return> to quit---
#34 0x0106f993 in QApplication::notify (this=0xbffff0d4, receiver=0x85e8850, e=0xbfffedf8) at kernel/qapplication.cpp:2358
#35 0x0047ae22 in KApplication::notify () from /usr/lib/libkdecore.so.4
#36 0x00d6e6be in QApplication::sendEvent () from /usr/lib/libkdeui.so.4
#37 0x01060a54 in QEventLoop::activateTimers (this=0x8457810) at kernel/qeventloop_unix.cpp:556
#38 0x01014b8f in QEventLoop::processEvents (this=0x8457810, flags=4) at kernel/qeventloop_x11.cpp:389
#39 0x01087f82 in QEventLoop::enterLoop (this=0x8457810) at kernel/qeventloop.cpp:198
#40 0x01087d96 in QEventLoop::exec (this=0x8457810) at kernel/qeventloop.cpp:145
#41 0x0106f719 in QApplication::exec (this=0xbffff0d4) at kernel/qapplication.cpp:2758
#42 0x08337a75 in main (argc=2, argv=0xbffff2c4) at main.cpp:57

step-in で調べあげる方法にはちょっと限界があるのか・・・
さて、この情報を元に気を取り直して debug 再開。


上の方は stdc++ だから、それを除くと、関数 Map のようだ。
関数なの? まあ、いっか。C++ らしくないな。

(gdb) break Map
"Map" is not a function
(gdb)


ほら、関数じゃないってよ。っていうことはあれか。コンストラクタか。

(gdb) break Map::Map
(gdb) run
Starting program: /usr/bin/ktechlab [

Program received signal SIGSEGV, Segmentation fault.
0x0827d438 in ~vector (this=0x51) at /usr/lib/gcc/i686-momonga-linux/4.3.1/../../../../include/c++/4.3.1/bits/stl_vector.h:300
300           { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
(gdb) kill
Kill the program being debugged? (y or n) y

あ、でも引っかからないや。

Breakpoint 2, Circuit::init (this=0x86549f0) at circuit.cpp:172
172             m_branchCount = 0;
(gdb)
(gdb) unti;
Internal: global symbol `' found in ecclockinput.cpp psymtab but not in symtab.
 may be an inlined function, or may be a template function
(if a template, try specifying an instantiation: <type>).
(gdb) until
174             const ElementList::iterator listEnd = m_elementList.end();

さあ、潜り込むぞ! 誤爆したけどまあ、いいや。

(gdb)
203             m_elementSet = new ElementSet( this, m_cnodeCount, m_branchCount );
(gdb) step
ElementSet (this=0x8655168, circuit=0x86549f0, n=1, m=1) at elementset.cpp:26
26      ElementSet::ElementSet( Circuit * circuit, const int n, const int m )
(gdb) until
28              m_pCircuit = circuit;

ここで until すると落ちるので中へ入るぜ。

(gdb)
31              p_logicIn = 0l;
(gdb)
32              p_A = new Matrix( m_cn, m_cb );
(gdb) step
Matrix (this=0x86547f0, n=1, m=1) at matrix.cpp:26
26              m_n = n;
(gdb) until
27              m_m = m;

あの関数見覚えあるな。よし、ステップインだ。

(gdb)
35              m_map = new Map(m_size);
(gdb) step
Map (this=0x86551a8, size=2) at matrix.cpp:290
290             m_size = size;
(gdb) until
291             m_map = new ETMap;
(gdb)

お、ついに Map コンストラクタまで到達したぞ。ステップインだ。
Trace 情報によると、vector<...>::resize で問題が生じていると言うことだ。


ん? この関数 gcc4.3 パッチの中で見覚えがあるぞ。

(gdb) until
293             for (int i=0; i<m_size; ++i)
(gdb)
294               m_map[i].resize( m_size );
(gdb)
293             for (int i=0; i<m_size; ++i)
(gdb)
294               m_map[i].resize( m_size );
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x0827d438 in ~vector (this=0x51) at /usr/lib/gcc/i686-momonga-linux/4.3.1/../../../../include/c++/4.3.1/bits/stl_vector.h:300
300           { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
(gdb)

やはり、問題があったのは gcc パッチだったのか。
さて、どう fix するかな。