Fixed Strings Limit ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Fixed Strings Limit ?

Post 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...
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

It works here, do you have the libs from http://www.purebasic.com/beta ?
BERESHEIT
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Post 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 ?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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)
BERESHEIT
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
BERESHEIT
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

with netmaestro code: 12224 works and 12225 doesn't work
512 MB RAM
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Post by HeX0R »

Yeah, 12224 is the magic size here also (1Gig of Ram).
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Now what happens to the stack if you push a lot of stuff on it?
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Post by blueb »

Yep, 12224 is the magic number that works for me, except I've got 2 gigs of RAM.


--blueb
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Post 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 ?
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Post 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 ?
jonljacobi
User
User
Posts: 67
Joined: Mon Jan 16, 2006 10:12 pm

Post 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
Post Reply