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

Do not attempt to allocate >= 4 GiB on 32-bit systems #99

Merged
merged 1 commit into from Jul 9, 2019
Merged

Conversation

@tevador
Copy link
Owner

@tevador tevador commented Jul 3, 2019

  • Cache size limited to 2 GiB
@@ -102,6 +103,12 @@ extern "C" {
}

randomx_dataset *randomx_alloc_dataset(randomx_flags flags) {

//fail on 32-bit systems if DatasetSize is >= 4 GiB
Copy link
Collaborator

@hyc hyc Jul 3, 2019

Choose a reason for hiding this comment

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

Shouldn't the failure threshold be much smaller? At 4GiB there is no room in the address space for any other code or data.

Loading

Copy link
Owner Author

@tevador tevador Jul 3, 2019

Choose a reason for hiding this comment

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

If the computer doesn't have enough virtual memory (which is likely) then the allocation will fail naturally.

This condition is in place to prevent an overflow which could make the allocation to falsely succeed. For example if DatasetSize is 4.5 GiB, it will overflow to 0.5 GiB on 32-bit systems and only 0.5 GiB will be allocated, leading to runtime crashes.

Loading

Copy link
Collaborator

@hyc hyc Jul 3, 2019

Choose a reason for hiding this comment

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

ok

Loading

hyc
hyc approved these changes Jul 3, 2019
@tevador tevador merged commit 47ade5e into master Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants