Re: [Mono-winforms-list] Is System.Drawing (libgdiplus) thread-safe?

Alex Shulgin <[email protected]>
Newsgroups gmane.comp.gnome.mono.devel,gmane.comp.gnome.winforms
Message-ID <[email protected]>
Sebastien Pouliot wrote:
> 
> Please open a bug report on bugzilla.novell.com and attach your test
> case.

https://bugzilla.novell.com/show_bug.cgi?id=551009

>> On my Linux box it crashes all the time.  I get a wide variety of errors 
>> from gdb stacktraces with SIGSEGV or SIGABRT in the end, to SIGILL with 
>> .Net stack trace.
>>
>> Uncommenting these lock {} lines in the ThreadProc helps, but not an 
>> option for my real app, as there's simply no single place a lock could 
>> be added.
>>
>> I've also tried writing some code in plain C which links to libgdiplus 
>> directly: see `threads-gdiplus.c'.  It happily crashes just like the C# 
>> version.
> 
> Most of System.Drawing is only a small wrapper abound libgdiplus (or GDI
> + under Windows). Any bug will likely be inside libgdiplus so it's
> "normal" (i.e. expected) that you get the same behavior.

Yes, it's what I expected.  Just thought it might be helpful in 
debugging the problem.  Attached this to the bug too.

>> My tests show that even using unsynchronized GdipGetImageGraphicsContext 
>> / GdipDeleteGraphics (no fonts stuff touched) can easily lead to crashes.
>>
>>  From what I've seen, cairo seems to be thread-safe: see attached[1] 
>> `cairo-multi-thread-text.c'.
> 
> It's thread-safe as long as everything is created and executed in the
> same thread. Otherwise it would not be safe-thread (just like .net and
> most libraries are).

This is actually what I meant by thread-safe here. :)

I'd expect any library not to crash under similar circumstances as long 
as it doesn't use global variables or, if so, does ensure proper locking 
around them.

--
Regards,
Alex
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.