[Mono-bugs] [Bug 65089][Min] New - Marshal.AllocHGlobal returns NULL (0) on Linux
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 1 Sep 2004 11:34:49 -0400 (EDT)
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 t7@pobox.com.
http://bugzilla.ximian.com/show_bug.cgi?id=65089
--- shadow/65089 2004-09-01 11:34:48.000000000 -0400
+++ shadow/65089.tmp.2402 2004-09-01 11:34:48.000000000 -0400
@@ -0,0 +1,55 @@
+Bug#: 65089
+Product: Mono: Runtime
+Version: unspecified
+OS:
+OS Details: GNU/Linux (all)
+Status: NEW
+Resolution:
+Severity:
+Priority: Minor
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: t7@pobox.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Marshal.AllocHGlobal returns NULL (0) on Linux
+
+Description of Problem:
+System.Runtime.InteropServices.Marshal.AllocHGlobal returns NULL (0)
+pointer on failure instead of throwing OutOfMemoryException
+
+
+Steps to reproduce the problem:
+1. Compile test case below
+2. run it
+3.
+
+Actual Results:
+prints p=0
+
+Expected Results:
+should abort with OutOfMemoryException
+
+How often does this happen?
+every time (unless you have 1GB of free RAM!)
+
+using System;
+using System.Runtime.InteropServices;
+
+public class MarshalTest
+{
+ public static void Main()
+ {
+ IntPtr p = Marshal.AllocHGlobal(1024*1024*1024);
+ Console.WriteLine("p="+p);
+ }
+}
+
+
+Additional Information:
+System.Runtime.InteropServices.Marshal.AllocHGlobal is implemented
+in mono/metadata/marshal.c function mono_marshal_alloc(gpointer size)
+which just calls g_try_malloc(size), but doesn't check the return
+value for NULL.