#2917: alloca and allocaArray do not respect alignment
-------------------------------+--------------------------------------------
    Reporter:  guest           |        Owner:                  
        Type:  bug             |       Status:  new             
    Priority:  normal          |    Milestone:                  
   Component:  Compiler (FFI)  |      Version:  6.10.1          
    Severity:  normal          |   Resolution:                  
    Keywords:                  |   Difficulty:  Unknown         
    Testcase:                  |           Os:  Unknown/Multiple
Architecture:  x86             |  
-------------------------------+--------------------------------------------
Comment (by guest):

 Trying to fix my patch to not waste memory I realized that the patch is
 broken.
 It takes a pointer from some internal malloc and adjusts it for alignment.
 This will not work when that pointer is later given to free.

 I'm not sure how to fix this.  It seems we need to have the low level
 allocator return a pointer that is properly aligned, otherwise giving the
 block back to the low level free will never work.

 In short, I don't know how to fix this.

 Note that this is a real problem.  Using SSE instructions on the x86
 requires the vectors to be properly aligned, otherwise you get a fault.
 So I can't use any of the allocators for Storable in Foreign (nor
 Data.Array.Storable) when allocating vectors.

 A hack would be to have the allocator return everything 16 byte aligned,
 but that really is a hack.  The longer term solution must take alignment
 into account.

   -- Lennart

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2917#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to