Open aidenfoxx opened 10 months ago
Thank you for reporting the issue. I can reproduce the issue in clang32 but not in ucrt64. Unfortunately, I am limited with my knowledge because gdb leads to the SIMD intrinsic used in graphene. Please wait for others to comment.
Here's a stacktrace:
(lldb) target create "./gtk4-demo.exe"
(rrent executable set to 'C:\Users\roberta\gtk4-clang32\gtk4-demo.exe' (i386).
(lldb) r
(lldb) Process 11004 launched: 'C:\Users\roberta\gtk4-clang32\gtk4-demo.exe' (i386)
Process 11004 stopped
* thread #1, stop reason = Exception 0xc0000005 encountered at address 0x667b429c: Access violation reading location 0xffffffff
frame #0: 0x667b429c libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix + 12
libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix:
-> 0x667b429c <+12>: movaps %xmm0, 0x30(%eax)
0x667b42a0 <+16>: movaps 0x20(%ecx), %xmm0
0x667b42a4 <+20>: movaps %xmm0, 0x20(%eax)
0x667b42a8 <+24>: movaps (%ecx), %xmm0
(lldb) bt
* thread #1, stop reason = Exception 0xc0000005 encountered at address 0x667b429c: Access violation reading location 0xffffffff
* frame #0: 0x667b429c libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix + 12
frame #1: 0x674210ec libgtk-4-1.dll`gsk_color_matrix_node_new(child=0x085eafb0, color_matrix=0x0e3ee180, color_offset=0x0e3ee1c0) at gskrendernodeimpl.c:3892:3
frame #2: 0x67050471 libgtk-4-1.dll`gtk_snapshot_collect_color_matrix(snapshot=0x0e77e8c8, state=0x0e3ee160, nodes=0x0e3b79e8, n_nodes=1) at gtksnapshot.c:644:16
frame #3: 0x67052ab1 libgtk-4-1.dll`gtk_snapshot_pop_one(snapshot=0x0e77e8c8) at gtksnapshot.c:1691:14
frame #4: 0x670525a2 libgtk-4-1.dll`gtk_snapshot_pop_internal(snapshot=0x0e77e8c8, is_texture_pop=0) at gtksnapshot.c:1776:10
frame #5: 0x670516ae libgtk-4-1.dll`gtk_snapshot_pop(snapshot=0x0e77e8c8) at gtksnapshot.c:1902:10
frame #6: 0x66f51ab7 libgtk-4-1.dll`gtk_icon_paintable_snapshot_symbolic(paintable=0x0e66d570, snapshot=0x0e77e8c8, width=16, height=16, colors=0x085948a0, n_colors=4) at gtkicontheme.c:3938:5
frame #7: 0x67074857 libgtk-4-1.dll`gtk_symbolic_paintable_snapshot_symbolic(paintable=0x0e66d570, snapshot=0x0e77e8c8, width=16, height=16, colors=0x085948a0, n_colors=4) at gtksymbolicpaintable.c:101:7
frame #8: 0x671886db libgtk-4-1.dll`gtk_css_image_icon_theme_snapshot(image=0x08594890, snapshot=0x0e77e8c8, width=16, height=36) at gtkcssimageicontheme.c:92:3
frame #9: 0x67181a78 libgtk-4-1.dll`gtk_css_image_snapshot(image=0x08594890, snapshot=0x0e77e8c8, width=16, height=36) at gtkcssimage.c:290:3
frame #10: 0x670076aa libgtk-4-1.dll`gtk_css_style_snapshot_icon(style=0x08594830, snapshot=0x0e77e8c8, width=16, height=36) at gtkrendericon.c:66:7
frame #11: 0x6714db3a libgtk-4-1.dll`gtk_builtin_icon_snapshot(widget=0x033b2d40, snapshot=0x0e77e8c8) at gtkbuiltinicon.c:53:5
frame #12: 0x6710ccb6 libgtk-4-1.dll`gtk_widget_create_render_node(widget=0x033b2d40, snapshot=0x0e77e8c8) at gtkwidget.c:11864:7
frame #13: 0x67102202 libgtk-4-1.dll`gtk_widget_do_snapshot(widget=0x033b2d40, snapshot=0x0e77e8c8) at gtkwidget.c:11899:17
frame #14: 0x67103148 libgtk-4-1.dll`gtk_widget_snapshot_child(widget=0x0623bcc0, child=0x033b2d40, snapshot=0x0e77e8c8) at gtkwidget.c:12320:3
frame #15: 0x671071fd libgtk-4-1.dll`gtk_widget_real_snapshot(widget=0x0623bcc0, snapshot=0x0e77e8c8) at gtkwidget.c:762:5
frame #16: 0x6710ccb6 libgtk-4-1.dll`gtk_widget_create_render_node(widget=0x0623bcc0, snapshot=0x0e77e8c8) at gtkwidget.c:11864:7
frame #17: 0x67102202 libgtk-4-1.dll`gtk_widget_do_snapshot(widget=0x0623bcc0, snapshot=0x0e77e8c8) at gtkwidget.c:11899:17
frame #18: 0x67103148 libgtk-4-1.dll`gtk_widget_snapshot_child(widget=0x062f15b0, child=0x0623bcc0, snapshot=0x0e77e8c8) at gtkwidget.c:12320:3
frame #19: 0x671071fd libgtk-4-1.dll`gtk_widget_real_snapshot(widget=0x062f15b0, snapshot=0x0e77e8c8) at gtkwidget.c:762:5
frame #20: 0x6710ccb6 libgtk-4-1.dll`gtk_widget_create_render_node(widget=0x062f15b0, snapshot=0x0e77e8c8) at gtkwidget.c:11864:7
frame #21: 0x67102202 libgtk-4-1.dll`gtk_widget_do_snapshot(widget=0x062f15b0, snapshot=0x0e77e8c8) at gtkwidget.c:11899:17
frame #22: 0x67103148 libgtk-4-1.dll`gtk_widget_snapshot_child(widget=0x06ae4d88, child=0x062f15b0, snapshot=0x0e77e8c8) at gtkwidget.c:12320:3
frame #23: 0x671071fd libgtk-4-1.dll`gtk_widget_real_snapshot(widget=0x06ae4d88, snapshot=0x0e77e8c8) at gtkwidget.c:762:5
frame #24: 0x6710cc8a libgtk-4-1.dll`gtk_widget_create_render_node(widget=0x06ae4d88, snapshot=0x0e77e8c8) at gtkwidget.c:11859:7
frame #25: 0x67102202 libgtk-4-1.dll`gtk_widget_do_snapshot(widget=0x06ae4d88, snapshot=0x0e77e8c8) at gtkwidget.c:11899:17
frame #26: 0x67103148 libgtk-4-1.dll`gtk_widget_snapshot_child(widget=0x06ac5d50, child=0x06ae4d88, snapshot=0x0e77e8c8) at gtkwidget.c:12320:3
frame #27: 0x671071fd libgtk-4-1.dll`gtk_widget_real_snapshot(widget=0x06ac5d50, snapshot=0x0e77e8c8) at gtkwidget.c:762:5
frame #28: 0x67020304 libgtk-4-1.dll`gtk_scrolled_window_snapshot(widget=0x06ac5d50, snapshot=0x0e77e8c8) at gtkscrolledwindow.c:2832:3
frame #29: 0x6710ccb6 libgtk-4-1.dll`gtk_widget_create_render_node(widget=0x06ac5d50, snapshot=0x0e77e8c8) at gtkwidget.c:11864:7
frame #30: 0x67102202 libgtk-4-1.dll`gtk_widget_do_snapshot(widget=0x06ac5d50, snapshot=0x0e77e8c8) at gtkwidget.c:11899:17
frame #31: 0x67103148 libgtk-4-1.dll`gtk_widget_snapshot_child(widget=0x06a80a98, child=0x06ac5d50, snapshot=0x0e77e8c8) at gtkwidget.c:12320:3
frame #32: 0x671071fd libgtk-4-1.dll`gtk_widget_real_snapshot(widget=0x06a80a98, snapshot=0x0e77e8c8) at gtkwidget.c:762:5
frame #33: 0x6710ccb6 libgtk-4-1.dll`gtk_widget_create_render_node(widget=0x06a80a98, snapshot=0x0e77e8c8) at gtkwidget.c:11864:7
frame #34: 0x67102202 libgtk-4-1.dll`gtk_widget_do_snapshot(widget=0x06a80a98, snapshot=0x0e77e8c8) at gtkwidget.c:11899:17
frame #35: 0x67103148 libgtk-4-1.dll`gtk_widget_snapshot_child(widget=0x06a80540, child=0x06a80a98, snapshot=0x0e77e8c8) at gtkwidget.c:12320:3
frame #36: 0x671071fd libgtk-4-1.dll`gtk_widget_real_snapshot(widget=0x06a80540, snapshot=0x0e77e8c8) at gtkwidget.c:762:5
frame #37: 0x6710ccb6 libgtk-4-1.dll`gtk_widget_create_render_node(widget=0x06a80540, snapshot=0x0e77e8c8) at gtkwidget.c:11864:7
frame #38: 0x67102202 libgtk-4-1.dll`gtk_widget_do_snapshot(widget=0x06a80540, snapshot=0x0e77e8c8) at gtkwidget.c:11899:17
frame #39: 0x67103148 libgtk-4-1.dll`gtk_widget_snapshot_child(widget=0x0691b430, child=0x06a80540, snapshot=0x0e77e8c8) at gtkwidget.c:12320:3
frame #40: 0x671071fd libgtk-4-1.dll`gtk_widget_real_snapshot(widget=0x0691b430, snapshot=0x0e77e8c8) at gtkwidget.c:762:5
frame #41: 0x6710cc8a libgtk-4-1.dll`gtk_widget_create_render_node(widget=0x0691b430, snapshot=0x0e77e8c8) at gtkwidget.c:11859:7
frame #42: 0x67102202 libgtk-4-1.dll`gtk_widget_do_snapshot(widget=0x0691b430, snapshot=0x0e77e8c8) at gtkwidget.c:11899:17
frame #43: 0x671020a5 libgtk-4-1.dll`gtk_widget_snapshot(widget=0x0691b430, snapshot=0x0e77e8c8) at gtkwidget.c:11921:3
frame #44: 0x6710237a libgtk-4-1.dll`gtk_widget_render(widget=0x0691b430, surface=0x085efd20, region=0x0625cb48) at gtkwidget.c:11953:3
frame #45: 0x6711d108 libgtk-4-1.dll`surface_render(surface=0x085efd20, region=0x0625cb48, widget=0x0691b430) at gtkwindow.c:4745:3
frame #46: 0x673621de libgtk-4-1.dll`_gdk_marshal_BOOLEAN__BOXEDv(closure=0x0e7b4a70, return_value=0x009ef780, instance=0x085efd20, args="H\xcb%\U00000006(\xf8\x9e", marshal_data=0x00000000, n_params=1, param_types=0x085e8900) at gdkmarshalers.c:130:14
frame #47: 0x66c47969 libgobject-2.0-0.dll`__g_closure_invoke_va + 249
frame #48: 0x66c5ae20 libgobject-2.0-0.dll`g_signal_emit_valist + 1120
frame #49: 0x66c5b580 libgobject-2.0-0.dll`g_signal_emit + 64
frame #50: 0x67400281 libgtk-4-1.dll`gdk_surface_paint_on_clock(clock=0x085ed600, data=0x085efd20) at gdksurface.c:1393:7
frame #51: 0x66c4960c libgobject-2.0-0.dll`g_cclosure_marshal_VOID__VOIDv + 44
frame #52: 0x66c47969 libgobject-2.0-0.dll`__g_closure_invoke_va + 249
frame #53: 0x66c5b2ab libgobject-2.0-0.dll`g_signal_emit_valist + 2283
frame #54: 0x66c5b580 libgobject-2.0-0.dll`g_signal_emit + 64
frame #55: 0x673d924b libgtk-4-1.dll`_gdk_frame_clock_emit_paint(frame_clock=0x085ed600) at gdkframeclock.c:710:3
frame #56: 0x673db22c libgtk-4-1.dll`gdk_frame_clock_paint_idle(data=0x085ed600) at gdkframeclockidle.c:634:19
frame #57: 0x673daabf libgtk-4-1.dll`gdk_frame_clock_flush_idle(data=0x085ed600) at gdkframeclockidle.c:400:3
frame #58: 0x66cc4180 libglib-2.0-0.dll`g_clear_list + 144
(lldb) f 1
frame #1: 0x674210ec libgtk-4-1.dll`gsk_color_matrix_node_new(child=0x085eafb0, color_matrix=0x0e3ee180, color_offset=0x0e3ee1c0) at gskrendernodeimpl.c:3892:3
3889 node->offscreen_for_opacity = child->offscreen_for_opacity;
3890
3891 self->child = gsk_render_node_ref (child);
-> 3892 graphene_matrix_init_from_matrix (&self->color_matrix, color_matrix);
3893 graphene_vec4_init_from_vec4 (&self->color_offset, color_offset);
3894
3895 gsk_rect_init_from_rect (&node->bounds, &child->bounds);
(lldb) p *self
(GskColorMatrixNode) {
render_node = {
parent_instance = {
g_class = 0x0334cad8
}
ref_count = 1
bounds = {
origin = (x = 0, y = 0)
size = (width = 0, height = 0)
}
preferred_depth = 0
offscreen_for_opacity = 0
}
child = 0x085eafb0
color_matrix = {
__graphene_private_value = {
x = (x = 0, y = 0, z = 0, w = 0)
y = (x = 0, y = 0, z = 0, w = 0)
z = (x = 0, y = 0, z = 0, w = 0)
w = (x = 0, y = 0, z = 0, w = 0)
}
}
color_offset = {
__graphene_private_value = (x = 0, y = 0, z = 0, w = 0)
}
}
(lldb) p color_matrix
(const graphene_matrix_t *) 0x0e3ee180
(lldb) p *color_matrix
(const graphene_matrix_t) {
__graphene_private_value = {
x = (x = 0.200000003, y = 0.819607853, z = 0.478431374, w = 0)
y = (x = 0.960784316, y = 0.474509805, z = 0, w = 0)
z = (x = 0.800000011, y = 0, z = 0, w = 0)
w = (x = 0, y = 0, z = 0, w = 1)
}
}
(lldb) f 0
frame #0: 0x667b429c libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix + 12
libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix:
-> 0x667b429c <+12>: movaps %xmm0, 0x30(%eax)
0x667b42a0 <+16>: movaps 0x20(%ecx), %xmm0
0x667b42a4 <+20>: movaps %xmm0, 0x20(%eax)
0x667b42a8 <+24>: movaps (%ecx), %xmm0
(lldb) registers read
error: 'registers' is not a valid command.
(lldb) register read
General Purpose Registers:
eax = 0x0E66D688
ebx = 0x009EE300
ecx = 0x0E3EE180
edx = 0x00000000
edi = 0x0E77E8C8
esi = 0x0E77E8C8
ebp = 0x009EE1E0
esp = 0x009EE1B4
eip = 0x667B429C libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix + 12
eflags = 0b00000000000000010000001000000110
(lldb)
Doesn't happen if libgraphene is built with --buildtype=debug
🤷♂️
And here's with debugoptimized
builds:
$ lldb ./gtk4-demo.exe
(lldb) target create "./gtk4-demo.exe"
(rrent executable set to 'C:\Users\roberta\gtk4-clang32\gtk4-demo.exe' (i386).
(lldb) r
(lldb) Process 13304 launched: 'C:\Users\roberta\gtk4-clang32\gtk4-demo.exe' (i386)
Process 13304 stopped
* thread #1, stop reason = Exception 0xc0000005 encountered at address 0x667542cc: Access violation reading location 0xffffffff
frame #0: 0x667542cc libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix(m=0x0deea508, src=0x009ee310) at graphene-matrix.c:248:19
245 graphene_matrix_init_from_matrix (graphene_matrix_t *m,
246 const graphene_matrix_t *src)
247 {
-> 248 m->value = src->value;
249
250 return m;
251 }
(lldb) p m
(graphene_matrix_t *) 0x0deea508
(lldb) p src
(const graphene_matrix_t *) 0x009ee310
(lldb) p *src
(const graphene_matrix_t) {
value = {
x = (x = 0.200000003, y = 0.819607853, z = 0.478431374, w = 0)
y = (x = 0.960784316, y = 0.474509805, z = 0, w = 0)
z = (x = 0.800000011, y = 0, z = 0, w = 0)
w = (x = 0, y = 0, z = 0, w = 1)
}
}
(lldb) p *m
(graphene_matrix_t) {
value = {
x = (x = -0.00132703932, y = -0.00132703932, z = -0.00132703932, w = -0.00132703932)
y = (x = -0.00132703932, y = -0.00132703932, z = -0.00132703932, w = -0.00132703932)
z = (x = -0.00132703932, y = -0.00132703932, z = -0.00132703932, w = -0.00132703932)
w = (x = -0.00132703932, y = -0.00132703932, z = -0.00132703932, w = -0.00132703932)
}
}
(lldb)
I can't understand where 0xffffffff comes out of..guess we have to check the function with a disassembler
Here's graphene_matrix_init_from_matrix compiled with debugoptimized
(crashes):
(lldb) disassemble
libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix:
0x668742c0 <+0>: movl 0x4(%esp), %eax
0x668742c4 <+4>: movl 0x8(%esp), %ecx
0x668742c8 <+8>: movaps 0x30(%ecx), %xmm0
-> 0x668742cc <+12>: movaps %xmm0, 0x30(%eax)
0x668742d0 <+16>: movaps 0x20(%ecx), %xmm0
0x668742d4 <+20>: movaps %xmm0, 0x20(%eax)
0x668742d8 <+24>: movaps (%ecx), %xmm0
0x668742db <+27>: movaps 0x10(%ecx), %xmm1
0x668742df <+31>: movaps %xmm1, 0x10(%eax)
0x668742e3 <+35>: movaps %xmm0, (%eax)
0x668742e6 <+38>: retl
Versus debug
(which runs fine):
(lldb) disassemble
libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix:
0x668b5a30 <+0>: pushl %ebp
0x668b5a31 <+1>: movl %esp, %ebp
0x668b5a33 <+3>: subl $0xc, %esp
0x668b5a36 <+6>: movl 0xc(%ebp), %eax
0x668b5a39 <+9>: movl 0x8(%ebp), %eax
-> 0x668b5a3c <+12>: movl 0x8(%ebp), %ecx
0x668b5a3f <+15>: movl 0xc(%ebp), %eax
0x668b5a42 <+18>: movl %ecx, (%esp)
0x668b5a45 <+21>: movl %eax, 0x4(%esp)
0x668b5a49 <+25>: movl $0x40, 0x8(%esp)
0x668b5a51 <+33>: calll 0x668d9ac2 ; _memcpy
0x668b5a56 <+38>: movl 0x8(%ebp), %eax
0x668b5a59 <+41>: addl $0xc, %esp
0x668b5a5c <+44>: popl %ebp
0x668b5a5d <+45>: retl
Here's debugoptimized with GCC from MSYS2/MINGW32 (runs fine):
(lldb) disassemble
libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix:
-> 0x667366b0 <+0>: pushl %ebp
0x667366b1 <+1>: movl %esp, %ebp
0x667366b3 <+3>: movl 0xc(%ebp), %edx
0x667366b6 <+6>: movl 0x8(%ebp), %eax
0x667366b9 <+9>: movdqu (%edx), %xmm1
0x667366bd <+13>: movups %xmm1, (%eax)
0x667366c0 <+16>: movdqu 0x10(%edx), %xmm2
0x667366c5 <+21>: movups %xmm2, 0x10(%eax)
0x667366c9 <+25>: movdqu 0x20(%edx), %xmm3
0x667366ce <+30>: movups %xmm3, 0x20(%eax)
0x667366d2 <+34>: movdqu 0x30(%edx), %xmm0
0x667366d7 <+39>: movups %xmm0, 0x30(%eax)
0x667366db <+43>: popl %ebp
0x667366dc <+44>: retl
(lldb) register read
General Purpose Registers:
eax = 0x009EE3F0
ebx = 0x009EE76C
ecx = 0x009EE5B0
edx = 0x667542B0 _graphene_identity_matrix_floats + 48
edi = 0x00000000
esi = 0x00000000
ebp = 0x009EE458
esp = 0x009EE32C
eip = 0x667366B0 libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix at 247:1
eflags = 0b00000000000000000000001001000110
I believe it's a dupe of https://github.com/llvm/llvm-project/issues/55844
movaps %xmm0, 0x30(%eax)
With EAX=0x0E66D688 is not correct since movaps can only operate on addresses that are 16 bytes aligned.
Edit: however graphene_matrix_t
is meant to be 16 byte aligned...
graphene_matrix_t
is aligned to 16 bytes (even without SSE support). That can also be verified with alignof
. Anyway in https://github.com/msys2/MINGW-packages/issues/18799#issuecomment-1837537008 we have m=0x0deea508, which isn't a multiple of 16.
frame #0: 0x667542cc libgraphene-1.0-0.dll`graphene_matrix_init_from_matrix(m=0x0deea508, src=0x009ee310) at graphene-matrix.c:248:19
245 graphene_matrix_init_from_matrix (graphene_matrix_t *m,
246 const graphene_matrix_t *src)
247 {
-> 248 m->value = src->value;
249
250 return m;
251 }
(lldb) p m
(graphene_matrix_t *) 0x0deea508
The matrix is heap allocated, perhaps the required alignment is not respected by g_type_create_instance
This is going to be fixed within GTK, see https://gitlab.gnome.org/GNOME/gtk/-/issues/6256
How did you build graphene? Which build flags did you use?
Hi @ebassi! :) Build recipe is here https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-graphene/PKGBUILD#L24
Thanks, @lb90. Care to check what is the generated graphene-config.h
? Because this looks like something is enabling the SSE or GCC autovectorisation implementations of graphene_simd4f_t
on i686, which should just not happen.
You can try and rebuild Graphene with -Dsse2=false -Dgcc_vector=false
, and see if it reproduces the issue.
Really amazing work @lb90. ❤️
Here's the configure output:
Directories
prefix : D:/msys64/clang32
libdir : lib
includedir : include
SIMD
SSE : NO
GCC/Clang vector: NO
ARM NEON : NO
Features
GObject types : YES
Introspection : NO
Build
Documentation : NO
Tests : YES
Installed tests : NO
Subprojects
mutest : YES
User defined options
buildtype : release
gtk_doc : false
installed_tests : false
Setting options explicitly with -Dsse2=false -Dgcc_vector=false
doesn't seem to help, still crashes.
My understanding is that the compiler emits movaps
instructions because it sees that graphene_matrix_t
is aligned to 16 bytes and takes advantage of that. That happens regardless if the graphene's SSE2 code path is included for compilation or not.
We may work around that by setting a low -march
or something like -mno-sse
Description / Steps to reproduce the issue
The "mingw-w64-clang-i686-gtk4" current causes a segmentation fault when used. This can be seen by executing the "gtk4-demo.exe" included with the package.
Expected behavior
The library can be used without causing an immediate crash.
Actual behavior
An immediate segmentation fault.
Verification
Windows Version
MSYS_NT-10.0-19044
MINGW environments affected
Are you willing to submit a PR?
No response