Skip to content
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

Merged

Conversation

VincentBlondeau
Copy link
Contributor

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.

- 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static const DWORD MAX_DWORD = 4294967295;
static const DWORD MAX_DWORD = MAXDWORD;

Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

@eliotmiranda eliotmiranda merged commit 2a79468 into OpenSmalltalk:Cog Apr 11, 2020
@OpenSmalltalk-Bot
Copy link

OpenSmalltalk-Bot commented Apr 11, 2020 via email

VincentBlondeau added a commit to VincentBlondeau/opensmalltalk-vm that referenced this pull request Apr 12, 2020
hogoww referenced this pull request in hogoww/opensmalltalk-vm Dec 23, 2021
hogoww referenced this pull request in hogoww/opensmalltalk-vm Dec 23, 2021
…false ] on method [ is:onObjStack: ] SURVIVED 8/8 test cases.
hogoww referenced this pull request in hogoww/opensmalltalk-vm Feb 26, 2022
…oat value ] on method [ scavengingGCTenuringIf: ] 14 test cases.
hogoww referenced this pull request in hogoww/opensmalltalk-vm Feb 26, 2022
…at value ] on method [ scavengingGCTenuringIf: ] 14/14 test case are EQUIVALENT
guillep added a commit to tesonep/opensmalltalk-vm that referenced this pull request May 12, 2023
…ature/gdbinit

Revert "gdbinit file and helpers"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants