[Mono-bugs] [Bug 76010][Nor] New - Error when judging out of memory
when using string and stringbuilder
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Wed Sep 7 11:24:01 EDT 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 zig.wei at gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=76010
--- shadow/76010 2005-09-07 11:24:01.000000000 -0400
+++ shadow/76010.tmp.25467 2005-09-07 11:24:01.000000000 -0400
@@ -0,0 +1,70 @@
+Bug#: 76010
+Product: Mono: Class Libraries
+Version: 1.1
+OS: Red Hat 9.0
+OS Details:
+Status: NEW
+Resolution:
+Severity: 008 One day
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: zig.wei at gmail.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Error when judging out of memory when using string and stringbuilder
+
+Please fill in this template when reporting a bug, unless you know what
+you are doing.
+Description of Problem:
+
+The mono's new string code is as following:
+
+MonoString *
+mono_string_new_size (MonoDomain *domain, gint32 len)
+{
+ MonoString *s;
+ MonoVTable *vtable;
+ size_t size = (sizeof (MonoString) + ((len + 1) * 2));
+
+ /* overflow ? can't fit it, can't allocate it! */
+==========================
+ if (len > size)
+ mono_gc_out_of_memory (-1);
+==========================
+
+ vtable = mono_class_vtable (domain, mono_defaults.string_class);
+
+ s = mono_object_allocate_ptrfree (size, vtable);
+
+ s->length = len;
+#if NEED_TO_ZERO_PTRFREE
+ s->chars [len] = 0;
+#endif
+ mono_profiler_allocation ((MonoObject*)s,
+mono_defaults.string_class);
+
+ return s;
+}
+
+However, size = (sizeof (MonoString) + ((len + 1) * 2)) < len is always
+false. This is a wrong condition for judging out of memory. I'm suffering
+from out of memory error (this is another bug) when using StringBuider
+class and happened to see this mistake.
+
+
+Steps to reproduce the problem:
+no neeed, error in source code
+
+Actual Results:
+
+
+Expected Results:
+
+
+How often does this happen?
+
+
+Additional Information:
More information about the mono-bugs
mailing list