Bug 323935 (MONO81254) - [SPARC] Throws NRE on unaligned members in structures (e.g. Pack=2)
Summary: [SPARC] Throws NRE on unaligned members in structures (e.g. Pack=2)
Status: RESOLVED INVALID
Alias: MONO81254
Product: Mono: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: 1.2
Hardware: Other All
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Paolo Molaro
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-28 16:55 UTC by Sebastien Pouliot
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:33:55 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>