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

[gtk3] Paste text into Entry buffer causes Segmentation fault #13258

Closed
2 of 7 tasks
PetStr opened this issue Sep 24, 2022 · 10 comments · Fixed by #13269
Closed
2 of 7 tasks

[gtk3] Paste text into Entry buffer causes Segmentation fault #13258

PetStr opened this issue Sep 24, 2022 · 10 comments · Fixed by #13269
Labels

Comments

@PetStr
Copy link

PetStr commented Sep 24, 2022

Description

Originally I have issue with a gtkmm application that seg faults when anything is pasted into Gtk::Entry. I was looking around trying to find the issue. Issue came up after a resent upgrade.

Now I am able to get seg fault if I run gtk3-demo, Open Entry Buffer and paste into the widget. Every 3-4 tries will cause a segmentation fault. I assume this is the same fault as in my gtkmm applications.

I don't get anything from debugger. So fault seems to come from inside the kit. I am still humble to suspect that I made some mistake and relying on undefined behavior.

Verification

Windows Version

Microsoft Windows [Version 10.0.19044.2006]

MINGW environments affected

  • MINGW64
  • MINGW32
  • UCRT64
  • CLANG64
  • CLANG32
  • CLANGARM64

Expected behavior

No seg fault.

Actual behavior

Application crashes with segfault. from libglib2

Repro steps

  1. Launch gtk3-demo
  2. Open Entry
  3. Run Entry Buffer
  4. ctrl-V anything into the text-window.
  5. application exit

$ gtk3-demo
Segmentation fault

Are you willing to submit a PR?

Not right now.

@PetStr PetStr added the bug label Sep 24, 2022
@Biswa96
Copy link
Member

Biswa96 commented Sep 24, 2022

Where can I find the gtk3-demo code?

@PetStr
Copy link
Author

PetStr commented Sep 24, 2022

It is part of the gtk3 package. if you have gtk3 installed just type "gtk3-demo"

$ pacman -Qo gtk3-demo.exe
/mingw64/bin/gtk3-demo.exe is owned by mingw-w64-x86_64-gtk3 3.24.34+87+g8bbc24c165-3

Crashing gtk-demo in gdb Get me this info.

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ffb85fc8fa7 in ?? () from C:\msys64\mingw64\bin\libglib-2.0-0.dll

(gdb) bt
#0  0x00007ffb85fc8fa7 in ?? () from C:\msys64\mingw64\bin\libglib-2.0-0.dll
#1  0x00007ffb70ba86ad in ?? () from C:\msys64\mingw64\bin\libgdk-3-0.dll
#2  0x00007ffb70ba9b75 in ?? () from C:\msys64\mingw64\bin\libgdk-3-0.dll
#3  0x00007ffb70b6bbf7 in ?? () from C:\msys64\mingw64\bin\libgdk-3-0.dll
#4  0x00007ffb66b3705b in ?? () from C:\msys64\mingw64\bin\libgtk-3-0.dll
#5  0x00007ffb66c24414 in ?? () from C:\msys64\mingw64\bin\libgtk-3-0.dll
#6  0x00007ffb66956bed in ?? () from C:\msys64\mingw64\bin\libgtk-3-0.dll
#7  0x00007ffb9eb37e74 in ?? () from C:\msys64\mingw64\bin\libgobject-2.0-0.dll
#8  0x00007ffb9eb50d21 in ?? () from C:\msys64\mingw64\bin\libgobject-2.0-0.dll
#9  0x00007ffb9eb51004 in ?? () from C:\msys64\mingw64\bin\libgobject-2.0-0.dll
#10 0x00007ffb66b39086 in ?? () from C:\msys64\mingw64\bin\libgtk-3-0.dll
#11 0x00007ffb66952d03 in ?? () from C:\msys64\mingw64\bin\libgtk-3-0.dll
#12 0x00007ffb9eb37e74 in ?? () from C:\msys64\mingw64\bin\libgobject-2.0-0.dll
#13 0x00007ffb9eb503d7 in ?? () from C:\msys64\mingw64\bin\libgobject-2.0-0.dll
#14 0x00007ffb9eb50e98 in ?? () from C:\msys64\mingw64\bin\libgobject-2.0-0.dll
#15 0x00007ffb66bf3e65 in ?? () from C:\msys64\mingw64\bin\libgtk-3-0.dll
#16 0x00007ffb66aab8c9 in ?? () from C:\msys64\mingw64\bin\libgtk-3-0.dll
#17 0x00007ffb70b5f139 in ?? () from C:\msys64\mingw64\bin\libgdk-3-0.dll
#18 0x00007ffb70b97eb0 in ?? () from C:\msys64\mingw64\bin\libgdk-3-0.dll
#19 0x00007ffb85fd8783 in ?? () from C:\msys64\mingw64\bin\libglib-2.0-0.dll
#20 0x00007ffb85fdb828 in ?? () from C:\msys64\mingw64\bin\libglib-2.0-0.dll
#21 0x00007ffb85fdbb2d in ?? () from C:\msys64\mingw64\bin\libglib-2.0-0.dll
#22 0x00007ffb6ea9083d in ?? () from C:\msys64\mingw64\bin\libgio-2.0-0.dll

