[GHC] #8627: mallocForeignPtrBytes documentation unobvious regarding memory alignment

#8627: mallocForeignPtrBytes documentation unobvious regarding memory alignment ------------------------------------+------------------------------------- Reporter: schernichkin | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Documentation | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- 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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8627 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8627: mallocForeignPtrBytes documentation unobvious regarding memory alignment -------------------------------------+------------------------------------- Reporter: | Owner: ekmett schernichkin | Status: new Type: bug | Milestone: Priority: normal | Version: 7.6.3 Component: Core | Keywords: Libraries | Architecture: Unknown/Multiple Resolution: | Difficulty: Unknown Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | Documentation bug | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (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. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8627#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8627: mallocForeignPtrBytes documentation unobvious regarding memory alignment -------------------------------------+------------------------------------- Reporter: | Owner: ekmett schernichkin | Status: new Type: bug | Milestone: Priority: normal | Version: 7.6.3 Component: Core | Keywords: Libraries | Architecture: Unknown/Multiple Resolution: | Difficulty: Unknown Operating System: | Blocked By: Unknown/Multiple | Related Tickets: #9806 Type of failure: | Documentation bug | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by ekmett): * related: => #9806 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8627#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8627: mallocForeignPtrBytes documentation unobvious regarding memory alignment -------------------------------------+------------------------------------- Reporter: | Owner: ekmett schernichkin | Status: new Type: bug | Milestone: Priority: normal | Version: 7.6.3 Component: Core | Keywords: Libraries | Architecture: Unknown/Multiple Resolution: | Difficulty: Unknown Operating System: | Blocked By: Unknown/Multiple | Related Tickets: #9806 Type of failure: | Documentation bug | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by ekmett): Leaving this ticket open to address the documentation issue. I've opened #9806 to address potential library changes though. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8627#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC