I have tested the fix to align the return value of sbrk().
The sinle line fix is sufficient to fix the problem.
So this indicates that the return value of sbrk() is related to the problem.

The Single UNIX Specification (SUS) and POSIX standards seem unclear on these subtle properties of the return value.

The SUS standard however seems to be aware of the problem because it states "It is unspecified whether the pointer returned by sbrk() is aligned suitably for any purpose."

See https://pubs.opengroup.org/onlinepubs/7908799/xsh/brk.html for the specification on sbrk()

The Linux manpage is not saying anything on the issue (on a Linux system that I've checked) but the Linux manpage says "STANDARDS
4.3BSD; SUSv1, marked LEGACY in SUSv2, removed in POSIX.1-2001.

NOTES
Avoid using brk() and sbrk(): the malloc(3) memory allocation package
is the portable and comfortable way of allocating memory."

The Standard SUSv1 is probably the one from the Open Group (Single UNIX Specification).

I have submitted a pull request for my proposal for patch or fix.

It is now more clear to me that the return value of sbrk() has something to do with it, but the mmap() call itself is not failing.

As I wrote before my fix comes from copying Eliot's code and by using the example from sqAllocateMemory() which is also using sbrk() but it is doing an alignment calculation on the return value of sbrk() and from sqAllocateMemorySegmentOfSizeAboveAllocatedSizeInto() which has a loop doing mmap() and doing alignment calculations.

So my reasoning for the patch was that because of "consistency" or "symmetry" the same alignment calculation (which I copied from those functions) need to be applied in allocateJITMemory().

The return value of sbrk() is not wrong or right, but for the purpose of the loop in sqAllocateMemorySegmentOfSizeAboveAllocatedSizeInto() it must be aligned for that particular purpose of that loop.

Regards,
David Stes


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <OpenSmalltalk/opensmalltalk-vm/issues/665/1879779596@github.com>