PDA

View Full Version : Misaligned stack error...



mtnbiker66
2nd July 2012, 21:37
Good afternoon --

After a little bit of time last week I finally got an older C++ app incorporated into my Qt app and compiled correctly (went back to square one and found that I was calling the C++ app with a QString parameter but it was receiving it as a char *). So, of course the next step was to run it and immediately it exited with an error code of 1.

Now I then had to learn the debugger and thankfully have a past in assembly programming, so it wasn't too Greek (and even brought back some old memories). The error occurred in my initial "QApplication a(argc, argv);" command where unexpectedly methods in one of the C++ classes were called, but seeing that there are a lot of memory allocation command, I thought, well, hopefully that's a correct behavior as there's nothing I've done that was calling them.

Stepping thru the debugger I got to a call in the stack view to "misaligned_stack_error_entering_dylb_stub_binder" function and further, in the debug log, found a "msg="mi_cmd_stack_list_frames: Not enough frames in stack." " error.

Before heading off down an incorrect path and wasting my time, knowing what a misaligned stack is and knowing my friend's C++ app is 13 years old, would it seem like a reasonable theory that the memory allocations being performed in C++ are causing this alignment issue? He's relying on size_t quite a bit and standard C++ types and doesn't appear to have anything hard coded. If this sounds logical, are their any suggestions beyond the obvious of tearing into the memory allocations?

Interestingly, if within Qt I create a project and only include the code from C++ app, the ensuing executable works fine at the command line, and if I compile and link at the command line it works as well.

It might matter that I'm working on a Mac OS 10.7.4, Qt 4.8.1, and GCC...

Thanks for any direction!

Kodi

high_flyer
3rd July 2012, 12:08
can you post your the cpp file where your main() is in?
Do you use any structs with specific mem alignment?
Any pragmas?

mtnbiker66
3rd July 2012, 16:52
Thanks! I'll post shortly but I just found out it works perfectly in Windows 7....


Kodi

Added after 41 minutes:

Here are the files -- double checked and while my app runs in Windows, the call to my friend's app crashes my app with an error code 1.

main.cpp is from my app, but the others are my friends app that I'm folding into mine. There is a STRUCT but no PRAGMA.


Kodi

mtnbiker66
4th July 2012, 01:53
I'm an idiot. Whenever you incorporate a standalone app into another one it helps to remove the "exit" statement. Everything works perfectly in Windows...