Click here to go to the forum index Click here for the home page
 
Author Message

<  TAP and patch development  ~  What makes TAPs unstable?

Page 1 of 1
MarkPax
Posted: Mon Dec 27, 2010 7:58 pm Reply with quote
Frequent contributor Joined: 07 Nov 2010 Posts: 520
Are there any good rules of thumb to spot what causes crashing TAPs?

I had a nightmare today with a short (30 line) TSR TAP. The problem seemed to be this line in TAP_Main:-
TYPE_TapChInfo CurrChanInfo;
It crashed every time even though the compiler was happy. Another similar version crashed only when I started playing a merged recording in MyStuff. Odd given that my TAP doesn't do anything special, just looks for EVT_SVCSTATUS calls and changes the volume when it gets them.
I moved this type declaration up to being a global declaration and it's sweet, it seems stable now. (There's no need for it to be global however, it's just used in TAP_Main). I have loads of memory free.

Do you guys have any rules for structuring TAPs to avoid these kind of funnies? Thanks. (I am a C newbie)

_________________
TF5800t, TS On, F/W: MS6 Recommended F/W 12/9/2009 +PeR0UUuWfZ
TAPs: TAP Commander 1.34; TommyFF v2.1; BlankStuff v2.5; MyInfo B5.5; EPG2MEI v0.96; MyStuff 6.5; Font Manager 1.0d; Extend v1.7; SecCache (UK) v0.4; EIT Sub v0.6; TF5000 Display v1.53;
Sig generated by MyInfo on 19/5/11
View user's profile Send private message
Geoff Bacon
Posted: Mon Dec 27, 2010 8:13 pm Reply with quote
Frequent contributor Joined: 12 Jan 2007 Posts: 4416
Just because it compiles doesn't mean it will work or that the logic is correct; it just means that the source code follows the syntax rules for the language.

I don't have experience with taps but normally programs need to leave things as they find them e.g. save and restore all registers, worry about code being reentered (especially if could exhaust the stack).

Geoff

_________________
TopManager program
TF5800, TS On, F/W: MS6 Recommended F/W 12/9/2009 -Sy+EvEzPfUUuZ
TAPs: PcControl B1.4; StopExit v1.01; PruneEPG 1.0; fsSave 1.1; QuickJump 1.72; SecCache (UK) v0.4; EIT Sub (Game) v0.6; EPG2MEI v0.96; MyStuff 6.6; Bookmark 3.0; Extend v1.7; Font Manager 1.0d; MyInfo B5.6; MHEG On/Off A3;
Sig generated by EMJB's MyInfo.tap on 29/12/18
View user's profile Send private message Visit poster's website
EMJB
Posted: Tue Dec 28, 2010 10:53 am Reply with quote
Frequent contributor Joined: 08 Jul 2005 Posts: 3639 Location: Maldon Essex
There is a bug in the firmware such that TAPs which are an exact multiple of 512 bytes long do not run correctly. Your symptoms sound consistent with this.

Incidentally, suggest this would have been better posted in the TAP development section.

EMJB
View user's profile Send private message
MarkPax
Posted: Tue Dec 28, 2010 12:00 pm Reply with quote
Frequent contributor Joined: 07 Nov 2010 Posts: 520
EMJB wrote:
There is a bug in the firmware such that TAPs which are an exact multiple of 512 bytes long do not run correctly. Your symptoms sound consistent with this.

Incidentally, suggest this would have been better posted in the TAP development section.

EMJB

You're right re TAP development, oops. Mods, could you move this thread? Thanks

Nope, it's 20,004 bytes, not divisible by 512. The version which works is 20,080. Thanks very much for the tip however, I'll watch out for that one.

_________________
TF5800t, TS On, F/W: MS6 Recommended F/W 12/9/2009 +PeR0UUuWfZ
TAPs: TAP Commander 1.34; TommyFF v2.1; BlankStuff v2.5; MyInfo B5.5; EPG2MEI v0.96; MyStuff 6.5; Font Manager 1.0d; Extend v1.7; SecCache (UK) v0.4; EIT Sub v0.6; TF5000 Display v1.53;
Sig generated by MyInfo on 19/5/11
View user's profile Send private message
BobD
Posted: Tue Dec 28, 2010 5:24 pm Reply with quote
MyStuff Team Joined: 03 Aug 2005 Posts: 4218
Do a search for tapcheck. Its a program that will check a compiled tap for its length, and adjust it if it is a multiple of 512. You can just add this to your makefile to get it to run automatically.

As for your original crash, it might just depend on what and were you were using the CurrChanInfo variable for.

Is all of your processing done in your TAP_Main then? For something that monitors events I would have expected you to use this variable in your EventHandler.

Things to look out for are reentry in your EventHandler and of course good old memory corruption/overruns etc. Not saying that I suffer from those of course. Good grief no. Not me. No. Never.

