Bug 58567 - C# + Mono (4.2.1) + Ubuntu (16.04) = Objects becoming null
Summary: C# + Mono (4.2.1) + Ubuntu (16.04) = Objects becoming null
Status: NEW
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: 4.2.1 (C6SR0)
Hardware: Other Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-08-03 11:22 UTC by Gilad Rave
Modified: 2017-08-03 11:22 UTC (History)
2 users (show)

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

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 for Bug 58567 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Gilad Rave 2017-08-03 11:22:53 UTC
DISCLAIMER: Unfortunately, I cannot provide a simple test case of the issue, or a guaranteed way to reproduce.
D#2: Wasn't sure about which component to select for this bug.

So I have a C# application (single process with a few threads), which I'm running with Mono on a Linux VM (Azure/AWS).

Every once in a while some variable which couldn't possibly be null causes some null value exception. Examples:

* "Value cannot be null. Parameter name: source" on `var lst = JObject["list"].Select(x => x["key"].ToString());`

* "Specified cast is not valid." on the `Regex.Replace(Regex.Replace(txt, @"[^a-z ]", "", RegexOptions.IgnoreCase).ToLower(), @"  +", " ").Trim();`

This happens in various other places in the application.

Additionally, certain threads communicate via the disk, where one thread writes a Json to a file, and another thread reads it (the Json processing is done with the Newtonsoft package). And sometimes the Json received is invalid, and looks something like:

   { ... valid Json ... } extra characters which seem to be taken from an earlier message making the json invalid }

The above behavior leads me to believe that some sort of memory corruption is taking place. I cannot explain why or how it occurs, and certainly not how to prevent it.

Two things to note:

* The application never runs into these problems when executed on my Windows laptop.

* The Linux VM has relatively low memory (~0.7 GB RAM), but the app usually takes only about a third/half of that.