GdkDrop: read_async: munmap_chunk(): invalid pointer -> Crash
Dropping (sth. with the corresponding mime-type), e.g. the URI from the address bar of Chromium, will give the following log and then crash shortly after (signal 6: SIGABRT). Other drops don't give the log, but crash faster (signal 11: SIGSEGV).
munmap_chunk(): invalid pointer
Python test program, equivalent Rust program gives the same problem.
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk, Gdk, GLib
mime = "STRING"
def cb_accept(_target, drop):
formats = drop.get_formats()
if formats is not None:
return formats.contain_mime_type(mime)
return False
def cb_async(drop, task):
try:
value = drop.read_finish(task)
print(value)
except Exception as e:
print(e)
def cb_drop(_target, drop, x, y):
formats = drop.get_formats()
if formats is not None:
if formats.contain_mime_type(mime):
drop.read_async([mime], GLib.PRIORITY_DEFAULT, None, cb_async)
drop.finish(Gdk.DragAction.COPY)
return True
return False
def get_drop_handler():
builder = Gdk.ContentFormatsBuilder()
builder.add_mime_type(mime)
formats = builder.to_formats()
handler = Gtk.DropTargetAsync(formats=formats)
handler.connect('accept', cb_accept)
handler.connect('drop', cb_drop)
return handler
def on_activate(app):
window = Gtk.ApplicationWindow(application=app)
window.set_title("Gtk4 Mime Test")
window.set_default_size(500, 400)
textview = Gtk.TextView()
textview.add_controller(get_drop_handler())
window.set_child(textview)
window.present()
# Create a new application
app = Gtk.Application(application_id='com.example.GtkApplication')
app.connect('activate', on_activate)
# Run the application
app.run(None)
Current behavior
Crash.
Expected outcome
No crash. If the API is used incorrectly, please give a hint in the documentation how to use it correctly.
Version information
Gtk 4.0.3 via Pacman on X11, Arch Linux. Python bindings: Master from https://gitlab.gnome.org/GNOME/pygobject/