mail-archives/monodroid/2011-December/008036.html

104 строки
4.2 KiB
HTML
Исходник Обычный вид История

2019-06-06 22:06:39 +03:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [mono-android] PSA: runtime aborts without stack traces
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:monodroid%40lists.ximian.com?Subject=%5Bmono-android%5D%20PSA%3A%20runtime%20aborts%20without%20stack%20traces&In-Reply-To=">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="008033.html">
<LINK REL="Next" HREF="008076.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[mono-android] PSA: runtime aborts without stack traces</H1>
<B>Jonathan Pryor</B>
<A HREF="mailto:monodroid%40lists.ximian.com?Subject=%5Bmono-android%5D%20PSA%3A%20runtime%20aborts%20without%20stack%20traces&In-Reply-To="
TITLE="[mono-android] PSA: runtime aborts without stack traces">jonp at xamarin.com
</A><BR>
<I>Thu Dec 22 11:04:18 EST 2011</I>
<P><UL>
<LI>Previous message: <A HREF="008033.html">[mono-android] Adjust Emulator's Resolution
</A></li>
<LI>Next message: <A HREF="008076.html">[mono-android] ExecutionEngineException: SIGILL
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#8036">[ date ]</a>
<a href="thread.html#8036">[ thread ]</a>
<a href="subject.html#8036">[ subject ]</a>
<a href="author.html#8036">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>There have been several mentions of runtime aborts that do not contain a stack trace, e.g.
<A HREF="http://lists.ximian.com/pipermail/monodroid/2011-December/007756.html">http://lists.ximian.com/pipermail/monodroid/2011-December/007756.html</A>
<A HREF="http://lists.ximian.com/pipermail/monodroid/2011-December/007862.html">http://lists.ximian.com/pipermail/monodroid/2011-December/007862.html</A>
We have discovered a [0] cause: stack overflow.
Mono/ARM has no stack overflow support at the moment, so mono aborts on stack overflow. (Mono usually aborts _anyway_, but usually you'll at least get some stack trace output because of it. Mono/ARM does not. We will be improving this in a future release.)
Combined with a breaking change in Mono for Android 4.0, in which Java.Lang.Object.Dispose() was made non-virtual and a virtual Java.Lang.Object.Dispose(bool) method was added, it is now very easy to trigger stack overflow. Consider:
class Death : Java.Lang.Object {
protected override void Dispose (bool disposing)
{
Android.Util.Log.Info (&quot;death&quot;, &quot;Death.Dispose(bool)&quot;);
base.Dispose (); // BAD
}
}
If you create and dispose of an instance of Death:
using (var f = new Death ()) {
}
then your app will crash with a stack overflow, and no stack trace will be printed. (You will get a ton of &quot;Death.Dispose(bool)&quot; messages printed to logcat, but most Dispose() implementations won't actually log anything...hence the stacktrace-less nature of the abort.)
The solution is to review any Java.Lang.Object.Dispose(bool) overrides and ensure that IF they call base.Dispose(), they call the Dispose(bool) method, NOT Dispose():
base.Dispose(disposing); // GOOD
base.Dispose(); // BAD
This is in accordance with the IDisposable pattern:
<A HREF="http://msdn.microsoft.com/en-us/library/b1yfkh5e.aspx">http://msdn.microsoft.com/en-us/library/b1yfkh5e.aspx</A>
- Jon
[0] I have no idea if it's _the_ cause, but it's certainly _a_ cause. I'm always interested in further repros.
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="008033.html">[mono-android] Adjust Emulator's Resolution
</A></li>
<LI>Next message: <A HREF="008076.html">[mono-android] ExecutionEngineException: SIGILL
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#8036">[ date ]</a>
<a href="thread.html#8036">[ thread ]</a>
<a href="subject.html#8036">[ subject ]</a>
<a href="author.html#8036">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/monodroid">More information about the Monodroid
mailing list</a><br>
</body></html>