Function call observed before _start and main in backtrace

I received the backtrace of my program (QT application running on RHEL 5.3) from a colleague, and, analyzing it, I found something that I could not explain. If you look at this reverse trace, you will notice the trace for main and _start. But before that, we see the _ZN19datalog_render_area9prepStripEh and _ZN12QMutexLockerD1Ev that are in my program. As I can see, some of my functions are called before _start and main. Is it impossible? (sorry for the layout of my back line)

  Funct Addr |  Instr.  Addr |  Functionsymbol  
 ---------- | ------------- | ------------------------- --------------------------------- |  
 0x8060bf2 |  0x8060dc0 |  _Z11print_tracev  
 0x8061386 |  0x806141c |  _Z15myMessageOutput9QtMsgTypePKc  
 0x822b558 |  0x822b598 |  _ZN5QListIP13QStandardItemEixEi  
 0x8229ece |  0x8229f0b |  _ZN12vehicleModel14updHeaderModelEP5QListIjE  
 0x822be7e |  0x822bf64 |  _ZN14vehTableWidget19updVehicleTabLayoutEib  
 0x822c668 |  0x822c8e7 |  _ZN14vehTableWidget13setupVehTableEib  
 0x82845f8 |  0x82846fc |  _ZN14vehTableWidget11qt_metacallEN11QMetaObject4CallEiPPv

... function calls outside the program

  0x8060e86 |  0x80612ce |  main  

 _____________________ | ____________________ | address outside of program: 4804252  

 0x8060a70 |  0x8060a91 |  _start  

 _____________________ | ____________________ | address outside of program: 3218418744  

 0x808df02 |  0x808df13 |  _ZN12QMutexLockerD1Ev    

 _____________________ | ____________________ | address outside of program: 3218420336  
 _____________________ | ____________________ | address outside of program: 152429104  
 _____________________ | ____________________ | address outside of program: 3218420552  

 0x8208fa6 |  0x820acd0 |  _ZN19datalog_render_area9prepStripEh  

 _____________________ | ____________________ | address outside of program: 3218420336  
 _____________________ | ____________________ | address outside of program: 3218420500  
+4
source share
3 answers

Most likely you see garbage on the stack. To get an accurate stack trace, the debugger needs either pointers to frames (often omitted on x86 to save the registry) or debugging information. Without this information, he tries to guess - he looks through the stack for pointers that look like sorta-like code addresses, and does everything possible to match them with the functions to which they belong.

As already mentioned, static initialization can cause code to run before main , but this code returned by main is running, so they don’t have work on the true stack trace. I would say that, most likely, everything except _start is garbage data and can be safely ignored.

+2
source

It is possible. For example, these functions could be called part of the dynamic initialization of an object of static storage duration.

Toy example:

 const bool i = []() -> bool { // arbitrary code here return true; }(); int main() {} 
+1
source

It looks like you have a class that has a static data member. The constructor of this static data member calls QMutexLocker. Static data elements are built before calling main ().

+1
source

All Articles