Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / SIGSEGV AGK in Pascal

Author
Message
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 21st Nov 2012 17:27
Hi all

Sometime ago, I left the Native AppGameKit as I missed OOP!

However, I all of sudden keep getting a SIGSEGV error hen closing my App? Runs fine....does what I ask of it....as soon as I close it...BAM

Project Raised Exception Class 'External SIGSEGV'

Access violation at Address xxx

When the assembler starts it says:
ntdll!TpCallBackMayRunLong (1670)

Any ideas what is causing this? The only external DLL being used is AppGameKit!

Constantly seeking!
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 21st Nov 2012 19:11
Can you post an example, please.

Are you compiling with Free Pascal or Delphi?

Do the example programs work OK?

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 22nd Nov 2012 12:55
Jim

It is quite hard to post code as I am not sure where in the code the error occurs. I have out break points at various locations, even in the main unit at the beginning of startup....basically before I create/initialise anything.

I found that when I open an example project it starts working fine. I then save under a different project name and modify the code. Then after several change/compile cycles its starts again. I would agree that I have modified code and that it would point to this being an issue. However, the issue occurs even when no other units / classes are called - if I comment them out. Then once I click to close the program...bam sigsegv. A couple of times even lazarus has closed down which is pretty drastic.

Just wondered if anyone else with Laz has had the issue so I could either start accepting it is an AppGameKit dll issue or I am doing something drastically incorrect with scenes or objects. I did note that I was using Laz file io instead of AGKReader....maybe this causes an error? ( forgot about AGKReader when I was in my happy coding world!)

Thanks anyway!

Lazarus 1.x
Win 7 64 bit
AMD 4170 black edition
Radeon HD6700
16gb Ram

Constantly seeking!
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 22nd Nov 2012 12:57
Oh by the way, upon the error the assembler starts and states

Xxdll Possible long wait....(sorry not at my pc and cannot remember the full message)

Constantly seeking!
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 22nd Nov 2012 13:26
What happens if you run it outside the Lazarus IDE? I have noticed some exit exceptions when running with debug on which don't happen with it off.

Personally, I wouldn't put breakpoints in when interfacing to the OpenGL system through AppGameKit - there's a lot of time-critical code in there.

It's difficult for Erik or me to make suggestions without having something that will break. This could be (a) a Lazarus error (b) a coding error (c) an ADK Pascal error (d) an AppGameKit error.

Try running outside the IDE many times and see if you get an AV.

Always happy to try stuff out.

At least we don't have beta AppGameKit problems (yet)!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 23rd Nov 2012 20:20
OK so I have Opened a sampled AGK4Pas example...the simple one that shows "Hello AppGameKit for pascal" with an AppGameKit sprite in the centre of the window.

I have run this no problem at al..no SIGSEGV!...I then introduce one of my own classes and do little more than create an instance of it. Bam a SIGSEGV.

I then remove my class from the source completely, recompile : No SIGSEV. So it must be the unit that holds my class. What I do not get is that when i do nothing but add the unit containing the class to my uses, I get a SIGSEGV?

That is without ANY other reference to it in the code?

Assembler starts:
ntdll!TPCallBack May Run Long (1670)

***STOP THE PRESS***
The user created units/classes added to a project in AppGameKit for Pascal must be listed in the 'uses' clause AFTER - AGK. As soon as I Put my unit name AFTER AppGameKit, the SIGSEGV vanished!!!! ie

in 'uMain' the clause

uses
uMyUnit,
AGK;

Seems to cause a SIGSEGV. However simply changing it to

uses
AppGameKit,
uMyUnit;

Seems NOT to give a SIGSEGV.....!!!

hoooooooooooooooooooooooray!

Constantly seeking!
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 24th Nov 2012 00:05
Glad you found it! Hooo.... also!

This question of inclusion order is actually quite subtle. You'd think everything would be equal, but it isn't to the linker.

I think (Erik may disgagree!) that a good "Uses" order would be:

(1) Classes, sysutils (any other fundamentals)
(2) AGK
(3) Our stuff

That's very useful information. I'm about to add a microphone module, for PC only ATM, and I'd better be sure it comes after AppGameKit!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Neslib
12
Years of Service
User Offline
Joined: 8th May 2012
Location: San Diego, CA, USA
Posted: 26th Nov 2012 16:17
Good catch!

I have found the problem. It has to do with the HeapTrc unit I use when compiling a debug version with FreePascal (or Lazarus). I use that unit to test for any memory leaks. At shutdown, it will report any unreleased memory (if any) and it that causes the issue (even when there are no memory leaks).

I think that is because the HeapTrc unit should be the very first unit that the compiler "sees". Since it is the first used unit in the AppGameKit unit, that works if AppGameKit is the first unit in the project's uses clause.

Anyway, the HeapTrc unit should not be part of the AppGameKit unit, so I will remove it with the 108 release. (I do all my memory testing with Delphi anyway, so that should not be a problem).

In the meantime, you can also fix the problem by building the application in Release mode (which also runs a bit faster), or by removing the MEMCHECK define in debug mode. To do that in Lazarus, go to "Project | Project Options | Compiler Options | Build Modes" and make sure that the Debug mode is active. Then, under "Compiler Options | Other", remove the "-dMEMCHECK" option.
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 26th Nov 2012 17:02
Thanks, Erik!
Quote: "I will remove it with the 108 release"

No need to panic, then !!!

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
The Daddy
15
Years of Service
User Offline
Joined: 13th Jan 2009
Location: Essex
Posted: 30th Nov 2012 20:43
Thanks guys...really useful!

Constantly seeking!

Login to post a reply

Server time is: 2024-11-24 03:58:04
Your offset time is: 2024-11-24 03:58:04