Exit Posted October 25, 2020 Share Posted October 25, 2020 (edited) Edit: Bug fixed in Beta 3.3.15.4 Edit: This is a restriction in the string length of 2GB for Autoit strings. More information in third post. ----------------------------------------------------- When testing my file verification script, I noticed that 1GB blocks can be written but not read. The maximum block size is 1073741822 bytes. With a block size of 1073741823 or more, Fileread() ends with @error = 0 and @extended shows the correct size, but there is an empty string in the receiving variable. Here is a reproducer: expandcollapse popup#AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w no4 -w 5 -w 6 -w 7 #include <String.au3> Local $sTestDir = "C:\~Test~\" Local $hFileHandle, $iLength, $s1GB, $sInitData, $sReadData DirCreate($sTestDir) FileDelete($sTestDir & "*.txt") ShellExecute($sTestDir) OnAutoItExitRegister(_Exit) Func _Exit() MsgBox(64 + 262144, Default, "Press OK to exit.", 0) DirRemove($sTestDir, 1) Sleep(3000) WinClose("[TITLE:" & StringLeft($sTestDir, 3) & "; CLASS:CabinetWClass]") EndFunc ;==>_Exit $iLength = 1024 * 1024 * 1024 ; 1 Gigabyte $s1GB = _StringRepeat("-", $iLength) $iLength -= 3 For $i = 1 To 2 Beep(1000, 100) $iLength += 1 $hFileHandle = FileOpen($sTestDir & $i & ".txt", 2) $sInitData = StringLeft($i & $s1GB, $iLength) FileWrite($hFileHandle, $sInitData) FileSetPos($hFileHandle, 0, 0) $sReadData = FileRead($hFileHandle) ConsoleWrite(@LF & "Fileread $i:" & $i & " Error: " & @error & " Extended: " & @extended & @LF & " Datalen: " & StringLen($sInitData) & @LF & "ReadDatalen: " & StringLen($sReadData) & @LF & "ReadData(first 10 Bytes): >" & StringLeft($sReadData, 10) & "< " & @LF & "Stringcompare Result: " & (StringCompare($sInitData, $sReadData, 1) ? "NOT" : "") & " equal" & @LF & @LF) If StringCompare($sReadData, $sInitData, 1) Then Exit MsgBox(16 + 262144, Default, "Compare Error. I=" & $i, 0) FileClose($hFileHandle) Next and here is the console log: Fileread $i:1 Error: 0 Extended: 1073741822 Datalen: 1073741822 ReadDatalen: 1073741822 ReadData(first 10 Bytes): >1---------< Stringcompare Result: equal Fileread $i:2 Error: 0 Extended: 1073741823 Datalen: 1073741823 ReadDatalen: 0 ReadData(first 10 Bytes): >< Stringcompare Result: NOT equal I think Fileread() should return an error code in this case. Or am I on the wrong track? Edited June 12, 2021 by Exit Edit: Bug fixed in Beta 3.3.15.4 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Musashi Posted October 25, 2020 Share Posted October 25, 2020 Maybe thread a-set-of-question-for-file brings some light into the dark. Especially the posts from @Valik I consider as very informative. Exit 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Exit Posted October 26, 2020 Author Share Posted October 26, 2020 (edited) @Musashi Thanks for the info. I will investigate and report here soon. Stay tuned. --------------------------------------------------------------------------------- The maximum string length in Autoit is 2GB Since each character in UTF8 is 2 bytes long, only 1GB strings can be processed. When using ANSI, each character is only 1 byte long and a 2GB string can then be processed. You have to accept this limitation.But that doesn't change the fact that it is probably wrong to set an error code of 0 under these circumstances and return an empty variable. Is this a case for the bug tracker? Please give your opinion. Edited November 7, 2020 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
JockoDundee Posted October 26, 2020 Share Posted October 26, 2020 32bit version, 64bit version? Both? Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
jchd Posted October 26, 2020 Share Posted October 26, 2020 7 hours ago, Exit said: The maximum string length in Autoit is 2GB Since each character in UTF8 is 2 bytes long, only 1GB strings can be processed. When using ANSI, each character is only 1 byte long and a 2GB string can then be processed. No: UTF8 uses 1 to 4 bytes per Unicode character. Whatever encoding a text source uses (file or not), native AutoIt strings uses UCS2 encoding (the first 64k Unicode codepoints, without surrogates) so every character in such a string uses one 16-bit encoding unit, limiting character count to 2Gi. 7 hours ago, Exit said: Is this a case for the bug tracker? My opinion is YES. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Exit Posted October 26, 2020 Author Share Posted October 26, 2020 7 hours ago, JockoDundee said: 32bit version, 64bit version? Both? See first line of script: #AutoIt3Wrapper_UseX64=y App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Exit Posted November 7, 2020 Author Share Posted November 7, 2020 Bug created in bug tracker : https://www.autoitscript.com/trac/autoit/ticket/3789#ticket App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Solution Exit Posted June 12, 2021 Author Solution Share Posted June 12, 2021 Edit: Bug fixed in Beta 3.3.15.4 and working perfect. Musashi 1 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now