TURBO'd app that hangs the QL on termination...

Anything QL Software or Programming Related.
martyn_hill
Gold Card
Posts: 339
Joined: Sat Oct 25, 2014 9:53 am

TURBO'd app that hangs the QL on termination...

Postby martyn_hill » Wed Nov 01, 2017 1:45 pm

Hi everyone

I'm trying to track down a problem with one of my TURBO'd SB applications that always hangs the QL when it terminates.

Of course there are many program-specific factors that could be the cause, but without writing pages on the program in question, I wonder if the summary below might prompt some thoughts...

I CHARGE the program on QPC before transferring to the target QL
TURBO configuration is 'Structured', <64K (or > 64k), 0 Copied Windows, 8 (or 16) KB DATASPACE, 350 (or 512) bytes Stack
Target QL is equipped with QL-SD, 640KB RAM, Minerva 1.89 and Hermes, running TK2 v2.23 (or v2.26), LNG v2.11, Turbo TK (v3.34), HOTKEY v.something, THinG v.something-else plus a host of other custom extensions - all from ROM (actually, a custom made NV SRAM)
HOT_GO and _lngInit are invoked before two other needed extension are loaded from SDC (a heavily customised MEM driver, plus modified DIYTK TIMER ext.)
Program runs fine (invoked by EW or EX from SDC) until it terminates via STOP (no further executable code appears after here - just DEFinitions - as expected by the Structured paradigm)
The CON window remains visible and no further KB input is recognised (it's as if SB Job 0 Chan #0 has also been killed - even running as EX fails to allow further switching to SB #0)
My Hermes continues to blip upon further key presses - some more spectacular crashes I've experienced will kill this too, but not in this case.

i'm pretty sure that earlier versions of my program didn't exhibit this behaviour, but can't find any significant changes in the termination phase of the program since - its just gotten larger as I've added features. Also, other TURBO'd programs running with an identical environment (TK2, LNG, etc) and TURBO configuration terminate as expected.

Even if you haven't got ideas on what is causing the crash, I'd be interesting in how you might troubleshoot such a situation.

Thanks for any ideas (at all!)

M.


User avatar
pjw
Gold Card
Posts: 294
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: TURBO'd app that hangs the QL on termination...

Postby pjw » Wed Nov 01, 2017 2:33 pm

Martyn, I often use the following technique to debug this kind of thing: Somewhere at the (logical) start of your program add the line
dbg = fop_over('ram1_dbg_txt")

In your case Id use a different fast device ;) Then, near any tricky parts of the program add something like

print#dbg; "Now doing <action or line number, or variable values, or whatever>

For complex debugging I might add a PROCedure like DBG, where the command DBG <text> datestamps and prints out the debugging
text, as such lines are quick to add and remove.


Per
Assumptions should only be a first resort when the cost of being wrong is less than the trouble of finding out the facts! - pjw, 2016
martyn_hill
Gold Card
Posts: 339
Joined: Sat Oct 25, 2014 9:53 am

Re: TURBO'd app that hangs the QL on termination...

Postby martyn_hill » Wed Nov 01, 2017 4:53 pm

Thanks Per!

Yep - I've got lots of those debug statements reporting progress littered through the code - all of them print-out as expected - including the very last one that appears immediately prior to the STOP :-)

I'm suspecting that the TURBO close-down code is mistakenly de-allocating some critical memory area that doesn't belong to the job, or similar.

Either that, or one of my many system extensions is playing up (LNG, perhaps - I do open lots of CON channels during the life-time of the app - some of which have custom fonts attached.)

I may have to resort to learning how to use the C1 Monitor utility and see what's going-on at the MC level...

Thanks again!


User avatar
tofro
QL Wafer Drive
Posts: 1292
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: TURBO'd app that hangs the QL on termination...

Postby tofro » Wed Nov 01, 2017 6:15 pm

A very general remark:

In your otherwise very impressive list of system extensions I'm definitely missing SYSMON (from QPAC1). This allows you to find heap corruptions that might actually occur much earlier than the STOP.

Tobias


martyn_hill
Gold Card
Posts: 339
Joined: Sat Oct 25, 2014 9:53 am

Re: TURBO'd app that hangs the QL on termination...

Postby martyn_hill » Wed Nov 01, 2017 9:43 pm

SYSMON, eh?

I'll have a play tomorrow evening - thanks for the tip, Tobias!


User avatar
tofro
QL Wafer Drive
Posts: 1292
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: TURBO'd app that hangs the QL on termination...

Postby tofro » Wed Nov 01, 2017 9:55 pm

Something else that hits me every now and then is a somewhat obscure difference between ALLOCATE (Turbo TK) and ALCHP (TK2) that principally do the same thing, but not quite:

While ALLOCATE always allocates memory owned by your running job (unless you tell it otherwise by specifying ja job id and tag), ALCHP allocates the memory always to job 0 (i.e. it's not automatically released when your job terminates). Depending on what you do (or if you mix the two allocation schemes), you might get into tricky situations.


User avatar
pjw
Gold Card
Posts: 294
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: TURBO'd app that hangs the QL on termination...

Postby pjw » Wed Nov 01, 2017 11:15 pm

martyn_hill wrote:Yep - I've got lots of those debug statements reporting progress littered through the code - all of them print-out as expected - including the very last one that appears immediately prior to the STOP :-)

Of course you do :) It can sometimes be hard to guess what people know and dont know, so I was just playing safe.

Yes, I concur with Tobias' suggestion of sysmon. The next step would be Qmon/Jmon.
Last edited by pjw on Wed Nov 01, 2017 11:37 pm, edited 1 time in total.


Per
Assumptions should only be a first resort when the cost of being wrong is less than the trouble of finding out the facts! - pjw, 2016
User avatar
pjw
Gold Card
Posts: 294
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway

Re: TURBO'd app that hangs the QL on termination...

Postby pjw » Wed Nov 01, 2017 11:35 pm

tofro wrote:<>ALCHP allocates the memory always to job 0 (i.e. it's not automatically released when your job terminates).<>

Surely, this cant be correct, Tobias. I use ALCHP i my (QLib) compiled tasks all the time. I would have noticed. Perhaps there is a specific version, or software configuration (eg TK2 + Turbo) that behaves in that way? Or perhaps another toolkit containing ALCHP thats overwriting TK2?


Per
Assumptions should only be a first resort when the cost of being wrong is less than the trouble of finding out the facts! - pjw, 2016
stevepoole
Trump Card
Posts: 153
Joined: Mon Nov 24, 2014 2:03 pm

Re: TURBO'd app that hangs the QL on termination...

Postby stevepoole » Thu Nov 02, 2017 5:31 am

Hi Martyn,
Do you really still use LNG ?
Steve Poole.


martyn_hill
Gold Card
Posts: 339
Joined: Sat Oct 25, 2014 9:53 am

Re: TURBO'd app that hangs the QL on termination...

Postby martyn_hill » Thu Nov 02, 2017 9:58 am

stevepoole wrote:Hi Martyn,
Do you really still use LNG ?


Hi Steve - yes, just to eek-out a little more (PRINT) performance from my old QL(s)... In this particular application (a 'real-time' lap-counter/timer for my son's Scalectrix), there is a lot of screen-update going-on and LNG gives a bit more zip to the proceedings...

:-)



Return to “Software & Programming”

Who is online

Users browsing this forum: No registered users and 5 guests