To me it looks like I am writing to uninitialized memory.

@Biswa96
Copy link
Member

Biswa96 commented Sep 24, 2022

Found something in gdb

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ffcad4f320e in g_hash_table_lookup_node (hash_table=0x15884536840, key=0xd0376, hash_return=0x3d943fe6c8) at ../glib-2.74.0/glib/ghash.c:474
474       hash_value = hash_table->hash_func (key);
(gdb) bt
#0  0x00007ffcad4f320e in g_hash_table_lookup_node (hash_table=0x15884536840, key=0xd0376, hash_return=0x3d943fe6c8)
    at ../glib-2.74.0/glib/ghash.c:474
#1  0x00007ffcad4f4cab in g_hash_table_lookup (hash_table=0x15884536840, key=0xd0376)
    at ../glib-2.74.0/glib/ghash.c:1540
#2  0x00007ffcad8286ad in ?? () from F:\msys64\ucrt64\bin\libgdk-3-0.dll

The issue only occurs with glib2 package version 2.74.0-1. If I downgrade glib2 to 2.72.3-3 version things are fine. @lb90 Would you like to share any hint about this issue?

@lb90
Copy link
Collaborator

lb90 commented Sep 24, 2022

Hi @Biswa96! Don't know much currently, but looks related to https://gitlab.gnome.org/GNOME/gimp/-/issues/8576. I will try to debug this tomorrow!

@lb90
Copy link
Collaborator

lb90 commented Sep 24, 2022

Mmh actually the stack traces look pretty different...

@lb90
Copy link
Collaborator

lb90 commented Sep 24, 2022

Ok, I have tried bisecting this. Looks like the first bad commit is https://gitlab.gnome.org/GNOME/glib/-/commit/9444ace2c8 🤷‍♂️

@Jehan
Copy link

Jehan commented Sep 26, 2022

Should be fixed with this patch: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2921

Someone validated that it works on Linux, I welcome people testing on Windows too. :-)

@lb90
Copy link
Collaborator

lb90 commented Sep 26, 2022

Hi @Jehan! That GLib MR fixes the issue in GIMP with NULL GParamSpecs. However, there's also another issue with pasting content from the clipboard on Windows, which is has to be fixed in GTK3. See https://gitlab.gnome.org/GNOME/gtk/-/issues/5207

lb90 added a commit to lb90/MINGW-packages that referenced this issue Sep 26, 2022
@lb90 lb90 mentioned this issue Sep 26, 2022
@PetStr PetStr closed this as completed Sep 26, 2022
@PetStr
Copy link
Author

PetStr commented Sep 26, 2022

I see that lots of work has been done. from @lb90 s work on https://gitlab.gnome.org/GNOME/gtk/-/issues/5207. Will test as soon as the next version comes out. In the mean while I will close this issue.

@Jehan
Copy link

Jehan commented Sep 26, 2022

Thanks @lb90 for the quick investigation and fix! 👍

Biswa96 pushed a commit that referenced this issue Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants