Bug 17411 - SIGSEGV with font creation & disposing in multiple threads
Summary: SIGSEGV with font creation & disposing in multiple threads
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Drawing ()
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-01-24 04:54 UTC by Russell van der Walt
Modified: 2014-02-12 21:40 UTC (History)
3 users (show)

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


Attachments
Simple program to reproduce the issue (1.17 KB, text/plain)
2014-01-24 04:54 UTC, Russell van der Walt
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 17411 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 Russell van der Walt 2014-01-24 04:54:19 UTC
Created attachment 5909 [details]
Simple program to reproduce the issue

We're experiencing the following SIGSEGV's when creating fonts in multiple threads:

Stacktrace:
Native stacktrace:

        mono() [0x4ab6ed]
        mono() [0x501cef]
        mono() [0x420367]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0) [0x7f38ec478cb0]
        /usr/lib/x86_64-linux-gnu/libfontconfig.so.1(FcCharSetDestroy+0x4) [0x7f38db7402a4]
        /usr/lib/x86_64-linux-gnu/libfontconfig.so.1(+0x18599) [0x7f38db74d599]
        /usr/lib/x86_64-linux-gnu/libfontconfig.so.1(FcPatternDestroy+0x7f) [0x7f38db74d88f]
        /usr/local/lib/libgdiplus.so(GdipDeleteFontFamily+0x118) [0x7f38e8e74848]
        /usr/local/lib/libgdiplus.so(GdipDeleteFont+0x1c) [0x7f38e8e7523c]
        [0x41f78fdb]

Debug info from gdb:
=================================================================
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.
=================================================================

Sometimes we get the following:

*** glibc detected *** mono: double free or corruption (fasttop): 0x00007f35e8003050 ***
Stacktrace:
Native stacktrace:

The error is caused by simply creating and disposing fonts in multiple threads with similar code to this (see attachment for full program):

using (var fFamily = new FontFamily("Arial")) {
    using (var f = new Font(fFamily, 10, FontStyle.Regular)) {

    }
}

I have not been able to reproduce the error on 32bit architectures.

OS is Ubuntu 12.04 

root@ubuntu12043:~/test# mono -V
Mono JIT compiler version 3.2.3 (tarball Fri Jan 24 00:12:45 SAST 2014)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen

I've confirmed the problem is also present in mono 2.10.9.
Comment 1 Zoltan Varga 2014-01-24 15:25:18 UTC
-> sys.drawing
Comment 2 Miguel de Icaza [MSFT] 2014-02-12 21:40:19 UTC
We likely did not add locking around the underlying primitives for some of the APIs in System.Drawing, will require a review.