Fix 32-bit build, array size too large - #47
Open
mcprat wants to merge 1 commit into
Open
Conversation
Building on 32-bit archs causes the following error:
type [1073741824]*_Ctype_char larger than address space
This is because the maximum size limit of the array is 1 GiB,
which is equal to an array length 1 << 30 for 1 byte elements.
However, for the function goStrings(), the elements in the array
are pointers that are 4 bytes long, making it 4 times the limit.
Fix this by reducing the array by the exact difference in bytes
so both arrays are now the same total size in 32-bit address space.
1 << 30 / 4 == 1 << (30-2) == 1 << 28
Signed-off-by: Michael Pratt <mcpratt@pm.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Building on 32-bit archs causes the following error:
This is because the maximum size limit of the array is 1 GiB, which is equal to an array length 1 << 30 for 1 byte elements. However, for the function goStrings(), the elements in the array are pointers that are 4 bytes long, making it 4 times the limit.
Fix this by reducing the array by the exact difference in bytes so both arrays are now the same total size in 32-bit address space. 1 << 30 / 4 == 1 << (30-2) == 1 << 28