Ticket #1753 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

PMC attribute blocks not aligned

Reported by: Paul C. Anagnostopoulos Owned by: Paul C. Anagnostopoulos
Priority: normal Milestone:
Component: core Version: 2.6.0
Severity: high Keywords:
Cc: Language:
Patch status: Platform:


As far as I can tell, PMC attribute blocks are not aligned as they are allocated in fixed-size PMC attribute pools. The memory manager assures that an attribute block is at least the size of a pointer, since free attribute blocks will be linked on the free lists. But it does not assure that each block starts on a pointer-aligned boundary. This probably doesn't matter to the standard PMCs, since their attributes are all integers, floats, or pointers. But a custom PMC could have, say, 13 bytes of short integers and/or characters.

I'm not completely sure I've analyzed this correctly, so I'll assign this ticket to myself for further analysis.

Change History

Changed 6 years ago by Paul C. Anagnostopoulos

  • owner set to Paul C. Anagnostopoulos
  • status changed from new to assigned

Changed 6 years ago by NotFound

The attributes are declared as a C struct, and PMCs that inherits from other copy the ones from the parent at the begin of its struct, So the C compiler takes care of the alignment. I don't think we need additional measures.

Changed 6 years ago by Paul C. Anagnostopoulos

If the attributes are, say, various short ints and/or chars, what would cause the struct size to be rounded to a multiple of the pointer size? C only guarantees that the size is rounded so that the first item in the struct is aligned on its required boundary.

Changed 6 years ago by NotFound

If there is no attribute of any pointer type there is no need to such alignment. What problem are you trying to solve?

Changed 6 years ago by Paul C. Anagnostopoulos

When the attribute block is freed, it is chained on a list of free blocks with a pointer at the beginning of the block. That pointer might need to be aligned. This is why the allocator ensures that the block is at least sizeof (void *) bytes in length. But it doesn't round up the size, so every block except the first might be misaligned.

Changed 6 years ago by Paul C. Anagnostopoulos

This problem appears to be fixed in the new gc_massacre collectors.

Changed 6 years ago by bacek

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

gc_massacre branch merged back to trunk. Closing ticket.

Note: See TracTickets for help on using tickets.