GNOME Bugzilla – Bug 508601
Copying from GTK+ applications causes crash
Last modified: 2011-08-01 00:00:08 UTC
Using <a href="http://developer.imendio.com/projects/gtk-macosx/build-instructions">GTK+ Mac OS X</a>, if I try to copy text from a GTK+ application (either by hitting Ctrl-c or clicking Copy), it causes a crash. This is more than 95% reproducible for me, across all GTK+ apps I have tried (both those written in C and PyGTK, if that makes any difference). I'm using GTK+ 2.15.0 on OS X 10.4.11 Intel. I have attached a stack trace here (three backtraces in one file actually: I asked gdb to continue thrice, and the third time it did not crash but the program was working normally again till I quit it normally). Originally <a href="http://developer.imendio.com/node/159">reported here</a>.
Created attachment 102536 [details] backtrace from running gtk+ app and copying Ran with: gdb gtk-demo run bt full continue etc.
Thanks for the report. To summarize the forum thread: I can't reproduce on 10.4.10 ppc or 10.5 intel. I'll try to take a closer look at this.
One question, are you sure it's when you press ctrl-c, and not ctrl-v? Nothing should really happen when copying, only when pasting.
Yes, it's when I copy, not when I paste. Pasting works fine (both Ctrl-v and right-click->paste). Something clearly _is_ happening when I copy; it crashes :) [in gtk_quartz_set_selection or whatever as the trace above says]
BTW it crashes (identically) when I Cut too. Both Cut and Copy are buggy, Paste is not.
Could you please try latest trunk or 2.12 branch from svn? I have still not been able to reproduce your problem, but did some related fixing in that code.
Sorry for the delay... I tried with 2.12.9, and it still crashes in the same way. Is there anything more I can do, like generate another backtrace and attach it?
Also (somewhat unrelated), my applications crash whenever I try to paste Unicode characters into them (some work, but most don't). Should I file a separate bug about this, or is it known already?
It's probably the same bug. What locale are you running in (run "locale" in a terminal and paste the output here), and what exact text are you trying to copy/paste? Also please paste the output from running this in the terminal: defaults read .GlobalPreferences AppleCollationOrder
locale was: ~$ locale LANG= LC_COLLATE="C" LC_CTYPE="C" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL="C" (I tried setting LC_ALL to "en_US" or "en_US.UTF-8" and it didn't help; I can try changing other things if you want.) defaults read .GlobalPreferences AppleCollationOrder says "en"
OK thanks. Just to make sure, can you please also give me exact detailed instructions for how to reproduce this with gtk-demo, including what exact text you are selecting etc? Also, are there any warnings printed in the terminal when you run it?
It does not matter what text I select; it always crashes. (Sometimes it does not crash immediately, but crashes when I next interact with it, like type some text etc.) Copying from the Source tab seems to more reliably crash it than from the Info tab, somewhat. In the terminal I see: 2008-04-12 09:13:08.484 gtk-demo[1122] An uncaught exception was raised 2008-04-12 09:13:08.484 gtk-demo[1122] *** -[NSConcreteData initWithBytes:length:copy:freeWhenDone:bytesAreVM:]: absurd length: -1, maximum size: -2147483648 bytes 2008-04-12 09:13:08.484 gtk-demo[1122] *** Uncaught exception: <NSInvalidArgumentException> *** -[NSConcreteData initWithBytes:length:copy:freeWhenDone:bytesAreVM:]: absurd length: -1, maximum size: -2147483648 bytes zsh: trace trap /opt/local/bin/gtk-demo [Last line is "Trace/BPT trap" if I run it from Bash, just to make sure it's not a Zsh-specific problem.]
OK, thanks. Could you also run otool -L /path/to/your/prefix/bin/gtk-demo and paste the output here? Are you sure you don't have any old/other installation somewhere of gtk+ that could interfere? Like mono or a macports build of gtk?
I don't have any other installation. But um.. this is a macports build of gtk. The problem, stack trace, error message in the terminal etc. are identical to what building gtk+ myself were giving me (when I filed this bug), so I hope it is not important (if not, I can uninstall the macports gtk and install according to the official build instructions...) otool -L gives: otool -L /opt/local/bin/gtk-demo /opt/local/bin/gtk-demo: /opt/local/lib/libgdk_pixbuf-2.0.0.dylib (compatibility version 1201.0.0, current version 1201.9.0) /opt/local/lib/libgdk-quartz-2.0.0.dylib (compatibility version 1201.0.0, current version 1201.9.0) /opt/local/lib/libgtk-quartz-2.0.0.dylib (compatibility version 1201.0.0, current version 1201.9.0) /opt/local/lib/libpangocairo-1.0.0.dylib (compatibility version 1801.0.0, current version 1801.4.0) /opt/local/lib/libpangoft2-1.0.0.dylib (compatibility version 1801.0.0, current version 1801.4.0) /opt/local/lib/libpango-1.0.0.dylib (compatibility version 1801.0.0, current version 1801.4.0) /opt/local/lib/libatk-1.0.0.dylib (compatibility version 2010.0.0, current version 2010.1.0) /opt/local/lib/libgobject-2.0.0.dylib (compatibility version 1401.0.0, current version 1401.6.0) /opt/local/lib/libgmodule-2.0.0.dylib (compatibility version 1401.0.0, current version 1401.6.0) /opt/local/lib/libglib-2.0.0.dylib (compatibility version 1401.0.0, current version 1401.6.0) /opt/local/lib/libcairo.2.dylib (compatibility version 14.0.0, current version 14.7.0) /opt/local/lib/libfontconfig.1.dylib (compatibility version 5.0.0, current version 5.0.0) /opt/local/lib/libfreetype.6.dylib (compatibility version 10.0.0, current version 10.16.0) /opt/local/lib/libexpat.1.dylib (compatibility version 7.0.0, current version 7.2.0) /opt/local/lib/libtiff.3.dylib (compatibility version 12.0.0, current version 12.2.0) /opt/local/lib/libjpeg.62.dylib (compatibility version 63.0.0, current version 63.0.0) /opt/local/lib/libpng12.0.dylib (compatibility version 25.0.0, current version 25.0.0) /opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.10) /opt/local/lib/libintl.8.dylib (compatibility version 9.0.0, current version 9.2.0) /opt/local/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
Hm, I wonder if there is a problem caused by the iconv version in macports... I don't know why they include that since the system comes with iconv. I will try to run with macports version, if I get some time to see if that causes any issues.
(In reply to comment #14) > But um.. this is a macports build of gtk. I am trying to install gtk+ quartz with macports but I can only manage to get the x11 version built... how do I get the right version installed? I did ports install gtk2 +quartz but that still pulled in X11.
Oh, was this recently? I thought this was fixed. Does "port install gtk2 +quartz +no_x11" work?
Ah, that worked, thanks. I don't get any crashes though (seems like the macport is broken btw, fonts are not working).
Yes, it's broken now. Stupid MacPorts. And I upgraded to Leopard now, so I might not be able to reproduce it either... I'll report back here when I've got everything working.
I couldn't reproduce with a macports build either.
Once 2.14.4 is released, it would be good if someone that sees this crash could retest (bug #554141 might have helped).
I just tried this again, and it seems to mostly crash no longer. Quicksilver has a clipboard history module. If I have it turned on, copying from applications frequently crashes (with the same "*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSConcreteData initWithBytes:length:copy:freeWhenDone:bytesAreVM:]: absurd length: -1, maximum size: -2147483648 bytes'" message.) If I turn it off, it seems hard or impossible to produce a crash. So I don't know if this is a bug in Quicksilver or GTK.
I have the same issue when I use set_with_data function but not if I use set_text on clipboard.
We are seeing this in MonoDevelop too. It seems to be caused by an application called Launchbar. https://bugzilla.novell.com/show_bug.cgi?id=533560
I seem to be having the same issue. My crash only occurs with GtkTextView not GtkEntry. Using the clipboard browser "Clipboard Viewer" included with X Code reveals that the two widgets offer different targets. Requesting STRING, TEXT, or COMPOUND_TEXT causes GTK+ 2.18.2 to crash. However GTK+ 2.20.1 handles the situation gracefully.
This is caused by the clipboard utilities requesting all of the available clipboard target types from the app. The COMPOUND_TEXT, TEXT and STRING types crash when requested, but they're not actually useful on Mac anyway, so they should be removed.
Fixed on master: http://git.gnome.org/browse/gtk+/commit/?id=8d69f3daf258c03e3b8d839cacc15a7b4d12e64d
And backported to gtk-2-24: 875e6f4bdbb8f4ee02fff11febbdca425ff915b0