Bug 1962215

Summary: Resizing column of tree/table to zero width crashes application
Product: Red Hat Enterprise Linux 7 Reporter: Simeon Andreev <simeon.andreev>
Component: gtk3Assignee: David King <dking>
Status: CLOSED ERRATA QA Contact: Radek Duda <rduda>
Severity: high Docs Contact:
Priority: high    
Version: 7.9CC: dking, jreznik, loskutov, mclasen, pbhoot, rduda, sbarcomb, tpopela
Target Milestone: rcKeywords: Triaged, ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: gtk3-3.22.30-7.el7_9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2032437 (view as bug list) Environment:
Last Closed: 2022-04-05 17:14:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2032437    
Attachments:
Description Flags
Video showing the crash with the snippet provided in the description.
none
clearlooks-phenix-theme-7.0.1.zip
none
treecrash_coredump.zip none

Description Simeon Andreev 2021-05-19 14:12:46 UTC
Created attachment 1784834 [details]
Video showing the crash with the snippet provided in the description.

Description of problem:

GTK3 crashes on resizing a tree/table column to width 0.

Version-Release number of selected component (if applicable):

3.22.30 (RPM version: gtk3-3.22.30-3.el7.x86_64)

How reproducible:

Compile and run the provided snippet.

Steps to Reproduce:
1. Compile and run the following snippet:
#include <gtk/gtk.h>

// gcc -g table_scrollbar_errors.cpp  `pkg-config --cflags --libs gtk+-3.0` -o TableScrollbarErrors && ./TableScrollbarErrors

enum
{
  STRING_COLUMN1,
  STRING_COLUMN2,
  STRING_COLUMN3,
  NUM_COLS
};


int
main (int argc, char **argv)
{
  GtkWidget *window, *scrolled_window, *view;
  GtkTreeIter iter;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  g_signal_connect(window, "delete_event", gtk_main_quit, NULL);
  gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);

  scrolled_window = gtk_scrolled_window_new (NULL, NULL);

  GtkCellRenderer     *renderer;
  GtkListStore        *liststore;

  liststore = gtk_list_store_new(NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);

  view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(liststore));


  renderer = gtk_cell_renderer_text_new();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), -1, "column1", renderer, "text", STRING_COLUMN1, NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), -1, "column2", renderer, "text", STRING_COLUMN2, NULL);
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), -1, "column3", renderer, "text", STRING_COLUMN3, NULL);
  for (int i = 0; i < 3; ++i) {
    GtkTreeViewColumn   *col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), i);
    gtk_tree_view_column_set_resizable(col, TRUE);
  }

  for (int i = 0; i < 10; ++i) {
    gtk_list_store_append(liststore, &iter);
    gtk_list_store_set(liststore, &iter, 
                           STRING_COLUMN1, "item1",
                           STRING_COLUMN2, "item2",
                           STRING_COLUMN3, "item3",  -1);
  }

  gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (liststore));

  gtk_container_add(GTK_CONTAINER(window), scrolled_window);
  gtk_container_add(GTK_CONTAINER(scrolled_window), view);

  gtk_widget_show_all(window);
 
  gtk_main();

  return 0;
}
(can be compiled e.g. with "gcc -g table.cpp  `pkg-config --cflags --libs gtk+-3.0`  -o TableExample")
2. Resize the first column to 0 width.
3. Observe crash with assertion error:

(TableScrollbarErrors:15278): Gtk-WARNING **: 15:29:34.645: Negative content width -8 (allocation 2, extents 5x5) while allocating gadget (node button, owner GtkButton)
**
Gtk:ERROR:gtkcellrenderer.c:1787:gtk_cell_renderer_get_aligned_area: assertion failed: (aligned_area->x >= cell_area->x && aligned_area->x <= cell_area->x + cell_area->width)
Aborted (core dumped)

Actual results:

Application crashes.

Expected results:

Application does not crash.

Additional info:

See attached video: "gtk_tree_column_resize_to_0_width_crash.mp4"

See also Eclipse bugs (Eclipse is where the problem was initially observed):

https://bugs.eclipse.org/bugs/show_bug.cgi?id=531685
https://bugs.eclipse.org/bugs/show_bug.cgi?id=573637

Comment 4 Benjamin Otte 2021-06-10 17:33:24 UTC
I ran the test locally and it does not crash for me.

But I notice in the video that you are not using the stock Adwaita GTK theme, probably because you're using KDE.  
Could you see if it still crashes when you run it with GTK_THEME=Adwaita ?

Also, if you could attach a stack trace for your crash, that might give an indication.

Comment 5 Simeon Andreev 2021-06-11 06:37:02 UTC
(In reply to Benjamin Otte from comment #4)
> I ran the test locally and it does not crash for me.
> 
> But I notice in the video that you are not using the stock Adwaita GTK
> theme, probably because you're using KDE.  
> Could you see if it still crashes when you run it with GTK_THEME=Adwaita ?
> 
> Also, if you could attach a stack trace for your crash, that might give an
> indication.

We do not see the crash on Adwaita. We also don't plan on using Adwaita.

See my comments on the resp. RHEL support case:

https://access.redhat.com/support/cases/#/case/02944585/discussion?commentId=a0a2K00000at5FcQAI
https://access.redhat.com/support/cases/#/case/02944585/discussion?commentId=a0a2K00000atXyXQAU

Theme is attached on the RHEL support case: https://access.redhat.com/support/cases/#/case/02944585/discussion?attachmentId=a092K00002aE0nxQAC
Core dump is also attached there: https://access.redhat.com/support/cases/#/case/02944585/discussion?attachmentId=a092K00002aDqjHQAS

Comment 6 Matthias Clasen 2021-06-15 13:16:55 UTC
Created attachment 1791263 [details]
clearlooks-phenix-theme-7.0.1.zip

Comment 7 Matthias Clasen 2021-06-15 13:19:36 UTC
Created attachment 1791264 [details]
treecrash_coredump.zip

Comment 8 Matthias Clasen 2021-06-15 18:00:59 UTC
Upstream fix: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/3671

Comment 9 Tomas Popela 2021-06-16 07:12:00 UTC
Moving to POST as there is an upstream fix available.

Comment 20 errata-xmlrpc 2022-04-05 17:14:14 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (gtk3 bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:1192