PB 6.10 beta 5 #PB_Any return value type changed?

Just starting out? Need help? Post your questions and find answers here.
Justin
Addict
Addict
Posts: 956
Joined: Sat Apr 26, 2003 2:49 pm

PB 6.10 beta 5 #PB_Any return value type changed?

Post by Justin »

This beta seems to return much bigger values when using #PB_Any when creating gadgets, using c backend x64:
PB 6.04 35915776
PB 6.10b5 2537844711072

Wich value type is returning?
User avatar
STARGÅTE
Addict
Addict
Posts: 2260
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by STARGÅTE »

It is and was always integer (.i)
I think there was a change in memory management in the background.

But why you think it is a bug?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Justin
Addict
Addict
Posts: 956
Joined: Sat Apr 26, 2003 2:49 pm

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by Justin »

Not really a bug but something has changed for sure.
In a program that interacts with COM what previously was interpreted as a VT_I4 (4 byte signed int) now has become a VT_R8 (8 byte floating point) it caused the program to crash.
The returned gadget handles values seem to have widened, i would like to know what has changed internally with more detail.
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by mk-soft »

Not Double ...

Code: Select all

Define v1.VARIANT
v1\vt = #VT_I8
v1\llVal = adr
v1\vt = #VT_UI8
v1\ullVal = adr
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
STARGÅTE
Addict
Addict
Posts: 2260
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by STARGÅTE »

Justin wrote: Sun Feb 04, 2024 9:12 pm Not really a bug but something has changed for sure.
In a program that interacts with COM what previously was interpreted as a VT_I4 (4 byte signed int) now has become a VT_R8 (8 byte floating point) it caused the program to crash.
The returned gadget handles values seem to have widened, i would like to know what has changed internally with more detail.
Here you can find my (and other's) old posts regarding this change: https://www.purebasic.fr/english/viewto ... 28#p572528
STARGÅTE wrote:Probably in older PB versions also the 64 bit version uses something like a virtual memory address per process.
In PB 6.00 is now uses the "real" memory position which is most often above a size of a long due to the huge RAM of 8 GB to 64 GB of typical PC systems.
But this is just speculation, I'm not familiar with this topic. Perhaps Fred can answer this question.
Please read also this blog post from freak:
Is your 64bit program really solid ?
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Justin
Addict
Addict
Posts: 956
Joined: Sat Apr 26, 2003 2:49 pm

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by Justin »

mk-soft, i don't understand your point

stargate, thanks but those posts are from 2 years ago, the changes in gadget handles returned from #PB_Any, happen from 6.04 to 6.10b5 not sure in b4
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by Fred »

We changed the linker, it probably added randomized address allocation by default to avoid memory attack prediction. That's a good thing anyway, it will help to track 64-bit code bug like you encountered.
juergenkulow
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 25, 2019 10:18 am

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by juergenkulow »

Is this line of code still correct? Protected.l FileNumber
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by Fred »

juergenkulow wrote: Mon Feb 05, 2024 10:12 am Is this line of code still correct? Protected.l FileNumber
It's indeed not correct, a #PB_Any result needs an integer (.i) type. I changed it.
Justin
Addict
Addict
Posts: 956
Joined: Sat Apr 26, 2003 2:49 pm

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by Justin »

So before 6.10 #PB_Any returned a long (4 bytes in x86/x64) and now returns an integer (4 bytes x86 / 8 bytes in x64)?
Thanks for the clarification.
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by Fred »

No, it never returned a long. It returned an integer which by luck was fitting into a long on x64. #PB_Any returns a real memory pointer, that's why it's always been integer (and not long). To have more info about the new linker memory default setting:

https://learn.microsoft.com/en-us/cpp/b ... w=msvc-170
Justin
Addict
Addict
Posts: 956
Joined: Sat Apr 26, 2003 2:49 pm

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by Justin »

Ok, thanks
User avatar
blueb
Addict
Addict
Posts: 1118
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by blueb »

Fred wrote: Mon Feb 05, 2024 2:33 pm No, it never returned a long. It returned an integer which by luck was fitting into a long on x64. #PB_Any returns a real memory pointer, that's why it's always been integer (and not long). To have more info about the new linker memory default setting:

https://learn.microsoft.com/en-us/cpp/b ... w=msvc-170
Wow Fred (and Freak).
That's deep. You do all the hard work, so I don't have to... it's appreciated :mrgreen:
- 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
Justin
Addict
Addict
Posts: 956
Joined: Sat Apr 26, 2003 2:49 pm

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by Justin »

Just noticed that in Windows 7 x64 with this beta the behaviour is to return small numbers like in previous PB versions, they actually fit in a long type.

This different memory behaviour between os with the same PB version can cause problems in some situations.
User avatar
STARGÅTE
Addict
Addict
Posts: 2260
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Post by STARGÅTE »

Justin wrote: Sat Feb 10, 2024 1:25 pm This different memory behaviour between os with the same PB version can cause problems in some situations.
Why? What kind of situation?
It doesn't matter whether a memory location is large or small, as long as you use the correct variable type: Integer.

I know, old codes here in the forum uses sometimes Long, because they where used in older PB version before the type integer was introduced. These codes should be avoided or adapted.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Post Reply