Frictional Games Forum (read-only)
(MinGW) Angelscript Crashing at Callfunc - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Open Source Collaboration (https://www.frictionalgames.com/forum/forum-27.html)
+--- Forum: Overture (https://www.frictionalgames.com/forum/forum-29.html)
+--- Thread: (MinGW) Angelscript Crashing at Callfunc (/thread-15213.html)



(MinGW) Angelscript Crashing at Callfunc - someone972 - 05-02-2012

I've been trying to get Penumbra to compile on MinGW with Code::Blocks, and for the most part it's been successful. The game runs up until it tries to run the OnInit function from the global script. I've traced it through the calls, and it fails in CallCDeclFunctionRetByRef_impl within Angelscript, specifically at the part where it tries to push the arguments onto the stack (segfault - memory could not be read). I'm using Angelscript 2.17.1b, which is the same one supplied in the dependency zip, but I am using the Code::Blocks project file to compile it. I have also tried using 2.8.1 with the same issue. Does anyone have any ideas on what I could do to either track down why this is happening or fix it?


RE: (MinGW) Angelscript Crashing at Callfunc - someone972 - 05-02-2012

After some fishing around in IDA Pro, I think I've found what is wrong. The function that is being called does not properly setup the base stack pointer when compiled with MinGW, so the arguments it tries to access are garbage. I'm experimenting with modifying the assembly code to push the base stack pointer and move the current stack pointer into ebp. Hopefully that will fix the problem.

EDIT: I can confirm that adding "pushl %ebp \n" and "movl %esp, %ebp \n" to the beginning of the x86 inline asm function calls and adding "popl %ebp \n" to the end did indeed fix the problem I was having. The game now loads and runs fine. It took a lot of library compiling and a couple changes to the code, but I finally got Penumbra to compile and work successfully with MinGW and Code::Blocks Big Grin .