_________________
FW: ChunkyWizard Recommended
TAPs:
MyStuff (always one version ahead of everyone else!), and recommended support TAPS
MyStuff skins, manual and latest version: http://www.BobDsMyStuff.co.uk
Known bugs & forthcoming fixes: http://www.BobDsMyStuff.co.uk/Bugs.shtml
Changes coming in the next version: http://www.BobDsMyStuff.co.uk/NextVersion.shtml
View user's profile Send private message Visit poster's website
MarkPax
Posted: Tue Dec 28, 2010 7:25 pm Reply with quote
Frequent contributor Joined: 07 Nov 2010 Posts: 520
I've cut my code down and down and down, here's what's left. For me the code below crashes every time I play a programme, even if this is the only TAP loaded (hold down 0 at boot, then load this TAP manually from the Toppy Archive). I press Play, the screen blanks, playback starts for half a second or so, then boom! the Toppy reboots.

I can stop it crashing by any of these tweaks:-
- move "TYPE_PlayInfo iPlay;" above "dword TAP_EventHandler ...", ie make it a global variable rather than local.
- declare another TAP type variable after the TYPE_Playinfo ... line, for example add TYPE_TapChInfo CurrChanInfo; after the offending line.

Is any of this vaguely plausible? Is this reentry, or a compiler bug, or something else? Thanks for all your helpful advice so far! (I'm compiling on Mac OS X 10.6.4 if that's of any value).

Code:
#include <stdarg.h>
#include <stdio.h>
#include <tap.h>

#define ID_TIMERLIST 0x80000127

TAP_ID( ID_TIMERLIST );
TAP_PROGRAM_NAME("BlankStuff crash test");
TAP_AUTHOR_NAME("Mark Paxman");
TAP_DESCRIPTION("Blanks the screen on keypress or dual record, includes volume ramp");
TAP_ETCINFO(__DATE__);

dword TAP_EventHandler(word event, dword param1, dword param2)
{
   TYPE_PlayInfo   iPlay;

   if (event == EVT_SVCSTATUS)
   {
      TAP_Hdd_GetPlayInfo (&iPlay);
   }      
   return param1;       
}

int TAP_Main(void)
{   
   return 1;       // TSR mode
}

_________________
TF5800t, TS On, F/W: MS6 Recommended F/W 12/9/2009 +PeR0UUuWfZ
TAPs: TAP Commander 1.34; TommyFF v2.1; BlankStuff v2.5; MyInfo B5.5; EPG2MEI v0.96; MyStuff 6.5; Font Manager 1.0d; Extend v1.7; SecCache (UK) v0.4; EIT Sub v0.6; TF5000 Display v1.53;
Sig generated by MyInfo on 19/5/11
View user's profile Send private message
BobD
Posted: Tue Dec 28, 2010 7:44 pm Reply with quote
MyStuff Team Joined: 03 Aug 2005 Posts: 4218
Aha, you need to use firebird.lib which fixes some memory overruns in the tap API, eg in GetPlayInfo.

_________________
FW: ChunkyWizard Recommended
TAPs:
MyStuff (always one version ahead of everyone else!), and recommended support TAPS
MyStuff skins, manual and latest version: http://www.BobDsMyStuff.co.uk
Known bugs & forthcoming fixes: http://www.BobDsMyStuff.co.uk/Bugs.shtml
Changes coming in the next version: http://www.BobDsMyStuff.co.uk/NextVersion.shtml
View user's profile Send private message Visit poster's website
MarkPax
Posted: Wed Dec 29, 2010 12:24 pm Reply with quote
Frequent contributor Joined: 07 Nov 2010 Posts: 520
Aha indeed! That fixed it, thanks so much for your help. Easy when you know how eh?

(Note to anyone else struggling with this. You need to include LibFireBird.h in your TAP; make sure the linker includes LibFireBird.a; and put the following line in your TAP:- InitTAPAPIFix();. I put it in TAP_Main. The FireBird documentation contains all this. You also need the right version of LibFireBird - the most recent versions don't have the TF5x00 functionality in them)

My whole life I've learned to remove the 3rd party stuff if I'm having problems. With the Toppy it's the other way round... the 3rd party stuff is more reliable. Most impressive.

Thanks again

_________________
TF5800t, TS On, F/W: MS6 Recommended F/W 12/9/2009 +PeR0UUuWfZ
TAPs: TAP Commander 1.34; TommyFF v2.1; BlankStuff v2.5; MyInfo B5.5; EPG2MEI v0.96; MyStuff 6.5; Font Manager 1.0d; Extend v1.7; SecCache (UK) v0.4; EIT Sub v0.6; TF5000 Display v1.53;
Sig generated by MyInfo on 19/5/11
View user's profile Send private message

Display posts from previous:  

All times are GMT + 1 Hour
Page 1 of 1

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum