Bug 27344 - Simple Winforms program throws exception on ARM but not on AMD64
Summary: Simple Winforms program throws exception on ARM but not on AMD64
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: libgdiplus ()
Version: 3.12.0
Hardware: Other Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-02-24 05:35 UTC by Rob
Modified: 2017-09-01 11:40 UTC (History)
3 users (show)

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


Attachments
Sample VS2013 project that produces the error (126.08 KB, application/octet-stream)
2015-02-26 05:19 UTC, Rob
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 for Bug 27344 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:
Status:
NEW

Description Rob 2015-02-24 05:35:43 UTC
I compiled Mono 3.12.0 from source, once for an armv7 BeagleBone Black, and once for an Ubuntu AMD64 system. I used the BBB toolchain and scratchbox2 for cross-compiling. As far as I can tell, everything worked quite well. Mono-test-install tells me that I have a working environment on both systems.

I created a very basic Winforms application with only a button and a messagebox with VS2013 (.NET Version 4.5, but also 3.5 in another test), compiled it to a (release) EXE and put it on the Ubuntu system as well as on the BBB.

I can successfully run the program on the Ubuntu system (after installing the needed libs libX11 and libgdiplus, which I also installed accordingly on the BBB), but on the BBB it crashes with this exception:

-------------------------------------------------------------------------------------
Unhandled Exception:
System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelFormat format) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Int32 width, Int32 height) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Size newSize) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (System.Drawing.Image,System.Drawing.Size)
  at System.Windows.Forms.XplatUIX11.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUI.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Cursor.CreateCursor (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Cursor..ctor (System.Type type, System.String resource) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Cursors.get_SizeNWSE () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.SizeGrip..ctor (System.Windows.Forms.Control CapturedControl) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.SizeGrip:.ctor (System.Windows.Forms.Control)
  at System.Windows.Forms.ScrollableControl.CreateScrollbars () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0 
  at guitest.Form1..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) guitest.Form1:.ctor ()
  at guitest.Program.Main () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelFormat format) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Int32 width, Int32 height) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Size newSize) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (System.Drawing.Image,System.Drawing.Size)
  at System.Windows.Forms.XplatUIX11.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUI.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Cursor.CreateCursor (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Cursor..ctor (System.Type type, System.String resource) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Cursors.get_SizeNWSE () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.SizeGrip..ctor (System.Windows.Forms.Control CapturedControl) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.SizeGrip:.ctor (System.Windows.Forms.Control)
  at System.Windows.Forms.ScrollableControl.CreateScrollbars () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0 
  at guitest.Form1..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) guitest.Form1:.ctor ()
  at guitest.Program.Main () [0x00000] in <filename unknown>:0
-------------------------------------------------------------------------------------

I then created a little console application with VS2013 and tested again, it ran on the Ubuntu system as well as on the BBB, so I think the mono version on the BBB is basically working.

After some searching I noticed that people had similar issues with the "newer" versions of mono, so I also tried installing an older version via the BBB's Angstrom opkg package manager (which was version 2.11). Again, the console program worked, the Winforms application didn't.

I also tried compiling the program not with VS but with xbuild instead, but it does not make a difference, it gives me the same error.
Comment 1 Rob 2015-02-26 05:19:47 UTC
Created attachment 10046 [details]
Sample VS2013 project that produces the error

This is the program I tried to compile and run on the BeagleBone Black.
Comment 2 Andy Baxman 2017-06-02 10:52:58 UTC
Seeing exactly the same problem occurring on an Odroid XU4 running Ubuntu 16.04.02 and Mono 5.0.0.

Main application:

using System;
using System.Windows.Forms;

namespace FormsTestApp
{
    class MainClass
    {
        [STAThread]
        public static void Main(string[] args)
        {
            Application.Run(new MainForm());
        }
    }
}

UI:

using System;
using System.Windows.Forms;

namespace FormsTestApp
{
    public class MainForm:Form
    {
        public MainForm(){}
    }
}

On running I get an identical Exception and Stack Trace as Rob (OP).

This *ONLY* occurs when the application is running on the native screen (an Odroid V7 screen (1024x600) connected via HDMI. The error does *not* occur when run on a remote desktop (XRDP) to the device.