Opened 3 years ago

Last modified 21 months ago

#8627 new bug

mallocForeignPtrBytes documentation unobvious regarding memory alignment

Reported by: schernichkin Owned by:
Priority: normal Milestone:
Component: Core Libraries Version: 7.6.3
Keywords: Cc: core-libraries-committee@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Documentation bug Test Case:
Blocked By: Blocking:
Related Tickets: #9806 Differential Rev(s):
Wiki Page:


According to the current documentation:

mallocForeignPtr - is equivalent to do { p <- malloc; newForeignPtr finalizerFree p }. It's ok since we can read that the "block of memory is sufficiently aligned" if the mallocBytes function descriprion and newAlignedPinnedByteArray in the function implementation.

mallocForeignPtrBytes - "similar to mallocForeignPtr" but will it alloc aligned memory? Internally it uses newPinnedByteArray which implies memory will not be aligned, but does it really makes any sense?

Plz correct documentation to make it more obvious.

Change History (5)

comment:1 Changed 3 years ago by thomie

Cc: core-libraries-committee@… added
Component: DocumentationCore Libraries
Owner: set to ekmett
Type of failure: None/UnknownDocumentation bug

comment:2 Changed 3 years ago by ekmett

mallocForeignPtrBytes provides no alignment guarantees. You should in theory need to pad your request by (alignment - 1) bytes and align the resulting memory by hand.

We're missing a mallocForeignPtrBytesAligned, which would behave like allocaBytesAligned which probably should become a separate issue.

comment:3 Changed 3 years ago by ekmett

comment:4 Changed 3 years ago by ekmett

Leaving this ticket open to address the documentation issue.

I've opened #9806 to address potential library changes though.

comment:5 Changed 21 months ago by thomie

Owner: ekmett deleted
Note: See TracTickets for help on using tickets.