It is currently Wed Jan 27, 2021 8:12 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: [Done] FreeArray and nested array create Invalid access
PostPosted: Sun Oct 11, 2020 6:53 pm 
Offline
User
User
User avatar

Joined: Sat Oct 18, 2014 8:37 am
Posts: 22
I tried to free the array inside the structure but it break the main array.

Code:
EnableExplicit

Structure TableauAlias
    Array choix.i(0) ; This is a simplified code. Normally it's an array of structures.
EndStructure

Dim Generateurs.TableauAlias(0)
; ReDim Generateurs(1) ; If you uncomment this line there no memory error.
FreeArray(Generateurs(0)\choix())
ReDim Generateurs(1) ; Invalid memory access. (write error at address 18446744073709551592)


EDIT:
- The purifier doesn't complain about this.
- Tested with PureBasic 5.72 (Windows - x64)

_________________
Please correct me if my English is bad.


Top
 Profile  
Reply with quote  
 Post subject: Re: FreeArray and nested array create Invalid memory access
PostPosted: Mon Oct 12, 2020 5:16 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Dec 23, 2009 3:26 pm
Posts: 220
Code:
EnableExplicit

Structure TableauAlias
    Array choix.i(0) ; This is a simplified code. Normally it's an array of structures.
EndStructure

Dim Generateurs.TableauAlias(0)
; Redim Generateurs(1) ; If you uncomment this line there no memory error.
FreeArray(Generateurs(0)\choix())
Dim Generateurs(0)\choix(0)
Redim Generateurs(1) ; Invalid memory access. (write error at address 18446744073709551592)

_________________
poor English...

PureBasic & Delphi & VBA


Top
 Profile  
Reply with quote  
 Post subject: Re: FreeArray and nested array create Invalid memory access
PostPosted: Tue Oct 13, 2020 9:25 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Mar 09, 2006 9:24 am
Posts: 297
Location: S. Kor
Confirmed with PB 5.73 b2 x64/x86.

Code:
Structure TableauAlias
    Array choix.i(2)
    Array abc.i(2)
EndStructure

Dim Generateurs.TableauAlias(5)

;FreeArray(Generateurs(0)\choix())  ; Invalid memory access. (write error at address 18446744073709551592)
;FreeArray(Generateurs(1)\choix())  ; Invalid memory access. (write error at address 18446744073709551592)
FreeArray(Generateurs(2)\choix())  ; no error.
;FreeArray(Generateurs(3)\choix())  ; no error.
;FreeArray(Generateurs(4)\choix())  ; no error.
;FreeArray(Generateurs(5)\choix())  ; no error.

ReDim Generateurs(1)


The same error occurs in all dynamic objects.

Code:
Structure TableauAlias
  List choix.i()
EndStructure

Dim Generateurs.TableauAlias(5)

;FreeList(Generateurs(0)\choix())  ; Invalid memory access. (write error at address 24)
FreeList(Generateurs(1)\choix())  ; Invalid memory access. (write error at address 24)
;FreeList(Generateurs(2)\choix())  ; no error.
;FreeList(Generateurs(3)\choix())  ; no error.
;FreeList(Generateurs(4)\choix())  ; no error.
;FreeList(Generateurs(5)\choix())  ; no error.

ReDim Generateurs(1)

Code:
Structure TableauAlias
  Map choix.i()
EndStructure

Dim Generateurs.TableauAlias(5)

;FreeMap(Generateurs(0)\choix())  ; Invalid memory access. (write error at address 72)
FreeMap(Generateurs(1)\choix())  ; Invalid memory access. (write error at address 72)
;FreeMap(Generateurs(2)\choix())  ; no error.
;FreeMap(Generateurs(3)\choix())  ; no error.
;FreeMap(Generateurs(4)\choix())  ; no error.
;FreeMap(Generateurs(5)\choix())  ; no error.

ReDim Generateurs(1)


Top
 Profile  
Reply with quote  
 Post subject: Re: FreeArray and nested array create Invalid memory access
PostPosted: Wed Oct 14, 2020 10:58 am 
Offline
Addict
Addict

Joined: Wed Nov 12, 2008 5:01 pm
Posts: 1131
Location: Russia
This is not a bug.
Read the help https://www.purebasic.com/documentation ... array.html
Quote:
Free the specified 'Array()' and release all its associated memory. To access it again Dim has to be called.
Code:
EnableExplicit

Structure TableauAlias
    Array choix.i(0) ; This is a simplified code. Normally it's an array of structures.
EndStructure

Dim Generateurs.TableauAlias(0)
; ReDim Generateurs(1) ; If you uncomment this line there no memory error.
FreeArray(Generateurs(0)\choix())
Dim Generateurs(0)

ReDim Generateurs(1)

_________________
Library XP_Menu_Lib - office menu; HID_Lib - USB Library
Torrent client - pbTorrent (source code); Create driver in PureBasic.


Top
 Profile  
Reply with quote  
 Post subject: Re: FreeArray and nested array create Invalid memory access
PostPosted: Wed Oct 14, 2020 11:15 am 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1288
Location: right here
User_Russian wrote:
Read the help
Read the thread :lol:
It's true that you would have to Dim \choix() again to use it after freeing it, but there is no reason you would have to Dim Generateurs() after freeing \choix(). Generateurs() should still be usable.


Top
 Profile  
Reply with quote  
 Post subject: Re: FreeArray and nested array create Invalid memory access
PostPosted: Wed Oct 14, 2020 2:04 pm 
Offline
Addict
Addict

Joined: Wed Nov 12, 2008 5:01 pm
Posts: 1131
Location: Russia
No error
Code:
Structure TableauAlias
  List choix.i()
EndStructure

Dim Generateurs.TableauAlias(5)

FreeList(Generateurs(0)\choix())  ; Invalid memory access. (write error at address 24)
;FreeList(Generateurs(1)\choix())  ; Invalid memory access. (write error at address 24)
;FreeList(Generateurs(2)\choix())  ; no error.
;FreeList(Generateurs(3)\choix())  ; no error.
;FreeList(Generateurs(4)\choix())  ; no error.
;FreeList(Generateurs(5)\choix())  ; no error.

NewList Generateurs(0)\choix()

ReDim Generateurs(1)

_________________
Library XP_Menu_Lib - office menu; HID_Lib - USB Library
Torrent client - pbTorrent (source code); Create driver in PureBasic.


Top
 Profile  
Reply with quote  
 Post subject: Re: FreeArray and nested array create Invalid memory access
PostPosted: Wed Oct 14, 2020 2:24 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14181
Location: France
Is it a regression ?


Top
 Profile  
Reply with quote  
 Post subject: Re: FreeArray and nested array create Invalid memory access
PostPosted: Wed Oct 14, 2020 2:33 pm 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1288
Location: right here
Happens in older versions like 5.43 LTS as well.


Top
 Profile  
Reply with quote  
 Post subject: Re: FreeArray and nested array create Invalid memory access
PostPosted: Mon Nov 02, 2020 5:33 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14181
Location: France
Fixed.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye