Log in

View Full Version : ThrowError problem


Basilik
1st August 2005, 15:01
Hi all,

Recently I discovered a strange problem: if I use env->ThrowError inside GetFrame function, VirtualDub (from where I open my avs script) crashes without any error message. My first guess was that my plugin eats/corrupts some memory and that was not noticed with previous releases of Avisynth but now it is visible with 2.5.5. But my assumption was wrong because I returned to 2.5.2 and the bug didn't disappear.

Then for testing I have taken SimpleSample example from Avisynth pages, compiled it and run. Result is the same: if just for testing purpose I insert line:
env->ThrowError("Error test"); into GetFrame function then VirtualDub just disappears from my screen (crashes without any message).

My environment settings:
- Windows XP Home Edition SP2 + all latest updates from MS
- Microsoft Visual Studio 2002 .NET
- Avisynth 2.5.5 (tried with 2.5.2, 2.5.6)
- Virtualdub 1.5.10 (tried with 1.6.9)

What I noticed as well: under Win2k everything runs as it should - VirtualDub reports an error in the status bar.

Did anyone experienced same kind of problem? Could give me a hint what might be wrong? WinXP?

Regards,
Basilik

Leak
2nd August 2005, 16:33
Did anyone experienced same kind of problem? Could give me a hint what might be wrong? WinXP?

If I'm not totally wrong, ThrowError doesn't work in GetFrame(), only during the setup part of the plugin. After all, ThrowError would generate a video with the error message of a size that exactly fits the message, but after setting up the filter the frame size can't be changed anymore...

You could, of course, use Subtitle or something like that to overlay your error message on the unprocessed input clip or something...

np: Giardini Di Mirņ - Song4 (Giardini Di Mirņ)

IanB
2nd August 2005, 16:45
If you where using VC6 I would say it's my most unfavorite compiler bug to do with Structure Exception Handling, SEH. For some reason the compiler sometimes forgets to build the SEH table. Putting a try { <your code> } catch(...) throw; around your code seems to prompt it into correct behaviour. With the bug any exception traversing a bugged routine will GPF. Search this forum for "SEH bug".

However I am not aware of the VC.net compilers having the same problem, but no-one has said they don't.

Also the SP2 versions of msvcrt*.dll takes strong exception to crashes in the exception handlers and hard exits the process. Using the static libraries (makes you plugin hugh) is an other option.

And I have to ask why do you want to ThrowError in the GetFrame, it's just plain mean to crash the script half way thru. Can't all the validating be done in the constructor.

IanB

kassandro
2nd August 2005, 17:12
Throwerror may cause crashes outside GetFrame. Most of these problems originate from Avisource. As soon as an Avisource clip is there, Avisynth becomes amenable to crashes. This does not happen with mpeg2source or other clip generators. When I compile my plugins with the Intel compiler (necessary for SSE3), then VdubMod always crashes upon exit, if Avisource is used as well. Avisource is the real bad boy.

Basilik
3rd August 2005, 06:50
Thanks all!

IanB
And I have to ask why do you want to ThrowError in the GetFrame, it's just plain mean to crash the script half way thru. Can't all the validating be done in the constructor I'm reading external file inside GetFrame. If reading fails or fetched info is wrong then I need to report an error.

Leak
You could, of course, use Subtitle or something like that to overlay your error message on the unprocessed input clip or something Well, my intention was to stop processing. Imagine, some user with slow computer starts avs processing and let it run during night. Then he wakes up in the morning happy that everything went ok but in reality somewhere in the middle I have displayed an error message over his clip. He deletes the original and then after couple of months finds out that target video is garbage. I really want that script processing stops when there is an error during processing.

Could you say if there is a way to stop processing other than throwing an exception?

tritical
3rd August 2005, 08:18
Calling throwerror inside getframe causes a crash on winxp sp2 due to the same mixing of seh and c++ exception handling problem that was occurring in expression.cpp. The throwerrors in getframe trigger the problem in:

void CAVIStreamSynth::ReadHelper(void* lpBuffer, int lStart, int lSamples)

inside main.cpp. Removing the seh fixes the crashing and everything works fine when using an avisynth.dll compiled with vs.net 2003, don't have vc6 to test with. Maybe doing the same workaround as was done in expression.cpp would be a good idea?

IanB
3rd August 2005, 10:34
Somebody with M$ support access (Tritical?),

Having to bastardize perfectly correct code to suit a stupid M$ XPsp2 bug is getting beyond the limit of reasonableness. Can someone please log a level 0 fault (whole community is down) about this. T.I.A.

@Basilik,

ThrowError is the correct exiting method. Note only programs with advanced error handling, like VirtualDub, gracefully handle this exit. Programs without an exception trap will just exit.

IanB

IanB
9th August 2005, 09:58
Well, this seems to have put a dampner on this thread. Surely somebody can give a little to this community. M$ used to refund support credits for genuine bugs, I wonder if they still do?

IanB