Bug 58613 - Mono Crashes the app When using Bitmap class to wrap SOME kind of PNG Files
Summary: Mono Crashes the app When using Bitmap class to wrap SOME kind of PNG Files
Status: CONFIRMED
Alias: None
Product: Class Libraries
Classification: Mono
Component: libgdiplus ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-08-07 12:50 UTC by Assem Radaideh
Modified: 2017-09-11 13:29 UTC (History)
3 users (show)

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


Attachments
PNG sample file that when wrapped by Bitmap class, the app crashes (251 bytes, image/png)
2017-08-07 12:50 UTC, Assem Radaideh
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 58613 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:
CONFIRMED

Description Assem Radaideh 2017-08-07 12:50:07 UTC
Created attachment 24057 [details]
PNG sample file that when wrapped by Bitmap class, the app crashes

Using Bitmap class crashes the app on SOME kind of png files!

This occurs since I've first used Mono starting from version 2.8 and up to the current 5.4
 

To produce it please use the Attached sample image with the code below.

The minimal app to produce this bug :




using System;
using System.Drawing;

namespace TestMonoMacBitmapCrash
{
    class MainClass
    {
        public static void Main(string[] args)
        {
           Bitmap bmp = new Bitmap("/Users/Assem/Desktop/bitmap_crash.png");
        }
    }
}





Running such an app (with the path to the bitmap in attachment) produces the following:




Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Drawing.GDIPlus.GdipCreateBitmapFromFile (string,intptr&) <0x00012>
  at System.Drawing.Bitmap..ctor (string,bool) [0x00022] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/System.Drawing/System.Drawing/Bitmap.cs:125
  at System.Drawing.Bitmap..ctor (string) [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/System.Drawing/System.Drawing/Bitmap.cs:104
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap..ctor (string) [0x0001a] in <d7b987a45b324e2aa8612eb1c38b0599>:0
  at TestDotNetBitmapCrash.MainClass.Main (string[]) [0x0000c] in /Users/Assem/Projects/TestMonoMacBitmapCrash/TestMonoMacBitmapCrash/Program.cs:11
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) [0x00051] in <79dcae69ae9e4d699e3d5ef93d8e353d>:0

Native stacktrace:


Debug info from gdb:

(lldb) command source -s 0 '/tmp/mono-gdb-commands.Z03i1w'
Executing commands in '/tmp/mono-gdb-commands.Z03i1w'.
(lldb) process attach --pid 22463
Process 22463 stopped
* thread #1, name = 'tid_403', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0xa1659c4a libsystem_kernel.dylib`__wait4 + 10
libsystem_kernel.dylib`__wait4:
->  0xa1659c4a <+10>: jae    0xa1659c5a                ; <+26>
    0xa1659c4c <+12>: calll  0xa1659c51                ; <+17>
    0xa1659c51 <+17>: popl   %edx
    0xa1659c52 <+18>: movl   0x58d53d7(%edx), %edx

Executable module set to "/Library/Frameworks/Mono.framework/Versions/5.4.0/bin/mono32".
Architecture set to: i386-apple-macosx.
(lldb) thread list
Process 22463 stopped
* thread #1: tid = 0xd50469, 0xa1659c4a libsystem_kernel.dylib`__wait4 + 10, name = 'tid_403', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  thread #2: tid = 0xd5046b, 0xa165930e libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
  thread #3: tid = 0xd5046c, 0xa165930e libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
  thread #4: tid = 0xd5046d, 0xa165195a libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
  thread #5: tid = 0xd50470, 0xa1659cba libsystem_kernel.dylib`__workq_kernreturn + 10
(lldb) thread backtrace all
* thread #1, name = 'tid_403', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0xa1659c4a libsystem_kernel.dylib`__wait4 + 10
    frame #1: 0xa15d82ef libsystem_c.dylib`waitpid$UNIX2003 + 32
    frame #2: 0x000f69dc mono32`mono_handle_native_crash + 492
    frame #3: 0x00159a55 mono32`mono_arch_handle_altstack_exception + 181
    frame #4: 0x0003d2d4 mono32`mono_sigsegv_signal_handler + 468

  thread #2, name = 'SGen worker'
    frame #0: 0xa165930e libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0xa173deb0 libsystem_pthread.dylib`_pthread_cond_wait + 647
    frame #2: 0xa173f844 libsystem_pthread.dylib`pthread_cond_wait$UNIX2003 + 51
    frame #3: 0x002d1de9 mono32`thread_func + 697
    frame #4: 0xa173d047 libsystem_pthread.dylib`_pthread_body + 184
    frame #5: 0xa173cf8f libsystem_pthread.dylib`_pthread_start + 243
    frame #6: 0xa173c84a libsystem_pthread.dylib`thread_start + 34

  thread #3, name = 'SGen worker'
    frame #0: 0xa165930e libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0xa173deb0 libsystem_pthread.dylib`_pthread_cond_wait + 647
    frame #2: 0xa173f844 libsystem_pthread.dylib`pthread_cond_wait$UNIX2003 + 51
    frame #3: 0x002d1dc8 mono32`thread_func + 664
    frame #4: 0xa173d047 libsystem_pthread.dylib`_pthread_body + 184
    frame #5: 0xa173cf8f libsystem_pthread.dylib`_pthread_start + 243
    frame #6: 0xa173c84a libsystem_pthread.dylib`thread_start + 34

  thread #4, name = 'Finalizer'
    frame #0: 0xa165195a libsystem_kernel.dylib`semaphore_wait_trap + 10
    frame #1: 0x0024e123 mono32`finalizer_thread + 275
    frame #2: 0x0021dc8d mono32`start_wrapper + 765
    frame #3: 0xa173d047 libsystem_pthread.dylib`_pthread_body + 184
    frame #4: 0xa173cf8f libsystem_pthread.dylib`_pthread_start + 243
    frame #5: 0xa173c84a libsystem_pthread.dylib`thread_start + 34

  thread #5
    frame #0: 0xa1659cba libsystem_kernel.dylib`__workq_kernreturn + 10
    frame #1: 0xa173cb95 libsystem_pthread.dylib`_pthread_wqthread + 841
    frame #2: 0xa173c826 libsystem_pthread.dylib`start_wqthread + 34
(lldb) detach

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Process 22463 detached
(lldb) quit