New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #484 [Win64]Cannot save and load image files with a heap whose size is more than 0xff ff ff ff (~4.1GB) #485
Fix #484 [Win64]Cannot save and load image files with a heap whose size is more than 0xff ff ff ff (~4.1GB) #485
Conversation
- Add Writing and Reading by block of MAX_DWORD
Display an error message if it the amount of bytes that should be written or read is not consistent
@@ -37,6 +37,7 @@ extern struct VirtualMachine *interpreterProxy; | |||
|
|||
#define true 1 | |||
#define false 0 | |||
static const DWORD MAX_DWORD = 4294967295; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static const DWORD MAX_DWORD = 4294967295; | |
static const DWORD MAX_DWORD = MAXDWORD; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...so really one could just use the constant provided by the Windows headers below.
BOOL ret = ReadFile((HANDLE)(h - 1), (LPVOID)((sqInt)ptr + (sqInt)reallyRead), toRead, &dwReallyRead, NULL); | ||
reallyRead += dwReallyRead; | ||
|
||
if (!ret | dwReallyRead != toRead) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether this is a bug or "clever" code to use the bitwise or. I suggest using the boolean operators (&& and ||) instead for clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not clever code here. Thanks for spotting it!
BOOL ret = WriteFile((HANDLE)(h - 1), (LPVOID)((sqInt)ptr + (sqInt) reallyWritten), toWrite, &dwReallyWritten, NULL); | ||
reallyWritten += dwReallyWritten; | ||
|
||
if (!ret | dwReallyWritten != toWrite) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
@jakob: Eliot seems to have merged this without incorporating your
feedback. Could you please open another PR with your suggestions?
Thanks,
Fabio
…On Sat, 11 Apr 2020 at 9:46 pm, Jakob Reschke ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In platforms/win32/plugins/FilePlugin/sqWin32FilePrims.c
<#485 (comment)>
:
> DWORD dwReallyWritten;
- WriteFile((HANDLE)(h-1), (LPVOID) ptr, count*sz, &dwReallyWritten, NULL);
- return (size_t) (dwReallyWritten / sz);
+ size_t totalToWrite = count * sz;
+ squeakFileOffsetType position;
+
+ position = sqImageFilePosition(h);
+ while (reallyWritten != totalToWrite) {
+ DWORD toWrite = (totalToWrite - reallyWritten) > (size_t) MAX_DWORD ? MAX_DWORD : totalToWrite - reallyWritten;
+ BOOL ret = WriteFile((HANDLE)(h - 1), (LPVOID)((sqInt)ptr + (sqInt) reallyWritten), toWrite, &dwReallyWritten, NULL);
+ reallyWritten += dwReallyWritten;
+
+ if (!ret | dwReallyWritten != toWrite) {
See above.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#485 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIJPEWYSLSBS2AMBET6YZLTRMDCK3ANCNFSM4MGDV3UQ>
.
|
… false ] on method [ is:onObjStack: ]
…false ] on method [ is:onObjStack: ] SURVIVED 8/8 test cases.
…oat value ] on method [ scavengingGCTenuringIf: ] 14 test cases.
…at value ] on method [ scavengingGCTenuringIf: ] 14/14 test case are EQUIVALENT
…ature/gdbinit Revert "gdbinit file and helpers"
The problem is actually when there is only one segment of memory of more of 0xff ff ff ff to read or to write to disk.
This fix the issue and it is tested with a real case on windows.
I added some checks on function return.
Let me know if changes are to be done to follows some conventions or optimizations.