Ticket #3800 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

sizeofByteArray# returns allocated words, not requested length in bytes

Reported by: AntoineLatter Owned by:
Priority: high Milestone: 7.0.1
Component: Compiler Version: 6.12.1
Keywords: Cc: aslatter@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo) (diff)

A byte array allocated with (GHC.Prim.newByteArray# 7) will report it's size as '8' - that is, the stored size in StgArrWords is the number of allocated words, not the number of requested bytes.

This menas that if I want to a GHC.Prim.ByteArray# or MutableByteArray# as an array type, I need a separate length fields.

See also:  http://www.haskell.org/pipermail/glasgow-haskell-users/2009-December/018199.html

Attachments

ghc_StgArrWords.2.dpatch Download (65.9 KB) - added by AntoineLatter 3 years ago.
patch for rts
ghc_StgArrWords.dpatch Download (65.9 KB) - added by AntoineLatter 3 years ago.
patch for rts
gmp_StgArrWords.dpatch Download (7.9 KB) - added by AntoineLatter 3 years ago.
patch for libraries/integer-gmp

Change History

Changed 3 years ago by AntoineLatter

patch for rts

Changed 3 years ago by AntoineLatter

patch for rts

Changed 3 years ago by AntoineLatter

patch for libraries/integer-gmp

Changed 3 years ago by simonmar

  • owner changed from AntoineLatter to simonmar
  • priority changed from normal to high
  • milestone set to 6.14.1

Nice patch, looks perfect. I'll milestone this for 6.14.1, since it would be a change in behaviour that people will want to rely on, so we can't make that change in a minor release.

Changed 3 years ago by AntoineLatter

  • cc aslatter@… added

Changed 3 years ago by simonmar

  • owner changed from simonmar to igloo
  • milestone changed from 6.14.1 to 6.12.2

This patch fixes the docs for 6.12.2, Ian could you merge please, and then milestone back to 6.14.1?

Tue Jan 19 10:38:25 GMT 2010  Simon Marlow <marlowsd@gmail.com>
  * Fix docs for sizeofByteArray#/sizeofMutableByteArray# (#3800)
  In 6.14.1 we'll switch these primops to return the exact byte size,
  but for 6.12.2 we need to fix the docs.

Changed 3 years ago by igloo

  • milestone changed from 6.12.2 to 6.14.1

Merged

Changed 3 years ago by igloo

  • owner igloo deleted

Changed 3 years ago by igloo

  • description modified (diff)

Changed 3 years ago by igloo

  • status changed from new to patch

Changed 3 years ago by igloo

  • status changed from patch to closed
  • resolution set to fixed

Patch applied, thanks!

Note: See TracTickets for help on using tickets.