Opened 6 years ago

Last modified 4 years ago

#7901 new Bugs

jam's hash.c misaligns hashed entries

Reported by: martin@… Owned by: Vladimir Prus
Milestone: To Be Determined Component: build
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:


On platforms where a void* is smaller (e.g. 32bit) than a time_t (e.g. 64bit) and where the cpu requires strict alignment, jam bus errors already during bootstrap. NetBSD/sparc is an example for such a platform.

This is because the hash_item_data macro () casts to char* and adds sizeof a struct only containing a pointer, while later filesys code stores file_info_t structures in a hash (which include time_t members and need greater alignment).

Since this is all needed very early, the easiest and most portable solution is to force sizeof(ITEM) to be great enough for the required alignment by making it a union including a dummy time_t member. This has the benefit of beeing a no-op for non affected architectures.

I have a patch tested against the 1.52 release, but the idea should be obvious and applying it to the (a bit different) trunk code should be straighforward. Please let me know if you need a real patch against trunk.

Attachments (1)

patch (2.1 KB) - added by martin@… 6 years ago.
working patch against 1.52

Download all attachments as: .zip

Change History (2)

Changed 6 years ago by martin@…

Attachment: patch added

working patch against 1.52

comment:1 Changed 4 years ago by Kohei Takahashi <flast@…>

Component: Building Boostbuild
Owner: set to Vladimir Prus
Note: See TracTickets for help on using tickets.