Skip to content

Commit

Permalink
Merge pull request #138 from fandrei/issue138-stackoverflow-exception…
Browse files Browse the repository at this point in the history
…-in-mono

Stack overflow in unmanaged: IP: 0x5fad4c, fault addr: 0x7f7fc7a89b28
  • Loading branch information
fandrei committed Jun 28, 2013
2 parents bb383fb + 337c05c commit 3dc32eb
Show file tree
Hide file tree
Showing 10 changed files with 1,206 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "issue138-StackOverflowException-on-Mono", "issue138-StackOverflowException-on-Mono\issue138-StackOverflowException-on-Mono.csproj", "{FA5AABB4-E49C-4F4D-AAA3-AB512F448BE1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FA5AABB4-E49C-4F4D-AAA3-AB512F448BE1}.Debug|x86.ActiveCfg = Debug|x86
{FA5AABB4-E49C-4F4D-AAA3-AB512F448BE1}.Debug|x86.Build.0 = Debug|x86
{FA5AABB4-E49C-4F4D-AAA3-AB512F448BE1}.Release|x86.ActiveCfg = Release|x86
{FA5AABB4-E49C-4F4D-AAA3-AB512F448BE1}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = issue138-StackOverflowException-on-Mono\issue138-StackOverflowException-on-Mono.csproj
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using Microsoft.VisualBasic.Devices;

namespace issue138StackOverflowExceptiononMono
{
class MainClass
{
public static void Main (string[] args)
{
/* When run under Mono, generates evens like:
* POST http://foo.com
AccessKey=accessKey
MessageAppKey=appKey
MessagesList=7ca6f023-f945-4052-a566-609aae8acde0 2013-06-27 17:10:02.9872070 System_OsName Unix
7ca6f023-f945-4052-a566-609aae8acde0 2013-06-27 17:10:02.9892350 System_OsVersion Unix 12.4.0.0
7ca6f023-f945-4052-a566-609aae8acde0 2013-06-27 17:10:02.9893300 System_ComputerName maccy001
7ca6f023-f945-4052-a566-609aae8acde0 2013-06-27 17:10:02.9893920 System_UserName mrdavidlaing
7ca6f023-f945-4052-a566-609aae8acde0 2013-06-27 17:10:02.9908230 System_ClrVersion 4.0.30319.17020
7ca6f023-f945-4052-a566-609aae8acde0 2013-06-27 17:10:03.0028930 Exception System.NotImplementedException: The requested feature is not implemented.\n at Microsoft.VisualBasic.Devices.ComputerInfo.get_TotalPhysicalMemory () [0x00000] in /private/tmp/source/bockbuild-crypto-mono/profiles/mono-mac-xamarin/build-root/mono-mono-basic-6bb2ca6/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.Devices/ComputerInfo.vb:80 \n at issue138StackOverflowExceptiononMono.Tracker.ReportSystemInfo () [0x000a0] in /Users/mrdavidlaing/Projects/fandrei/AppMetrics/samples/issue138-StackOverflowException-on-Mono/issue138-StackOverflowException-on-Mono/SimulatedTracker/Tracker.cs:312
7ca6f023-f945-4052-a566-609aae8acde0 2013-06-27 17:10:03.0029940 Client_WorkingSet 8
7ca6f023-f945-4052-a566-609aae8acde0 2013-06-27 17:10:03.0039930 Client_PrivateMemorySize 10231566338
7ca6f023-f945-4052-a566-609aae8acde0 2013-06-27 17:10:03.0041890 Exception System.NotImplementedException: The requested feature is not implemented.\n at Microsoft.VisualBasic.Devices.ComputerInfo.get_AvailablePhysicalMemory () [0x00000] in /private/tmp/source/bockbuild-crypto-mono/profiles/mono-mac-xamarin/build-root/mono-mono-basic-6bb2ca6/vbruntime/Microsoft.VisualBasic/Microsoft.VisualBasic.Devices/ComputerInfo.vb:42 \n at issue138StackOverflowExceptiononMono.Tracker.ReportPeriodicInfo () [0x00040] in /Users/mrdavidlaing/Projects/fandrei/AppMetrics/samples/issue138-StackOverflowException-on-Mono/issue138-StackOverflowException-on-Mono/SimulatedTracker/Tracker.cs:374
*/
var tracker = Tracker.Create ("http://foo.com", "appKey", "accessKey");

/* No errors when run under Mono */
// var tracker = MonoCompatableTracker.Create ("http://foo.com", "appKey", "accessKey");

var watch = tracker.StartMeasure ();
tracker.EndMeasure (watch, "Dummy event");

watch = tracker.StartMeasure ();
tracker.EndMeasure (watch, "Dummy event 2");


// Note that HttpUtil has been customised to log messages to the console rather than make HttpRequests
tracker.FlushMessages ();

tracker.Dispose ();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Reflection;
using System.Runtime.CompilerServices;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle("issue138-StackOverflowException-on-Mono")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("mrdavidlaing")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("1.0.*")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;

namespace issue138StackOverflowExceptiononMono
{
public static class HttpUtil
{
private const int DefaultTimeout = 100 * 1000;

public static string Request(string url, Dictionary<string, string> args = null, string method = "GET",
int timeout = DefaultTimeout, ICredentials credentials = null)
{
var buf = new StringBuilder();
if (args != null)
{
foreach (var val in args)
{
buf.AppendFormat("{0}={1}&", Uri.EscapeDataString(val.Key), Uri.EscapeDataString(val.Value));
}
}

if (method == "GET" && buf.Length > 0)
{
if (url.Contains("?"))
url += "&";
else
url += "?";
url += buf;
}

// var request = (HttpWebRequest)WebRequest.Create(url);
// request.Method = method;
// request.Timeout = timeout;
// request.ReadWriteTimeout = request.Timeout;
// request.Credentials = credentials;
//
// if (method == "GET")
// {
// request.ContentType = "text/plain; encoding='utf-8'";
// }
// else if (method == "POST")
// {
// request.ContentType = "application/x-www-form-urlencoded; encoding='utf-8'";
//
// using (var stream = request.GetRequestStream())
// {
// using (var writer = new StreamWriter(stream)) // UTF8 without BOM
// {
// writer.Write(buf.ToString());
// }
// }
// }

Console.WriteLine ("{0} {1}", method, url);

if (args != null)
{
foreach (var val in args)
{
Console.WriteLine("\t{0}={1}", val.Key, val.Value);
}
}

// using (var response = request.GetResponse())
// using (var responseStream = response.GetResponseStream())
// using (var reader = new StreamReader(responseStream, Encoding.UTF8))
// {
// return reader.ReadToEnd();
// }
return "OK";
}

public static string Request(string url, ICredentials credentials, Dictionary<string, string> args = null, int timeout = DefaultTimeout)
{
return Request(url, args, "GET", timeout, credentials);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace issue138StackOverflowExceptiononMono
{
class MessageInfo
{
public string Name;
public string Value;
public string SessionId;
public DateTime Time;
public MessagePriority Priority;

public override string ToString()
{
var res = string.Format("[{0} {1}] {2}: {3}", Time, Priority, Name, Value);
return res;
}
}
}
Loading

0 comments on commit 3dc32eb

Please sign in to comment.