PDA

View Full Version : env->throwerror in GetFrame


hanfrunz
3rd October 2004, 01:38
Hello,

if i use env->ThrowError("text") in the GetFrame-method of a filter (simplesample for example) i get an access violation. Why is that? I took a look in the avisynth-sources and find, that this is done in the imagereader-filter. Why is it working there?

hanfrunz

kassandro
4th October 2004, 01:15
Originally posted by hanfrunz
Hello,

if i use env->ThrowError("text") in the GetFrame-method of a filter (simplesample for example) i get an access violation. Why is that? I took a look in the avisynth-sources and find, that this is done in the imagereader-filter. Why is it working there?

hanfrunz
I experienced similar, but less severe problems a while ago. Avisynth seems to have problems with destroying objects controlled by "smart pointers", when it terminates prematurely. In my case PClip objects were the evil doers.
The Avisynth API is certainly not the most robust API. On the other hand, it is astonishely simple inviting anybody with some basic C++ knowledge to write a plugin.

Bidoche
4th October 2004, 15:07
Does it always happen ?
Even with the smallest script.

hanfrunz
4th October 2004, 20:26
Hello Bidoche,
i took the simplesample1.7 code, added something like env->thowerror ("helloworld") And just this script:
a=colorbars(100,100).killaudio
simplesample(a,a,23)

i'm curios, why it works in the imagereader-filter...

Bidoche
5th October 2004, 01:16
I don't know.
It should be safe to throw exceptions any time, ie if all the code is exception safe, which is probably not the case...

IanB
7th October 2004, 08:51
See this thread Report :- "Evaluate: Unrecognized exception!" (http://forum.doom9.org/showthread.php?s=&threadid=80737) it documents a very pernicious compiler bug.

I still have no hard recipe for what causes it, but asking for an assembler listing and doing a quick comparison of the stack references in the generated assembler for the exception time destructor calls and the subroutine entry initialization code, will show if a piece of code has a problem. i.e. there will be references to stack offsets that never get initialized.

So far the 2 best hacks for curing the problem are 1. disable all optimization. 2. to put a try { <all code here> } catch (...) { throw; } around the affected routines, this seems to remind the compiler to emit the code it forgets about.

Worst news is there are instances of this bug in the main Avisynth.dll

IanB