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

Anything QL Software or Programming Related.
martyn_hill
Aurora
Posts: 909
Joined: Sat Oct 25, 2014 9:53 am

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

Post by martyn_hill »

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
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

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

Post by pjw »

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
dont be happy. worry
- ?
martyn_hill
Aurora
Posts: 909
Joined: Sat Oct 25, 2014 9:53 am

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

Post by martyn_hill »

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
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

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

Post by tofro »

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


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
martyn_hill
Aurora
Posts: 909
Joined: Sat Oct 25, 2014 9:53 am

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

Post by martyn_hill »

SYSMON, eh?

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


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

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

Post by tofro »

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.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

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

Post by pjw »

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
dont be happy. worry
- ?
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

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

Post by pjw »

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
dont be happy. worry
- ?
stevepoole
Super Gold Card
Posts: 712
Joined: Mon Nov 24, 2014 2:03 pm

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

Post by stevepoole »

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


martyn_hill
Aurora
Posts: 909
Joined: Sat Oct 25, 2014 9:53 am

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

Post by martyn_hill »

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...

:-)


Post Reply