[Mono-bugs] [Bug 77123][Nor] New - file object.c: line 503 (compute_class_bitmap): assertion failed: ((field->offset % sizeof(gpointer)) == 0)

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Dec 29 15:05:54 EST 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by tjfontaine at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=77123

--- shadow/77123	2005-12-29 15:05:54.000000000 -0500
+++ shadow/77123.tmp.22415	2005-12-29 15:05:54.000000000 -0500
@@ -0,0 +1,199 @@
+Bug#: 77123
+Product: Mono: Runtime
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: ubuntu breezy
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: tjfontaine at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: file object.c: line 503 (compute_class_bitmap): assertion failed: ((field->offset % sizeof(gpointer)) == 0)
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+Everytime code is run it aborts with:
+file object.c: line 503 (compute_class_bitmap): assertion failed:
+((field->offset % sizeof(gpointer)) == 0)
+
+Steps to reproduce the problem:
+1. Compile the following code with gmcs /unsafe Fat32.cs
+
+using System;
+using System.IO;
+using System.Runtime.InteropServices;
+
+namespace Atx.FileSystem.VFat
+{
+    public class Fat32
+    {
+        private ushort brsanity = 0x55AA;
+        private uint fsisanity1 = 0x52526141;
+        private uint fsisanity2 = 0x72724161;
+
+        private Fat32BootRecord bootrecord;
+        private Fat32FileSystemInfo filesysteminfo;
+
+        private Stream file;
+
+	public static void Main(string[] args)
+	{
+		Fat32 fat;
+		
+		if(File.Exists(args[0]))
+		{
+			using(FileStream fs = new FileStream(args[0], FileMode.Open))
+			{
+				fat = new Fat32(fs);
+			}
+		}
+		else
+		{
+			Console.WriteLine("Usage: Fat32.exe <fat32 image file>");
+		}
+	}
+
+        public Fat32(Stream f)
+        {
+            file = f;
+            ReadBootRecord();
+            ReadFileSystemInfo(bootrecord.sectornumfsi,
+bootrecord.bytespersector);
+        }
+
+        private void ReadFileSystemInfo(int sectorNum, int sectorSize)
+        {
+            byte[] buff = new byte[512];
+            file.Seek(sectorNum * sectorSize, SeekOrigin.Begin);
+            file.Read(buff, 0, 512);
+
+            filesysteminfo = ReadStruct<Fat32FileSystemInfo>(buff);
+
+            if (filesysteminfo.brsignature != brsanity ||
+filesysteminfo.firstsignature != fsisanity1 ||
+                filesysteminfo.secondsignature != fsisanity2)
+                throw new Exception("Failed File System Info Signature
+Sanity Check");
+        }
+
+        private void ReadBootRecord()
+        {
+            byte[] buff = new byte[512];
+            file.Read(buff, 0, 512);
+
+            bootrecord = ReadStruct<Fat32BootRecord>(buff);
+
+            if (bootrecord.signature != brsanity)
+                throw new Exception("Failed Boot Record Singature Sanity
+Check");
+            
+            buff = null;
+        }
+
+        private T ReadStruct<T>(byte[] source) where T: struct
+        {
+            int objectSize = Marshal.SizeOf(typeof(T));
+
+            if (source.Length < objectSize)
+                throw new Exception("Size Mismatch");
+            
+            T returnStruct;
+
+            unsafe
+            {
+                fixed (byte* bufferPointer = &source[0])
+                    returnStruct =
+(T)Marshal.PtrToStructure((IntPtr)bufferPointer, typeof(T));
+            }
+
+            return returnStruct; 
+        }
+    }
+
+    [StructLayout(LayoutKind.Sequential, Size=512, Pack = 1)]
+    public struct Fat32FileSystemInfo
+    {
+        public uint firstsignature;
+	[MarshalAs(UnmanagedType.ByValArray, SizeConst=480)]
+        public byte[] unknown;
+        public uint secondsignature;
+        public uint numoffreeclusters;
+        public uint recentclusteralloc;
+	[MarshalAs(UnmanagedType.ByValArray, SizeConst=12)]
+        public byte[] reserved;
+        public ushort unknown2;
+        public ushort brsignature;
+    }
+
+    [StructLayout(LayoutKind.Sequential, Size=512, Pack=1)]
+    public struct Fat32BootRecord
+    {
+        [MarshalAs(UnmanagedType.ByValArray, SizeConst=3)]
+        public byte[] jmpcode;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=8)]
+        public string oemname;
+        public ushort bytespersector;
+        public byte sectorspercluster;
+        public ushort reservedsectors;
+        public byte numoffats;
+        public ushort maxrootentries;
+        public ushort numofsmallsectors;
+        public byte mediadescriptor;
+        public ushort sectorsperfat;
+        public ushort sectorspertrack;
+        public ushort numofheads;
+        public uint numofhiddensectors;
+        public uint numofsectors;
+        public uint numofsectorsperfat;
+        public ushort flags;
+        public ushort version;
+        public uint clusterstartnum;
+        public ushort sectornumfsi;
+        public ushort sectornumback;
+        [MarshalAs(UnmanagedType.ByValArray, SizeConst=12)]
+        public byte[] reserved;
+        public byte logicaldrivenum;
+        public byte unused;
+        public byte extsignature;
+        public uint serialnum;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=11)]
+        public string volumename;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst=8)]
+        public string fatname;
+        [MarshalAs(UnmanagedType.ByValArray, SizeConst=420)]
+        public byte[] exectuablecode;
+        public ushort signature;
+    }
+}
+
+2. run with mono Fat32.exe (with or without arguments)
+3. 
+
+Actual Results:
+tjfontaine at xenmaster:~$ mono Fat32.exe fat32.img
+
+** ERROR **: file object.c: line 503 (compute_class_bitmap): assertion
+failed: ((field->offset % sizeof(gpointer)) == 0)
+aborting...
+Aborted
+
+
+Expected Results:
+it would run
+
+How often does this happen? 
+every time
+
+Additional Information:
+The code compiles fine and runs as expected on ms.net 2.0. I tried several
+different ways to get around it, as it's own seperate assembly, generics
+and no unsafe, no generics with unsafe, and no generics and no unsafe,
+compiling with gmcs or mcs, with latest svn or 1.1.10 on multiple linux
+systems. All resulted in the same error.


More information about the mono-bugs mailing list