Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com From: "Dave Korn" To: Subject: RE: Seg Fault while using /dev/clipboard Date: Fri, 4 Mar 2005 17:14:18 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit In-Reply-To: Message-ID: X-OriginalArrivalTime: 04 Mar 2005 17:14:18.0673 (UTC) FILETIME=[99990210:01C520DD] ----Original Message---- >From: Igor Pechtchanski >Sent: 04 March 2005 16:55 > On Fri, 4 Mar 2005, Pat Kane wrote: >> To duplicate the problem try: cat /dev/clipboard >> first with a text selection and then after using Windows to copy a >> program (right click, copy), or after taking a screen snapshot >> (cntrl-alt-prntScrn). > Ok, I can reproduce this on WinXP Pro SP1. The last few lines of strace > before the exception[*] show a read call that executes normally, and then > a SEGV. Someone with a debug version of Cygwin [...snip!...] Grmbmmgf? Huh? did someone call my name? Here's the results from the .stackdump file: Exception: STATUS_ACCESS_VIOLATION at eip=610AB771 eax=00000000 ebx=00000400 ecx=FFFFFFFF edx=00000000 esi=00000000 edi=00000000 ebp=0022ED60 esp=0022ED5C program=C:\cygwin\bin\cat.exe, pid 4224, thread main cs=001B ds=0023 es=0023 fs=0038 gs=0000 ss=0023 Stack trace: Frame Function Args 0022ED60 610AB771 (00000000, 00000002, 0000000F, 610ABD58) ../../../../../../src/newlib/libc/machine/i386/strlen.S:27 0022EDC0 6101B28F (0022EE78, 00000001, 0022EDF0, 61045C38) /usr/build/obj/i686-pc-cygwin/winsup/cygwin/../../../../src/winsup/cygwin/fh andler_clipboard.cc:228 0022EDF0 61019508 (617E1458, 0022EE78, 00000001, 00000400) /usr/build/obj/i686-pc-cygwin/winsup/cygwin/../../../../src/winsup/cygwin/fh andler.cc:948 0022EE60 6107CC95 (00000003, 0022EE78, 00000001, 6107DF7F) /usr/build/obj/i686-pc-cygwin/winsup/cygwin/../../../../src/winsup/cygwin/cy gheap.h:326 0022EE80 6107CABD (00000003, 0A0501F8, 00000400, 00000000) /usr/build/obj/i686-pc-cygwin/winsup/cygwin/../../../../src/winsup/cygwin/sy scalls.cc:388 0022EEB0 6107348F (00000003, 0A0501F8, 00000400, 2CF91218) ??:0 0022EEE0 00401672 (0A0501F8, 00000400, 0022EFA0, 00402022) ??:0 0022EFA0 0040202E (00000002, 617E2CB8, 0A0500A8, 0022EFF8) ??:0 0022EFE0 610054DD (0022EFF8, 00000000, 00000002, 00000003) /usr/build/obj/i686-pc-cygwin/winsup/cygwin/../../../../src/winsup/cygwin/dc rt0.cc:861 0022FF60 61005603 (00000000, 00000000, 00000000, 00000000) /usr/build/obj/i686-pc-cygwin/winsup/cygwin/../../../../src/winsup/cygwin/dc rt0.cc:916 End of stack trace Hmmph. Calling strlen on a NULL pointer. D'oh! void __stdcall fhandler_dev_clipboard::read (void *ptr, size_t& len) { HGLOBAL hglb; size_t ret; UINT formatlist[2]; UINT format; if (eof) len = 0; else { formatlist[0] = cygnativeformat; formatlist[1] = current_codepage == ansi_cp ? CF_TEXT : CF_OEMTEXT; OpenClipboard (0); if ((format = GetPriorityClipboardFormat (formatlist, 2)) <= 0) { CloseClipboard (); #if 0 system_printf ("a non-accepted format! %d", format); #endif len = 0; } else { hglb = GetClipboardData (format); if (format == cygnativeformat) { unsigned char *buf = (unsigned char *) GlobalLock (hglb); size_t buflen = (*(size_t *) buf); ret = ((len > (buflen - pos)) ? (buflen - pos) : len); memcpy (ptr, buf + sizeof (size_t)+ pos , ret); pos += ret; if (pos + len - ret >= buflen) eof = true; GlobalUnlock (hglb); } else { LPSTR lpstr; lpstr = (LPSTR) GlobalLock (hglb); ret = ((len > (strlen (lpstr) - pos)) ? (strlen (lpstr) - pos) : len); So, GetClipboardData is failing and returning NULL. cheers, DaveK -- Can't think of a witty .sigline today.... -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/