I'm tring to chunked read a file (a Mozilla Thunderbird container file of ~330Mbytes) but when the variable "Length" value is exactly 13488096 i get this error:
I tested it with many files, smaller and bigger, with no difference.[18:30:39] [ERROR] testmemory.pb (Line: 54)
[18:30:39] [ERROR] Invalid memory access. (read error at address 71413760)
So i created this little peace of code to test with a difference of -1 and +1 of this "Lenght" and so no error there.
I noticed that:
- with Purebasic 6.10 LTS 32bit i got the error.
- with Purebasic 6.10 LTS 64bit this error does not apper.
Code: Select all
Enumeration
#file0
EndEnumeration
Declare i693()
Declare i694()
Declare i695()
Global Path$ = ""C:\Users\testuser\AppData\Roaming\Thunderbird\Profiles\niyfo4hw.default-release\Mail\Local Folders"
Global File$ = "Inbox"
Procedure i693()
LocIniziale = 0
LocFinale = 13488095
If ReadFile(#file0, Path$ + File$, #PB_File_SharedRead)
Length = LocFinale - LocIniziale
If Length
*MemoryID = AllocateMemory(Length)
If *MemoryID
FileSeek(#file0, LocIniziale) ;POSIZIONE CURSORE
ReadData(#file0, *MemoryID, Length)
Debug Length
Debug PeekS(*MemoryID, Length, #PB_UTF8)
EndIf
EndIf
CloseFile(#file0)
FreeMemory(*MemoryID)
EndIf
EndProcedure
Procedure i694()
LocIniziale = 0
LocFinale = 13488096
If ReadFile(#file0, Path$ + File$, #PB_File_SharedRead)
Length = LocFinale - LocIniziale
If Length
*MemoryID = AllocateMemory(Length)
If *MemoryID
FileSeek(#file0, LocIniziale) ;POSIZIONE CURSORE
ReadData(#file0, *MemoryID, Length)
Debug Length
Debug PeekS(*MemoryID, Length, #PB_UTF8)
EndIf
EndIf
CloseFile(#file0)
FreeMemory(*MemoryID)
EndIf
EndProcedure
Procedure i695()
LocIniziale = 0
LocFinale = 13488097
If ReadFile(#file0, Path$ + File$, #PB_File_SharedRead)
Length = LocFinale - LocIniziale
If Length
*MemoryID = AllocateMemory(Length)
If *MemoryID
FileSeek(#file0, LocIniziale) ;POSIZIONE CURSORE
ReadData(#file0, *MemoryID, Length)
Debug Length
Debug PeekS(*MemoryID, Length, #PB_UTF8)
EndIf
EndIf
CloseFile(#file0)
FreeMemory(*MemoryID)
EndIf
EndProcedure
i693()
i694()
i695()
Greetings