Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


(MinGW) Angelscript Crashing at Callfunc
someone972 Offline
Member

Posts: 57
Threads: 4
Joined: May 2012
Reputation: 1
#1
(MinGW) Angelscript Crashing at Callfunc

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?
(This post was last modified: 05-10-2012, 07:44 AM by someone972.)
05-02-2012, 01:49 AM
Find
someone972 Offline
Member

Posts: 57
Threads: 4
Joined: May 2012
Reputation: 1
#2
RE: (MinGW) Angelscript Crashing at Callfunc

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 .
(This post was last modified: 05-02-2012, 08:04 AM by someone972.)
05-02-2012, 07:37 AM
Find




Users browsing this thread: 2 Guest(s)