Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin-rescue block results in a double free or corruption error with Gdk::Texture #77

Open
BigBoyBarney opened this issue Dec 27, 2024 · 0 comments

Comments

@BigBoyBarney
Copy link

This is a follow-up issue from #74, possibly related.

The following code crashes with the error if GC.collect is run.

double free or corruption (fasttop)                 
Program received and didn't handle signal ABRT (6)
class MainWindow < Adw::ApplicationWindow
  def initialize(application : Adw::Application)
    super(application: application)
    KEEP_ALIVE << self

    begin
      texture = Gdk::Texture.new_from_filename("")
    rescue
    end

    button = Gtk::Button.new(label: "GC collect")

    button.clicked_signal.connect do
      GLib.idle_add do
        GC.collect
        false
      end
    end

    self.content = button
  end
end

The path to the file used for Gdk::Texture does not matter, as long as it doesn't exist. Without the begin block, the app exits with a GLib::Error and an invalid memory access even without running GC.collect.

Unhandled exception: Operation not supported (GLib::Error)
Invalid memory access (signal 11) at address 0x0

Notice how texture doesn't have to be called at all. Replacing the begin-rescue block with a File.exists? check goes around the issue.

Another interesting thing is that

Gtk::Picture.new_for_filename("")

does not suffer from the same issue.

@BigBoyBarney BigBoyBarney changed the title Begin-rescue block results in a double free or corruption error with Gdk::Texture Begin-rescue block results in a double free or corruption error with Gdk::Texture Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant