Bug 20748 - Last stack trace entry truncated
Summary: Last stack trace entry truncated
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.14.0
Hardware: PC Mac OS
: Low enhancement
Target Milestone: 4.16.0
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-06-20 06:26 UTC by Mikkel Kamstrup Erlandsen
Modified: 2014-08-25 14:51 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
logcat snippet, as pasted, but without bugzilla butchering the layout :-) (6.81 KB, text/plain)
2014-06-20 06:29 UTC, Mikkel Kamstrup Erlandsen
Details
logcat dump showing that the 'mono' tag includes more info than 'MonoDroid' (5.47 KB, text/plain)
2014-06-23 03:12 UTC, Mikkel Kamstrup Erlandsen
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Mikkel Kamstrup Erlandsen 2014-06-20 06:26:45 UTC
Looking at the last stack trace entry with the 'mono' and 'mono-rt' tags below the last line in each is truncated - although the 'MonoDroid' tag is OK.

This is making it a bit troublesome to extract correct stack traces for mono apps when analyzing logcat dumps in Xamarin Test Cloud.


I/MonoDroid( 5673): UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
I/MonoDroid( 5673):   at XamarinStore.User+<IsInformationValid>c__async0.MoveNext () [0x00000] in <filename unknown>:0
I/MonoDroid( 5673): --- End of stack trace from previous location where exception was thrown ---
I/MonoDroid( 5673):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
I/MonoDroid( 5673):   at System.Runtime.CompilerServices.TaskAwaiter`1[System.Tuple`2[System.Boolean,System.String]].GetResult () [0x00000] in <filename unknown>:0
I/MonoDroid( 5673):   at XamarinStore.ShippingDetailsFragment+<ProcessOrder>c__async2.MoveNext () [0x00000] in <filename unknown>:0
I/MonoDroid( 5673): --- End of stack trace from previous location where exception was thrown ---
I/MonoDroid( 5673):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
I/MonoDroid( 5673):   at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0
I/MonoDroid( 5673):   at XamarinStore.ShippingDetailsFragment+<OnCreateView>c__AnonStorey4+<OnCreateView>c__async3.MoveNext () [0x00000] in <filename unknown>:0
E/mono    ( 5673):
E/mono    ( 5673): Unhandled Exception:
E/mono    ( 5673): System.NullReferenceException: Object reference not set to an instance of an object
E/mono    ( 5673):   at XamarinStore.User+<IsInformationValid>c__async0.MoveNext () [0x00000] in <filename unknown>:0
E/mono    ( 5673): --- End of stack trace from previous location where exception was thrown ---
E/mono    ( 5673):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
E/mono    ( 5673):   at System.Runtime.CompilerServices.TaskAwaiter`1[System.Tuple`2[System.Boolean,System.String]].GetResult () [0x00000] in <filename unknown>:0
E/mono    ( 5673):   at XamarinStore.ShippingDetailsFragment+<ProcessOrder>c__async2.MoveNext () [0x00000] in <filename unknown>:0
E/mono    ( 5673): --- End of stack trace from previous location where exception was thrown ---
E/mono    ( 5673):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
E/mono    ( 5673):   at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0
E/mono    ( 5673):   at XamarinStore.ShippingDetailsFragment+<OnCreateView>c__AnonStorey4+<OnCreateView>c__async3.MoveN
E/mono-rt ( 5673): [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
E/mono-rt ( 5673):   at XamarinStore.User+<IsInformationValid>c__async0.MoveNext () [0x00000] in <filename unknown>:0
E/mono-rt ( 5673): --- End of stack trace from previous location where exception was thrown ---
E/mono-rt ( 5673):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
E/mono-rt ( 5673):   at System.Runtime.CompilerServices.TaskAwaiter`1[System.Tuple`2[System.Boolean,System.String]].GetResult () [0x00000] in <filename unknown>:0
E/mono-rt ( 5673):   at XamarinStore.ShippingDetailsFragment+<ProcessOrder>c__async2.MoveNext () [0x00000] in <filename unknown>:0
E/mono-rt ( 5673): --- End of stack trace from previous location where exception was thrown ---
E/mono-rt ( 5673):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
E/mono-rt ( 5673):   at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0
E/mono-rt ( 5673):   at XamarinStore.ShippingDetailsFragment+<OnCreateView>c__AnonStorey4+<OnCreateView>c_
Comment 1 Mikkel Kamstrup Erlandsen 2014-06-20 06:29:31 UTC
Created attachment 7129 [details]
logcat snippet, as pasted, but without bugzilla butchering the layout :-)

Bugzilla makes the logcat snippet pretty hard to read - so attached it as a file as well.
Comment 2 Udham Singh 2014-06-20 09:29:33 UTC
I have checked this issue but not able to reproduce this. To reproduce this issue I have followed the steps below:

1. Create a simple android application.
2. Run and deploy the application on device.
3. Check the adb logcat.

Adb logcat : https://gist.github.com/anonymous/d44bb8947f951075c414

Could you please provide me sample application/test case, So that I can reproduce this issue at my end.

Environment Info :

=== Xamarin Studio ===

Version 5.1.1 (build 2)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
 Mono 3.6.0 ((no/f6ef3e7)
 GTK+ 2.24.23 (Raleigh theme)

 Package version: 306000000

=== Xamarin.Android ===

Version: 4.14.0 (Business Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
 Supported Android versions:
  2.1   (API level 7)
  2.2   (API level 8)
  2.3   (API level 10)
  3.1   (API level 12)
  3.2   (API level 13)
  4.0   (API level 14)
  4.0.3 (API level 15)
  4.1   (API level 16)
  4.2   (API level 17)
  4.3   (API level 18)
  4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Apple Developer Tools ===

Xcode 5.1 (5084)
Build 5B130a

=== Xamarin.iOS ===

Version: 7.9.0.278 (Business Edition)
Hash: e9d8eea
Branch: 
Build date: 2014-06-19 16:21:14-0400

=== Xamarin.Mac ===

Version:

=== Build Information ===

Release ID: 501010002
Git revision: 6e6238e51353c78a23011a47894b160c8ded4eaa
Build date: 2014-06-19 18:38:43-04
Xamarin addins: 4072f200bfd429706bec44bfa9ebf698f9439b67

=== Operating System ===

Mac OS X 10.9.2
Darwin MacMini.local 13.1.0 Darwin Kernel Version 13.1.0
    Thu Jan 16 19:40:37 PST 2014
    root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64
Comment 3 Jonathan Pryor 2014-06-20 09:57:40 UTC
@Udham: To see the described behavior, your app needs to (1) have an unhanded exception, and (2) the resulting stack trace from said unhanded exception needs to exceed ~1024 characters. Without meeting both conditions, you won't see the described truncation.

@Mikkel: The reason for this is logcat messages are written with __android_log_print(), which only prints ~1024 bytes of data before truncating. The MonoDroid handler splits lines before sending to __android_log_print() (so a really long individual stack _frame_ will be truncated), but each stack frame is written separately, which is why everything is printed. The mono and mono-rt messages don't perform line splitting, which is why they're truncated.

That said, is there any reason why the mono/mono-rt messages need to provide the full trace, instead of using the MonoDroid output? (Rephrased: why do you care?)
Comment 4 Mikkel Kamstrup Erlandsen 2014-06-23 03:12:23 UTC
Created attachment 7151 [details]
logcat dump showing that the 'mono' tag includes more info than 'MonoDroid'

A while back I tried to figure out which of MonoDroid, mono, or mono-rt to pick for exception parsing; and I found some cases where the mono source (and mono-rt) included slightly more specific info. In particular types and namespaces are qualified on method args, also method arg names are included. See the attached file for an example.

But it seems I have to go with MonoDroid then since the other sources are likely to be truncated, if I understand correctly.
Comment 5 Jonathan Pryor 2014-06-26 20:44:16 UTC
Looking at the output, it seems that the mono and mono-rt output includes method parameter names, while the MonoDroid output does not. I don't know why this is the case.

Furthermore, while re-investigating this I found that my statement in Comment #3 is currently incorrect: MonoDroid stack frames will also be truncated in the same way.

I have fixed this for a future release (probably 4.16+).

That said, I don't foresee the mono or mono-rt messages providing full output, as those are backed by g_logv(), which may be invoked during process abort/etc., so I want that as simple as possible so that we don't lose any log messages:

https://github.com/mono/mono/blob/975bf0a3/eglib/src/goutput.c#L144

MonoDroid, meanwhile, is done in C#. If it's executing, we're not at a catastrophic failure condition, so splitting long messages on newlines (and the associated memory allocations) shouldn't be a problem.
Comment 6 Saurabh 2014-08-13 10:40:51 UTC
As per guidance given in comment 3, we have tried it with different exceptions so that I could get exception having stack trace  of ~1024 characters. But I am getting stack trace having almost 300 characters. However, I can't reproduce this, we may have to see if a developer can figure out what's going on from the stack trace.
Comment 7 Udham Singh 2014-08-25 14:51:24 UTC
I have checked this issue and now this is working fine, Hence closing this issue.

Screencast : http://screencast.com/t/8Z20oSGZ

Adb Logcat : https://gist.github.com/Udham1/56494e39160ae7a849c2
Application Output : https://gist.github.com/Udham1/c7ebfbb97759aff2f3d3

Environment Info : 

=== Xamarin Studio ===

Version 5.2.1 (build 1)
Installation UUID: ce927b2a-2c07-44c5-b186-09cfdafba6dc
Runtime:
	Mono 3.6.0 ((no/f540f8a)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 306000039

=== Xamarin.Android ===

Version: 4.16.0 (Business Edition)
Android SDK: /Users/xamarin76/Desktop/android-sdk-macosx
	Supported Android versions:
		1.6   (API level 4)
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Build Information ===

Release ID: 502010001
Git revision: d06832ce9807d6be24aca225457e8b37c7669f6f
Build date: 2014-08-07 12:10:47-04
Xamarin addins: 1de032531be4cecf2f39dbee3b87aac78204058c

=== Operating System ===

Mac OS X 10.9.3
Darwin Xamarin76s-Mac-mini.local 13.2.0 Darwin Kernel Version 13.2.0
    Thu Apr 17 23:03:13 PDT 2014
    root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64