Page 1 of 1
Fixed Strings Limit ?
Posted: Tue Sep 19, 2006 10:59 am
by HeX0R
It seems there is something wrong with fixed strings, at least here on my workingmachine the following code is just dying without notice.
Code: Select all
Structure _TEST_
Monkey.s{14*1024}
EndStructure
Procedure Test()
Protected A._TEST_
Debug "What happened ?"
EndProcedure
Test()
Lowering the 14*1024 will make it work...
Posted: Tue Sep 19, 2006 12:20 pm
by netmaestro
It works here, do you have the libs from
http://www.purebasic.com/beta ?
Posted: Tue Sep 19, 2006 12:26 pm
by HeX0R
The error came with 64 * 1024 btw, i just tried to lower the value to see when it starts to hang.
First i used the "out-of-the-box" PB4.0 Version.
When i realized this behaviour i tried with all the beta-libs installed.
It is still the same effect...
Do you see the "What happened ?" - Output no matter how big your fixed string is ?
Posted: Tue Sep 19, 2006 12:41 pm
by netmaestro
Code: Select all
Structure _TEST_
Monkey.s{16320}
EndStructure
Procedure Test()
Protected A._TEST_
Debug "What happened ?"
EndProcedure
Test()
This one works, if I put 16321 in there it hangs. Something isn't right, the docs say fixed strings are unlimited. Outside a procedure it seems to take anything without a problem, but inside - 16320 is it. (here, with 2g ram)
Posted: Tue Sep 19, 2006 12:47 pm
by netmaestro
Update: Inside the procedure only has the problem if the variable is protected. Static, Shared and Global vars declared inside the proc don't seem affected.
Posted: Tue Sep 19, 2006 12:48 pm
by ts-soft
with netmaestro code: 12224 works and 12225 doesn't work
512 MB RAM
Posted: Tue Sep 19, 2006 12:57 pm
by HeX0R
Yeah, 12224 is the magic size here also (1Gig of Ram).
Posted: Tue Sep 19, 2006 1:35 pm
by Trond
Now what happens to the stack if you push a lot of stuff on it?
Posted: Tue Sep 19, 2006 1:35 pm
by blueb
Yep, 12224 is the magic number that works for me, except I've got 2 gigs of RAM.
--blueb
Posted: Tue Sep 19, 2006 2:29 pm
by HeX0R
Trond wrote:Now what happens to the stack if you push a lot of stuff on it?
Very true, didn't think about that.
So the way to do would be something like this ? :
Code: Select all
Structure _TEST_
Monkey.s{14*1024}
EndStructure
Procedure Test()
Protected *A._TEST_
*A = AllocateMemory(SizeOf(_TEST_))
*A\Monkey = RSet("a", 10000, "b")
Debug *A\Monkey
FreeMemory(*A)
EndProcedure
Test()
But shouldn't there be at least some kind of error-msg ?
Posted: Wed Sep 20, 2006 8:42 am
by HeX0R
O.k., now i have another strange effect:
Code: Select all
Structure _TEST_
o.s{128}
EndStructure
Global Test._TEST_
Global *Buffer = AllocateMemory(1024)
Procedure FillStructure(*Raw_Line, *p._TEST_)
Text$ = PeekS(*Raw_Line)
*p\o = Trim(StringField(Text$, 1, " "))
b$ = Trim(StringField(Text$, 1, " "))
;Shouldn't the following be the same ?
Debug *p\o
Debug b$
EndProcedure
Procedure Main(raw$)
FillStructure(@raw$, @Test)
EndProcedure
PokeS(*Buffer, "What the heck ?")
Main(PeekS(*Buffer))
Any ideas on this ?
Posted: Wed Sep 20, 2006 11:04 pm
by jonljacobi
No idea, but perhaps it's for the same reason that my program crashes with and invalid memory access while displaying status bar text using different strings when the following line is compiled in a totally different routine and location...
Code: Select all
Globe\MessageBoxText = "File is not a Take Note 22 settings file. File Not Loaded"
And doesn't crash when it's commented out.
The structure and declaration are fine. Something to do with string allocation or housekeeping? This was originally a non-structure string that also caused the same behavior and the program doesn't crash on other strings in the same structure.
Cheers, Jon