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. |
|
|
#1 | Link |
|
Registered User
Join Date: Jan 2012
Location: On the net
Posts: 76
|
Concatenation failure on 4096 byte boundries
This is an odd one that I found while profile testing some of my code:
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
}
a = " " # 8
b = a+a+a+a+a+a+a+a # 64
c = b+b+b+b+b+b+b+b # 512
d = c+c+c+c+c+c+c+b+b+b+b+b+b+b+a+a+a+a+a+a+a+" " # 4094
d.strlen.string.output
e = d + " "
e.strlen.string.output
e.output
Must have something to do with your string allocation methods as this can happen on any 4096 byte boundary, though it doesn't always happen. It appears that certain even multiple cats can keep this from happening. |\/|x |
|
|
|
|
|
#2 | Link | |
|
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Code:
AVSValue ExpPlus::Evaluate(IScriptEnvironment* env)
...
else if (x.IsString() && y.IsString())
return env->Sprintf("%s%s", x.AsString(), y.AsString());
else {
...
Code:
char* ScriptEnvironment::VSprintf(const char* fmt, void* val) {
char *buf = NULL;
int size = 0, count = -1;
while (count == -1)
{
if (buf) delete[] buf;
size += 4096;
buf = new char[size];
if (!buf) return 0;
count = _vsnprintf(buf, size-1, fmt, (va_list)val);
}
char *i = ScriptEnvironment::SaveString(buf);
delete[] buf;
return i;
}
Quote:
Will fix asap. |
|
|
|
|
|
|
#4 | Link |
|
Registered User
Join Date: Mar 2006
Location: Jamaica
Posts: 48
|
Could this issue be translated into issue i have with multiple concatenation of OpenVidFiles [1] & [2]
Is it possible to detour this errata by concatenating strings into separate variables up to 4096bytes long, followed by pasting all those LessThan4096BytesStrings contained in Vars into one variable without AviSynth being aware of TotalStrLen but final StrLen itself being only of total length of NamesOfVars and plus chars? Thanks. Well that shouldn't concern me though ![]() It's a pretty weird issue, it's more like that someone searched for bug than fint this an issue. Anyway it's good that it's fixed. Patch is in 2.6alphaX version? Last edited by looney; 25th March 2012 at 08:56. |
|
|
|
|
|
#5 | Link |
|
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
The bug is when you concatenate 2 strings and the resulting length is 4096*k-1, where k is a positive integer. i.e 4095, 8191, 12287, 16383, ....
Hint, check for ((strlen(a)+strlen(b)+1) % 4096) == 0 |
|
|
|
|
|
#6 | Link |
|
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,385
|
I've just been bitten by this bug and expect to be repeatedly bitten again soon so,
have put up an update for The RT_Stats plug with function which allows concatenation of 2 or more strings and returns the resulting string. Useful for 2.58 or until bugfix appears in 2.6a4. EDIT: Reason for being bitten, RT_Stats has several funcs using EOL [chr(10)] separated strings and a sort of string indexing function allowing usage of concatenated strings like a single dimension array. EDIT: Can download RT_Stats v1.03 here: http://forum.doom9.org/showthread.php?t=165479 Two functions that give an alternative solution to this problem Code:
RT_StrAddStr(String, String s1, ... , String sn)
Non-clip function.
Function to concatenate (join together) 2 or more strings.
D = RT_StrAddStr("A","B","C") same as D="A"+"B"+"C".
There is a bug in v2.58 and 2.6a3 when joining strings that result in sizes of [(n * 4096) - 1],
this function just gives an alternative method of joining strings until 2.6a4 is released.
RT_TxtAddStr(String, String s1, ... , String sn)
Non-clip function.
Function to concatenate (join together) 2 or more strings with Chr(10) line separators.
If the first string is an empty string ("") it will not have a newline [Chr(10)] appended.
All other strings even empty strings will have a newline [Chr(10)] inserted after them
(if they dont already have a trailing newline).
Any source string containing Chr(13) will have them converted to Chr(10).
X = RT_TxtAddStr("A","B","C") same as X = "A" + Chr(10) + "B" + Chr(10) +"C" + Chr(10)
X = RT_TxtAddStr("","A","B","C") == "A" + Chr(10) + "B" + Chr(10) + "C" + Chr(10)
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 2nd September 2012 at 19:59. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|