Bugzilla – Bug 323935
[SPARC] Throws NRE on unaligned members in structures (e.g. Pack=2)
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by sebastien@ximian.com 2007-03-28 09:55:24 MST ---- Description of Problem: A structure used for metafile headers has a misaligned integer in it. [StructLayout (LayoutKind.Sequential, Pack=2)] internal struct WmfMetaHeader { public short file_type; public short header_size; public short version; // this is unaligned and fails on the SPARC architecture public int file_size; public short num_of_objects; public int max_record_size; public short num_of_params; } Using them throw NRE. Steps to reproduce the problem: 1. Declare structure 2. Assign value to file_size Actual Results: NRE on SPARC arch. Expected Results: No NRE (like other archs) How often does this happen? Always Additional Information: - I can work around this, either permanently or temporarily, in C#; ---- Additional Comments From vargaz@gmail.com 2007-03-28 10:07:56 MST ---- This is the correct behavior, since you are telling the runtime to align the int32 field at an unaligned location. So this is not a bug. ---- Additional Comments From sebastien@ximian.com 2007-03-28 10:26:33 MST ---- Ah, I just found it strange that it happened only on SPARC as other archs also have alignment requirements. Somehow I suspected their JIT to hide (well trap and deal with) the alignement issue. Please close if this is the correct behavior. Thanks! ---- Additional Comments From vargaz@gmail.com 2007-03-28 10:57:58 MST ---- Every arch has alignment reqs, but only sparc faults on unaligned accesses. I think the current behavior is correct, so closing. Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>Solaris and Linux</cf_op_sys_details>