From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.user Subject: Re: G-Golf - Callback segmentation fault Date: Wed, 21 Aug 2024 21:21:29 -0300 Message-ID: <20240821212129.7647d035@tintin> References: <87msl6c4lf.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/gs7PlQoaL.jUlKsVGbEfZdo"; protocol="application/pgp-signature"; micalg=pgp-sha512 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22169"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user@gnu.org To: Matija Obid Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Aug 22 02:22:45 2024 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sgvbB-0005fM-Er for guile-user@m.gmane-mx.org; Thu, 22 Aug 2024 02:22:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sgvaQ-0001f4-CY; Wed, 21 Aug 2024 20:21:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sgvaO-0001et-L3 for guile-user@gnu.org; Wed, 21 Aug 2024 20:21:56 -0400 Original-Received: from mail.all2all.org ([79.99.200.14] helo=moses.all2all.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sgvaH-0001uo-3J for guile-user@gnu.org; Wed, 21 Aug 2024 20:21:56 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by moses.all2all.org (Postfix) with ESMTP id 1FE6A67C007A; Thu, 22 Aug 2024 02:21:40 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at moses.all2all.org Original-Received: from moses.all2all.org ([127.0.0.1]) by localhost (moses.all2all.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Xg74RCgh2i5v; Thu, 22 Aug 2024 02:21:39 +0200 (CEST) Original-Received: from tintin (unknown [168.227.184.134]) by moses.all2all.org (Postfix) with ESMTPSA id 79FEC67C0074; Thu, 22 Aug 2024 02:21:38 +0200 (CEST) In-Reply-To: <87msl6c4lf.fsf@posteo.net> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; x86_64-pc-linux-gnu) Received-SPF: pass client-ip=79.99.200.14; envelope-from=david@altosw.be; helo=moses.all2all.org X-Spam_score_int: 7 X-Spam_score: 0.7 X-Spam_bar: / X-Spam_report: (0.7 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19765 Archived-At: --Sig_/gs7PlQoaL.jUlKsVGbEfZdo Content-Type: multipart/mixed; boundary="MP_/UFaAlRFpJKKEvkodH0kf3df" --MP_/UFaAlRFpJKKEvkodH0kf3df Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello Matija, > I'm facing the problem mentioned in [1]. Problematic are all examples > with virtual methods. Ok, so you are facing the same problem as Guix and HomeBrew, all other distro (that tried g-golf) work fine, i use Debian. > I have tried simpler example (attached) with same result. There is no > problem, when try same thing with guile-gi library. Somehow, callbacks > are not callable back from C code. Any clue? afaict, guile-gi does not support the definition of virtual functions - you can try this example using guile-gi (which afaict is unmaintained) because you are calling a 'regular' method, set-draw-func no problem, just saying that a mechanism to define vfunc in the GI lang binding of your choice is absolutely crucial for any 'real serious' gnome stack (type)libs use one big diffference in between guile-gi and g-golf is that in g-golf, the callback closure marshal code is written in scheme, the one in guile-gi is written in C - it could be that the pointer of the vfunc 'is fine' in guix/nix as well, but that for some reason, the %g-golf-callback-closure-marshal pointer would be the one that is damaged, i don't know Great, never used that function. You incidentally found a small bug in GI itself [1], and a tiny bug in G-Golf as well, though not the one that would solve the Guix/Nix/Homebrew problem yet [2], but thanks: can you install from the source checkout the devel branch run the make danse and install the latest [ to double check, you need this commit [ 134b57f52bc23cea8e3e02b974c7b909bb7cf56e So, here, after i patched g-golf to deal with this GI destroy notify callback tiny problem, so i can pass #f as its argument, then it works fine, as expected: https://imgur.com/a/tX8bn16 I slightly patched your example so it allows you to call it passing a -d [--debug] argument on the command line, which triggers the display of useful information while debugging ... > I'm using Nix. It would be interesting to try to understand the difference in between Debian (and most other distro) and Guix/Nix: when a vfunc is defined, it sets the upstream class structure field to a pointer, the result of calling g-callable-info-make-closure (defined in (g-golf hl-api callback). For some reason, that pointer is 'damaged' in Guix/Nix/Homebrew, and not in Debian (and most other distro), and as the gdb backtrace shows, in the msg link you are referring to, when Gtk tries to make a snapshot, it needs to access and 'call that pointer', which segfault ... I hope you'll be able to help, feel free to come and join us in #guile or #guix and try to get some help from a guix expert ... Thanks, David [1] all destroy notify callback argument ('linked' to a user-data argument) should always allow to be NULL, which g-golf checks by calling (>=3D (!destroy clb/arg) 0) but the signature of the destroy notify callback argument for gtk_drawing_area_set_draw_func wrongly report -1 [2] i did report the incident upstream, and meanwhile, patched g-golf so it treats callback argument named "destroy" as a maybe-null-exception, which checks itself had a tiny bug, fixed, thanks! --MP_/UFaAlRFpJKKEvkodH0kf3df Content-Type: text/x-scheme Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=nix-set-draw-func.scm #! /bin/sh # -*- mode: scheme; coding: utf-8 -*- exec guile -e main -s "$0" "$@" !# (eval-when (expand load eval) (use-modules (oop goops)) (default-duplicate-binding-handler '(merge-generics replace warn-override-core warn last)) (use-modules (g-golf)) (g-irepository-require "Gtk" #:version "4.0") (for-each (lambda (name) (gi-import-by-name "Gtk" name)) '("ApplicationWindow" "Application" "DrawingArea"))) (define (activate app) (let* ((window (make #:application app #:default-width 960 #:default-height 540 #:title "Title")) (drawing-area (make ))) (set-child window drawing-area) (set-draw-func drawing-area (lambda (area cr w h d) (display "I'm in!") (force-output)) #f #f) (show window))) (define (main args) (letrec ((debug? (or (member "-d" args) (member "--debug" args))) (animate (lambda () (let ((app (make #:application-id "org.gnu.g-golf.set-draw-func")= )) (connect app 'activate activate) (let ((status (g-application-run app '()))) #;(exit status) (dimfi 'status status)))))) (if debug? (parameterize ((%debug #t)) (animate)) (animate)))) --MP_/UFaAlRFpJKKEvkodH0kf3df-- --Sig_/gs7PlQoaL.jUlKsVGbEfZdo Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEhCJlRZtBM3furJHe83T9k6MFetcFAmbGhIkACgkQ83T9k6MF etc/Mgf8DV/hrjvHR8pKEaPWQDZq+/ZRd7nQl4ponbkZuiwnHC6yCPl5ZHhgQuTb pTwhTFH2RsIdRlbm5FDxftdgkt1f4M4Yp1v1Je5x4cag6JO2AP7HmGqI3wmUJNyD uNZj4SrgQYN4mtECN4erHFRcRdn8kkSB7o6FadVJwr4BIOSo4wFfh0gstD18Sslq xcT4qz7+oqeUSAMNVZOf+55g7LNoHJFv1O89UexWQaKiHM+hmOG1f0oKAVBs4Hc+ ONxZmfAf/M31jCeNlFl+206lWgF90ETkGGgajue/sg5eELlY4as4LazANGGDiv9c lia7b4x6Ltlt8bFHlEdnrQxSpWg4FA== =gIFv -----END PGP SIGNATURE----- --Sig_/gs7PlQoaL.jUlKsVGbEfZdo--