[Mono-bugs] [Bug 588228] New: System.Drawing.Graphics.CopyFromScreenX11 crash on 64 bit
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Sun Mar 14 14:06:30 EDT 2010
http://bugzilla.novell.com/show_bug.cgi?id=588228
http://bugzilla.novell.com/show_bug.cgi?id=588228#c0
Summary: System.Drawing.Graphics.CopyFromScreenX11 crash on 64
bit
Classification: Mono
Product: Mono: Class Libraries
Version: 2.6.x
Platform: x86-64
OS/Version: Ubuntu
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Sys.Drawing.
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: mdfederici at yahoo.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/532.9
(KHTML, like Gecko) Chrome/5.0.307.11 Safari/532.9
I originally thought that this bug was Bug
521718(https://bugzilla.novell.com/show_bug.cgi?id=521718). However, I have
verified that my mono 2.6.1 has the fixes described in that bug. I'm using
Ubuntu 9.10 64 bit and I'm trying to take a screen capture.
The actual problem seems to be coming from System.Graphics line 247:
image = GDIPlus.XGetImage (GDIPlus.Display, window, sourceX, sourceY,
blockRegionSize.Width,
blockRegionSize.Height, AllPlanes, 2 /* ZPixmap*/);
which invokes XGetImage from GDI Plus. I'm inclined to think that maybe the
'format' parameter( 2 /*ZPixmap*/) might be the problem.
Here is the actual stacktrace and code to reproduce(below):
X11 Error encountered:
Error: BadMatch (invalid parameter attributes)
Request: 73 (0)
Resource ID: 0x101
Serial: 92
Hwnd: Hwnd, Mapped:False ClientWindow:0x101, WholeWindow:0x101,
Zombie=False, Parent:[<null>]
Control: <handle 101 non-existant> at
System.Environment.get_StackTrace() in
/home/michael/Desktop/mono-2.6.1/mcs/class/corlib/System/Environment.cs:line
202
at System.Windows.Forms.XplatUIX11.HandleError(IntPtr display, XErrorEvent
ByRef error_event) in
/home/michael/Desktop/mono-2.6.1/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs:line
2035
at System.Drawing.GDIPlus.XGetImage(IntPtr , IntPtr , Int32 , Int32 , Int32
, Int32 , Int32 , Int32 )
at System.Drawing.Graphics.CopyFromScreenX11(Int32 sourceX, Int32 sourceY,
Int32 destinationX, Int32 destinationY, Size blockRegionSize,
CopyPixelOperation copyPixelOperation) in
/home/michael/Desktop/mono-2.6.1/mcs/class/System.Drawing/System.Drawing/Graphics.cs:line
247
at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY,
Int32 destinationX, Int32 destinationY, Size blockRegionSize,
CopyPixelOperation copyPixelOperation) in
/home/michael/Desktop/mono-2.6.1/mcs/class/System.Drawing/System.Drawing/Graphics.cs:line
190
at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY,
Int32 destinationX, Int32 destinationY, Size blockRegionSize) in
/home/michael/Desktop/mono-2.6.1/mcs/class/System.Drawing/System.Drawing/Graphics.cs:line
179
at Transparent.MainClass.recaptureScreen() in
/home/michael/workspace-mono/CodeBase/transparent/Main.cs:line 25
at Transparent.MainClass.Main(System.String[] args) in
/home/michael/workspace-mono/CodeBase/transparent/Main.cs:line 17
Stacktrace:
at (wrapper managed-to-native) System.Drawing.GDIPlus.XGetPixel
(intptr,int,int) <IL 0x00013, 0x00062>
at (wrapper managed-to-native) System.Drawing.GDIPlus.XGetPixel
(intptr,int,int) <IL 0x00013, 0x00062>
at System.Drawing.Graphics.CopyFromScreenX11
(int,int,int,int,System.Drawing.Size,System.Drawing.CopyPixelOperation)
[0x00102] in
/home/michael/Desktop/mono-2.6.1/mcs/class/System.Drawing/System.Drawing/Graphics.cs:257
at System.Drawing.Graphics.CopyFromScreen
(int,int,int,int,System.Drawing.Size,System.Drawing.CopyPixelOperation)
[0x00045] in
/home/michael/Desktop/mono-2.6.1/mcs/class/System.Drawing/System.Drawing/Graphics.cs:190
at System.Drawing.Graphics.CopyFromScreen
(int,int,int,int,System.Drawing.Size) [0x00000] in
/home/michael/Desktop/mono-2.6.1/mcs/class/System.Drawing/System.Drawing/Graphics.cs:179
at (wrapper remoting-invoke-with-check)
System.Drawing.Graphics.CopyFromScreen (int,int,int,int,System.Drawing.Size)
<IL 0x00039, 0x000bf>
at Transparent.MainClass.recaptureScreen () [0x00036] in
/home/michael/workspace-mono/CodeBase/transparent/Main.cs:25
at Transparent.MainClass.Main (string[]) [0x00000] in
/home/michael/workspace-mono/CodeBase/transparent/Main.cs:17
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object
(object,intptr,intptr,intptr) <IL 0x0001d, 0x00054>
Native stacktrace:
/opt/mono/bin/mono [0x4863f1]
/opt/mono/bin/mono [0x4d19ff]
/lib/libpthread.so.0 [0x7f92187f0190]
/usr/lib/libX11.so.6(XGetPixel+0) [0x7f9215b1f130]
[0x409267e2]
Debug info from gdb:
Mono support loaded.
[Thread debugging using libthread_db enabled]
[New Thread 0x7f92167da910 (LWP 3647)]
[New Thread 0x7f9219351910 (LWP 3646)]
[New Thread 0x7f9217fbf910 (LWP 3645)]
0x00007f92187ef0cb in read () from /lib/libpthread.so.0
4 Thread 0x7f9217fbf910 (LWP 3645) 0x00007f92187ec5a9 in
pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
3 Thread 0x7f9219351910 (LWP 3646) 0x00007f92187ef8f1 in nanosleep ()
from /lib/libpthread.so.0
2 Thread 0x7f92167da910 (LWP 3647) 0x00007f92187ee3c1 in sem_wait ()
from /lib/libpthread.so.0
* 1 Thread 0x7f92194c5730 (LWP 3643) 0x00007f92187ef0cb in read ()
from /lib/libpthread.so.0
Thread 4 (Thread 0x7f9217fbf910 (LWP 3645)):
#0 0x00007f92187ec5a9 in pthread_cond_wait@@GLIBC_2.3.2 ()
from /lib/libpthread.so.0
#1 0x00000000005c4ab8 in GC_wait_marker () at pthread_support.c:1785
#2 0x00000000005b5317 in GC_help_marker (my_mark_no=8) at mark.c:1116
#3 0x00000000005c36f4 in GC_mark_thread (id=0x0) at pthread_support.c:548
#4 0x00007f92187e7a04 in start_thread () from /lib/libpthread.so.0
#5 0x00007f92182cd80d in clone () from /lib/libc.so.6
#6 0x0000000000000000 in ?? ()
Thread 3 (Thread 0x7f9219351910 (LWP 3646)):
#0 0x00007f92187ef8f1 in nanosleep () from /lib/libpthread.so.0
#1 0x00000000005a3c12 in collection_thread (unused=<value optimized out>)
at collection.c:34
#2 0x00007f92187e7a04 in start_thread () from /lib/libpthread.so.0
#3 0x00007f92182cd80d in clone () from /lib/libc.so.6
#4 0x0000000000000000 in ?? ()
Thread 2 (Thread 0x7f92167da910 (LWP 3647)):
#0 0x00007f92187ee3c1 in sem_wait () from /lib/libpthread.so.0
#1 0x0000000000504300 in finalizer_thread (unused=<value optimized out>)
at gc.c:1022
#2 0x0000000000525255 in start_wrapper (data=<value optimized out>)
at threads.c:662
#3 0x000000000059a923 in thread_start_routine (args=0x10175e8)
at wthreads.c:286
#4 0x00000000005c471b in GC_start_routine (arg=0x7f921937ee70)
at pthread_support.c:1390
#5 0x00007f92187e7a04 in start_thread () from /lib/libpthread.so.0
#6 0x00007f92182cd80d in clone () from /lib/libc.so.6
#7 0x0000000000000000 in ?? ()
Thread 1 (Thread 0x7f92194c5730 (LWP 3643)):
#0 0x00007f92187ef0cb in read () from /lib/libpthread.so.0
#1 0x0000000000486569 in read (signal=<value optimized out>,
ctx=<value optimized out>) at /usr/include/bits/unistd.h:45
#2 mono_handle_native_sigsegv (signal=<value optimized out>,
ctx=<value optimized out>) at mini-exceptions.c:1809
#3 0x00000000004d19ff in mono_arch_handle_altstack_exception (sigctx=
0x7f92194cebc0, fault_addr=<value optimized out>, stack_ovf=0)
at exceptions-amd64.c:879
#4 <signal handler called>
#5 0x00007f9215b1f130 in XGetPixel () from /usr/lib/libX11.so.6
#6 0x00000000409267e2 in ?? ()
#7 0x0000000000fdc6d0 in ?? ()
#8 0x0000000000000000 in ?? ()
=================================================================
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.
=================================================================
The application was terminated by a signal: SIGABRT
And the code to run:
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Imaging;
namespace Transparent
{
class MainClass
{
public static void Main (string[] args)
{
Bitmap myCapture = MainClass.recaptureScreen();
}
public static Bitmap recaptureScreen()
{
Bitmap bmpScreenshot = new
Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height,
PixelFormat.Format32bppArgb);
Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(0, 0, 0, 0, new Size(
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height));
bmpScreenshot.Save("screenie.png", ImageFormat.Png);
gfxScreenshot.Dispose();
return bmpScreenshot;
}
}
}
Changing the pixel format doesn't seem to have any affect on the outcome.
Reproducible: Always
Steps to Reproduce:
1. Start a new mono 2.6.x console project and paste the given code. Add
dependencies.
2. Execute.
Actual Results:
An X11 error.
Expected Results:
I would expect the bitmap object to be populated with a screenshot.
I really need to be able to take a screenshot. It would be great if someone
could help me write a patch. Please let me know if you require more info or
help.
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list