Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 26th January 2012, 09:40   #1  |  Link
maxxon
Registered User
 
maxxon's Avatar
 
Join Date: Jan 2012
Location: On the net
Posts: 76
AviSynth scripting language bug?

Has anyone noticed that if you call a function that throws an exception within a try block, all variables are wiped from the stack frame? I mean the entire stack frame is just gone, even in previous function scopes all the way to the top level. But if you throw an exception within the try block without creating another function scope, everything works fine.

Globals don't seem to be affected though.

Here is an example:
Code:
global output__junk = BlankClip(height=0, width=0, length=0)
global output__filename = "output.log"
function output(string s)
{
    output__junk.WriteFileStart(output__filename, "s", append=true)
    return 1
}

global g = "GLOBAL"
l = "LOCAL"

function fail
{
    assert(false)
}

try { assert(false) } catch(e) {}
try { output("g="+g) } catch(e) { output("g doesn't exist.  "+e) }
try { output("l="+l) } catch(e) { output("l doesn't exist.  "+e) }

try { fail } catch(e) {}
try { output("g="+g) } catch(e) { output("g doesn't exist.  "+e) }
try { output("l="+l) } catch(e) { output("l doesn't exist.  "+e) }

l = "LOCAL"
try { output("g="+g) } catch(e) { output("g doesn't exist.  "+e) }
try { output("l="+l) } catch(e) { output("l doesn't exist.  "+e) }

output("fn1")
function fn1
{
    l1 = "LOCAL1"

    try { assert(false) } catch(e) {}
    try { output("g="+g) } catch(e) { output("g doesn't exist.  "+e) }
    try { output("l1="+l1) } catch(e) { output("l1 doesn't exist.  "+e) }
}
fn1
try { output("g="+g) } catch(e) { output("g doesn't exist.  "+e) }
try { output("l="+l) } catch(e) { output("l doesn't exist.  "+e) }

output("fn2")
function fn2
{
    l1 = "LOCAL1"

    try { fail } catch(e) {}
    try { output("g="+g) } catch(e) { output("g doesn't exist.  "+e) }
    try { output("l1="+l1) } catch(e) { output("l1 doesn't exist.  "+e) }
}
fn2
try { output("g="+g) } catch(e) { output("g doesn't exist.  "+e) }
try { output("l="+l) } catch(e) { output("l doesn't exist.  "+e) }
The output.log file will contain this:
Code:
g=GLOBAL
l=LOCAL
g=GLOBAL
l doesn't exist.  I don't know what "l" means
(test.avs, line 23)
g=GLOBAL
l=LOCAL
fn1
g=GLOBAL
l1=LOCAL1
g=GLOBAL
l=LOCAL
fn2
g=GLOBAL
l1 doesn't exist.  I don't know what "l1" means
(test.avs, line 49)
g=GLOBAL
l doesn't exist.  I don't know what "l" means
(test.avs, line 53)
Has anyone experienced this before? I'm using AviSynth 2.60 May 25 2011.

Strange bug,


Mx

Last edited by maxxon; 26th January 2012 at 09:52. Reason: Forgot to add another test case.
maxxon is offline   Reply With Quote
 

Tags
avisynth script, bug, try catch

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:06.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.