IRC channel logs

2023-03-04.log

back to list of logs

<daviid>lloda: that segfault
<daviid>segfulat g-golf i mean
<daviid>lloda: here is the definition of the function we use that returns the pointer i am passing to the cairo-pointer->context newly added proc ..
<daviid> https://docs.gtk.org/gtk4/method.Snapshot.append_cairo.html
<daviid>lloda: and that is what BrokenClutch uses to call the cairo using the ffi, so it is likely a 'correct' pointer (?)
<daviid>BrokenClutch: can you confirm the above sentence is accurate? can you paste a sample of your g-golf cairo example?
<daviid>lloda: is there a way to get the cairo_t* 'manually', once we called (cairo-create (cairo-image-surface-create 'argb32 140 100)), so we could try to call cairo-pointer->context with that pointer and check it works ?
<BrokenClutch>daviid: what paste site you use? I can show the code, it's pretty small and simple
<daviid>debian, or centos
<daviid> https://paste.centos.org/
<daviid>select the language 'scheme' for better rendering ..
<BrokenClutch>daviid: and to answer the question, yes, I'm using the returned pointer from append_cairo
<daviid>BrokenClutch: ok great
<daviid>tx
<BrokenClutch> https://paste.centos.org/view/1d22dd95
<BrokenClutch>daviid: forgot to mark your name when I sent the link above
<BrokenClutch>I'm new to that IRC stuff
<daviid>BrokenClutch: no need, we usually paste anonymously, and that would be your name actually ...
<BrokenClutch>daviid: I was saying on IRC, like, when I've sent the link
<BrokenClutch>Not even saw the author option in the paste site, hahahaha
<daviid>BrokenClutch: ok great - this is just to confirm for lloda (and myself) that the cairo context pointer is valid, and probably the bug is in the cairo-pointer->context def, but i need the help of lloda to solve it ...
<dsmith>daviid: Just started a fresh build from main.
<dsmith> https://paste.debian.net/1272893/
<dsmith>That's the ./meta/guile-3.0.pc
<daviid>dsmith: same here, i posted a long explanation that for some reason, my previous build failed , but i re-compiled and built gule-cairo as well ...
<dsmith>That's ./configure --prefix=/opt-9
<daviid>dsmith: yes, we are trying to slove a segfault in guile-cairo now
<dsmith>AHh. Sorry. Slow to catch up..
<daviid>dsmith: as you are a good C programmer, if you have an idea
<daviid>dsmith: here i applied this patch, compiled install https://paste.debian.net/1272875/ - then when i call it with a valid cairo_t*, it segfault
<daviid>dsmith: now, to debug, i 'd like to access the pointer in the guile-cairo context smob
<daviid>if you happen to know how ...
<daviid>after (cairo-create (cairo-image-surface-create 'argb32 140 100)) => $5 = #<cairo-context 7faf46da8e20> how to i get the cairo context pointer, so i can call the newlly added proc cairo-pointer->context and help lloda to get it 'right'
<dsmith>Dunno about good. Old. war torn. battle weary.
<daviid>BrokenClutch: in g-golf, each example (small of course, is a script, fwiw, here is the 'Simple Paintable' template that once guile-cairo works, and completed, will land in the distributed examples - https://paste.centos.org/view/4bdfa8d0
<daviid>BrokenClutch: you should carefully read the import module sequence, the goops config and re read the https://www.gnu.org/software/g-golf/manual/html_node/Configuring-Guile-for-G_002dGolf.html manual with 'full attention'
<daviid>BrokenClutch: then, as you can see in this short example, you should not import the all gtk space, rather selectively what you need ... which should boost the launching of the example by a substantial factor
<BrokenClutch>daviid: I was importing everything just to snoop it around on the geiser REPL
<daviid>lloda: so, fwiw, a valid cairo context pointer segfault guile, in this case - https://paste.centos.org/view/4bdfa8d0 - line 79, which uses cr defined line 72, which returns as described here https://docs.gtk.org/gtk4/method.Snapshot.append_cairo.html
<BrokenClutch>but I didn't know that I could have the width and height as arguments of the snapshot vfunc
<daviid>BrokenClutch: ah ok
<daviid>BrokenClutch: but i subclass GObject, you subclaeed gtk-widget, caution ...
<daviid>their respective snapshot virtual function aren't the same
<BrokenClutch>ooooh, I didn't know they could be different
<BrokenClutch>that's something to look for
<daviid>BrokenClutch: your code is perfectly valid to ... but i am more concerned you learn the goops / guile module / generics extremely difficult to understand for a new goops comers ... and the script and any other g-golf exmple, put in exec the recommendation of the g-golf manual ... you will have been warned :):)
<BrokenClutch>daviid: I'm going to, thanks for the help, I'm new to guile and I'm loving it
<daviid>BrokenClutch: if that new, then you are talented :) congrat
<BrokenClutch>daviid: I have some experience with lisp, but I use haskell mainly for doing some dumb projects
<BrokenClutch>and yes, I'm using this opportunity to say something about haskell, is something that we all do, we must spread the word
<daviid>lloda: could t be that cairo_reference sems to be called tice ? it is called by scm_take_cairo (?)
<daviid>lloda: how about "return scm_take_cairo ((cairo_t *) scm_pointer_address (scr));" ?
<daviid>hum, i just tired, that segfault as well
<daviid>*tried
<dsmith>Ok. So need to enable core dumps. (Always forget how). some rlimit?
<dsmith>ulimit
<dsmith>`ulimit -c unlimited` I think
<dsmith>That lets the app dump a core file. Then you can use that with gdb to see where the segfault happened.
<dsmith>(most segfaults I've seen in C/Scheme is letting a SCM be NULL)
<dsmith>(my guile is still building)
<daviid>dsmith: tx, but no need to, it happens exactly calling this linehttps://paste.debian.net/1272875/ - line 22
<daviid>a line which i changed to try return scm_take_cairo ((cairo_t *) scm_pointer_address (scr)); - that segfault as well
<dsmith>So is the argument a SCM or a pointer?
<daviid>but one thing is sure, the cr returend by gtk4 is valid, as BrokenClutch wrote an example which uses the ffi and calls successfully cairo api's passing the cairo context pointer returned by https://docs.gtk.org/gtk4/method.Snapshot.append_cairo.html
<daviid>dsmith: here is the example i just pasted it - https://paste.centos.org/view/4bdfa8d0
<daviid>line 72 defines the cairo context pointer, line 79, i cll the 'make me a guile-cairo cotext opaque type please', and it segfault
<daviid>in guile-cairo.c, i see lines 66 - 70, it just passed the cr, maybe i can try that
<daviid>that segfault as well
<daviid>return scm_take_cairo ((cairo_t *)scr);
<daviid>oh well, it ne3eds a billion years C expert for one line of code
<daviid>this segfault as well return scm_from_cairo ((cairo_t *)scr);
<daviid>this segfault as well return scm_from_cairo ((cairo_t *) scm_pointer_address (scr));
<daviid>today's one billion dllars quiz: how can you make a guile-cairo context recevingin a cairo context
<daviid>it's strange becuse whe i read the def, for exampe, of the user_font_data, in https://git.savannah.nongnu.org/cgit/guile-cairo.git/tree/guile-cairo/guile-cairo.c#n1660 - then the call just below, line 1690, it seems 'we do the same' in cairo-pointer->context
<daviid>i tried to add this def, to get access to the poiter when having guile-cairo context - https://paste.centos.org/view/4c5e4372 - but it rases error compiling ...
<daviid>i am next to blind here though, so if someone who knows C and libguile, can tell us how to ... (1) making a guile-cairo context when receiving a caro context pointer; (2) extract the cairo context pointer from guile-cairo context; then we can use (2) to write and debug (1) ...
<mwette>in C or in Scheme?
<mwette>in C, scm_from_cairo, scm_to_cairo
<mwette>methinks
<daviid>mwette: everything i tried segfault
<daviid>mwette: if you could 'shim-in' that would be great - here my last attempt - https://paste.rs/ejL.C
<daviid>to patch https://git.savannah.nongnu.org/cgit/guile-cairo.git/tree/guile-cairo/guile-cairo.c as suggested by lloda - lloda's 1st proposal was https://paste.debian.net/1272875/, then as it segfault, i tried a couple of things all related here above ..
<daviid>mwette: meanwhile, did you answer my quiz, where is the cod to use th generate cairo.scm ? and what would be the option to schemefy names ?
<daviid>mwette: ah i see cairo.ffi
<daviid>and a renamer is even commented ... great, i'll try asai can - tx
<dsmith>daviid: What's your example test that segfaults? Can you do it with just guile and guile-cairo? OR do I need more stuff?
<daviid>dsmith: so far i use g-golf - https://paste.centos.org/view/4bdfa8d0 - but ideally, you would write the opposite procedure, and use that to write/test/debug, as i just explained here above, let me recap here
<daviid>you patch https://git.savannah.nongnu.org/cgit/guile-cairo.git/tree/guile-cairo/guile-cairo.c with two procedures: (1) cairo-pointer->context; (2) context->cairo-pointer - then use (2) to test/debug (1), then we can try with another app that has proc thatr eturns a cairo_t pointer ...
<daviid>dsmith: https://paste.centos.org/view/2a1b6402
<dsmith>Thanks. looking into it..
<daviid>dsmith: i thank you -
<dsmith>So
<dsmith>(let ((ctx (cairo-create (cairo-image-surface-create 'argb32 140 100))))
<dsmith> (eq? ctx (cairo-pointer->context (context->cairo-pointer ctx))))
<dsmith>Or some kind = should be #t
<daviid>that i don't know, not sure - the problem is not that eq? it is that both proc segfault
<daviid>context->cairo-pointer ctx segfault
<daviid>sorry the other way around cairo-pointer->context, all i tried including the one prposed by lloda segfault - then i couldn't even come with something compilable for context->cairo-pointer
<daviid>dsmith: but i beleive reconstructing would never be eq?, because they are smobs, new smobs ...
<dsmith>I meant for some "kind" of eq.
<daviid>that doesn't matter though - if i have a working reliable cairo-pointer->context procedure in guile-cairo, it's already fine - here the new smobs C func - https://git.savannah.nongnu.org/cgit/guile-cairo.git/tree/guile-cairo/guile-cairo-smob-types.c#n56
<daviid>all we need is to be able to call, from scheme, scm_from_cairo (cairo_t *ctx), and so far all ateempt segfault
<dsmith>Right
<daviid>dsmith: and to debug you'd make it possible to call, from scheme, scm_to_cairo (SCM scm) - https://git.savannah.nongnu.org/cgit/guile-cairo.git/tree/guile-cairo/guile-cairo-smob-types.c#n72 - so you do not depend on g-golf/gtk4 to test/debug ...
<dsmith>Closer, but quite there yet...
<dsmith>scheme@(guile-user)> (cairo-create (cairo-image-surface-create 'argb32 140 100))
<dsmith>$1 = #<cairo-context 7f88502c1560>
<dsmith>scheme@(guile-user)> (context->cairo-pointer $1)
<dsmith>$2 = #<pointer 0x55e6a3837670>
<dsmith>scheme@(guile-user)> (cairo-pointer->context 2)
<dsmith>ice-9/boot-9.scm:1685:16: In procedure raise-exception:
<dsmith>In procedure pointer-address: Wrong type argument in position 1 (expecting POINTER_P): 2
<dsmith>Nope. Sorry
<daviid>dsmith: at least no more segfault
<daviid>(cairo-pointer->context $2) <$2, not 2 ?
<dsmith>My $ is sticky. Poured a coffee on it a while back.
<dsmith> https://paste.debian.net/1272902/
<dsmith>Maybe working?
<daviid>yes! cn you paste your changes or the entire file, as you wish
<dsmith> https://paste.debian.net/1272903/
<dsmith>Not sure if a finalizer is needed.. (the NULL in scm_from_pointer)
<dsmith>But it looks symmetrical
<daviid>i'll let you juge that :) - let me try here and use it with g-golf -
<dsmith>return scm_from_cairo ((cairo_t *) scm_to_pointer (scr));
<dsmith>return scm_from_pointer (scm_to_cairo (scr), NULL);
<dsmith>"from cairo to pointer", and "from pointer to cairo"
<daviid>dsmith: it works, but i need to complete a few cairo calls to actually see something - many thenks, just a few minutes i shall proove it effectively works
<dsmith>Sure hope it does.
<dsmith>I added those just after scm_release_cairo. Seemed a good place
<daviid>hum, what is this expression in scheme cairo_set_dash (cr, (double[1]) { RADIUS * G_PI / 3 }, 1, 0.0); - the (double[1]) { RADIUS * G_PI / 3 } i mean [i have radisu and pi values 'in hand']
<daviid>it's documented here, but i still do not know what to pass ?
<daviid> https://www.nongnu.org/guile-cairo/docs/html/cairo_005ft.html#index-cairo_002dset_002ddash
<daviid>and defined here - https://git.savannah.nongnu.org/cgit/guile-cairo.git/tree/guile-cairo/guile-cairo.c#n506 - i still do not know what scheme value it expects
<daviid>found an example, https://github.com/IisNuINu/guile-cairo-gtk-samples/blob/master/07_pen_dashes.scm - i guess double[1] says a vector of one value
<dsmith>An array of doubles. Actually a pointer to the first item in the array.
<dsmith>But I'm thinking C. That doesn't look like C. Or Scheme.
<haugh>Do we have any former/current Clojure users in here? I'm curious if/how Guile's approach to hash tables (immutability is not thread safe) changes one's approach to data processing, especially if you're used to taking this for granted. The data processing I've seen and imitated so far is mostly pattern based (matching sexps) or record based (depends on syntax for terseness). These are strong statements I'm making and I would love to be corrected on any
<haugh>misunderstanding; I'm just not extremely encouraged by the documentation on hash tables and vhashes.
<dsmith>rlb does clojure
<dsmith>sneek: seen rlb?
<sneek>rlb was last seen in #guile one month and 10 days ago, saying: .
<sneek>.
<haugh>oh no he was eaten by the JVM D:
<dsmith>Well, he's working on lokke, a clojure front end to guile..
<dsmith> https://github.com/lokke-org/lokke
<haugh>fascinating
<daviid>dsmith: (cairo-set-dash cr `#(,(/ (* radius %pi))) 1 0.0) => wrong number of arg - i wonder if guile-cairo has an old cairo-set-dash
<dsmith>ACTION looks..
<daviid>this cairo_set_dash (cr, (double[1]) { RADIUS * G_PI / 3 }, 1, 0.0); written by the gnome team works perfectly -
<daviid>in their C example ofc ..
<daviid>but this example has 3 args - line 27 .. https://github.com/IisNuINu/guile-cairo-gtk-samples/blob/master/07_pen_dashes.scm
<dsmith>The (double[1]) is a cast I guess.
<daviid>dsmith: this is not the problem the C call has 4 args
<daviid>dsmith: https://git.savannah.nongnu.org/cgit/guile-cairo.git/tree/guile-cairo/guile-cairo.c#n506 - what should i pass given this libguile def?
<dsmith>Ahh. So Guile knows the len of the vector.
<daviid>ah i can drop the 1
<daviid>let me try
<dsmith>Yeah
<daviid>ok, but, unfortunately, it doesn draw anything :(
<dsmith>IN the c code, ndashes is from scm_vector_length (sdashes)
<dsmith>Do you need the /3 ? (cairo-set-dash cr `#(,(/ (* radius %pi) 3)) 0.0)
<daviid>dsmith: here is the C code - https://paste.centos.org/view/37e68f22 - here is the g-golf 'same code' using guile-cairo - https://paste.centos.org/view/40dde843 - it should draw a nuclear sign, but i only get the yellow forreground squarre
<dsmith>Could it be drawing the other things (dashes?) in the same color?
<dsmith>wingo!
<dsmith>Does the C example work correctly?
<daviid>dsmith: sorry, complete machine crash here :(
<daviid>i added the 3 - (cairo-set-dash cr `#(,(/ (* radius %pi) 3)) 0.0) - but it still doesn 'draw' on the gtk4 widget
<daviid>here is what i have (on the left) and what i should get (on the right) - https://imgur.com/a/COAuoRl
<cow_2001>hmm
<daviid>ok, i am going to rest, thanks all, dsmith lloda mwette and BrokenClutch tomorrow i'll try a few other things .. not sure what's going on, but i don't see why it does not work, or sjhall i say why it would not work ...
<cow_2001>i feel like i should really really learn proper C
<cow_2001>there are some C programming tracks on coursera by irl universities
<chrislck>you only learn C properly when you encounter segfaults
<cow_2001>BAH & HUMBUG! (define fifo-read (open-file "my-fifo-file" "r")) blocks :(
<cow_2001>i want to use it to communicate between two different processes
<cow_2001>but i cannot do that when opening it blocks
<cow_2001>oh. you need to write into it before it is released
<cow_2001>okay, now that i want to write into it, i can't, because it blocks ~;~
<cow_2001>oh, ah, so turning off fifo buffering works
<cow_2001>still mucking about with the code, but it's getting there http://0x0.st/Hzy2.scm
<ArneBab>cow_2001: feel free to steal the socket stuff I wrote in dryads wake to get around parallelism barriers: https://hg.sr.ht/~arnebab/dryads-wake/browse/game-helpers.w?rev=tip#L450
<cow_2001>wisp!
<cow_2001>in the wild!
<cow_2001>it's like
<cow_2001> https://en.wikipedia.org/wiki/Illusory_contours
<cow_2001>but for parenthesis
<cow_2001>ArneBab: thank you!
<cow_2001>but now i am stuck with a popen port not wanting to be written to until i quit the repl
<cow_2001>(define e (open-pipe* "espeak-ng" "--stdin")) (put-string "moo\n" e)
<cow_2001>err
<cow_2001>open-pipe* OPEN_WRITE etc
<cow_2001>oh right! it's the weird (in a good way) text game. i played it until it told me it's still under development.
<cow_2001>latest and still not working http://0x0.st/HzyR.scm
<cow_2001>okay, i can only get (put-string pipe-port "moo\n") to work after (close-port pipe-port)
<cow_2001>no idea why
<mwette>maybe it's buffered, try setvbuf
<cow_2001>tried
<cow_2001> http://0x0.st/Hzt4.scm
<cow_2001>it says "moo" only after (close-port e)
<cow_2001>oh. of course
<cow_2001>i'm so dumb
<mwette>sneek: later tell dsmith, I got the demo to work in my wayland (guile) code
<sneek>Will do.
<dsmith>Yey
<sneek>Welcome back dsmith, you have 1 message!
<sneek>dsmith, mwette says: I got the demo to work in my wayland (guile) code
<mwette>I think
<dsmith>mwette: Any changes that would explain why it's not working under X?
<dsmith>LIke a refresh/flsh or something?
<mwette>I'm not sure the dashes are there
<dsmith>The "dashes" are the black sections I think.
<mwette> https://github.com/mwette/guile-wl-play/blob/main/pics/demo15wnuk.png
<mwette>I missed some details
<mwette>now i have it -- let me push the new image
<mwette>it works but not showing up on github
<mwette>The C code version does not work?
<cow_2001>somehow working when switched to (spawn) http://0x0.st/HzvP.scm
<daviid>mwette: fyi, the png you posted requires login
<daviid>*visualizing the png you posted requires login ...
<mwette>really?
<mwette>anything like paste.*.net for sharing pics?
<Keele>mwette: imgur?
<mwette> https://imgur.com/a/KjnV97W
<mwette> https://paste.debian.net/1272958/
<mwette>^uses my ffi/cairo implementation
<mwette>Keele: thanks
<daviid>mwette: thanks - i just ask for help on #introspecton, if anyone has an dea of some magic needed ... - but i will try ffi/cairo later today
<daviid>mwette: i unfortunately do not have a working guile-clutter working, otherwise i'd use it and demonstrate gule-cairo works fine - it however probably require some 'magic i am so far unaware of
<mwette>Is it that guile-cairo does not expose the pointers and that is what you need?
<daviid>mwette: if you happen to have an idea, here is the code https://paste.centos.org/view/7029657c - the nuclear icon def starts line 69, the gtk4 cairo context line 71, and the maing of a guile-cairo context line 77
<daviid>mwette: then, i can show the cairo context is 'the cairo context', here is a minintrace with a few pk while rnning the code https://paste.centos.org/view/f034b5b3
<daviid>mwette: i don't understand your sentence 'guile-cairo does not expose the pointers ...'
<mwette>where does `append-cairo' come from?
<daviid>a g-golf method, from gtk4 of course, here - https://docs.gtk.org/gtk4/method.Snapshot.append_cairo.html
<daviid>that definitely works fine
<mwette>and it returns a guile pointer?
<daviid>no, a C pointer
<daviid>line one in the mini trace
<daviid>that pointer is what the user who succeded yesterday with a few manual ffi cairo bindings ...
<mwette>Ah, ok. And can you call something simple like (cairo-get-reference-count on cr) to return a sensible result?
<mwette>s/on //
<daviid>mwette: no, i just call guile-cairo as i ever did (never ever did i have to call cairo-get-reference-count, but maybe that is the guile-clutter magic 'hidden' ...?
<daviid>let me paste the patch for guile-cairo
<mwette>the call to get-reference-count would validate that "cr" is valid
<daviid>here - https://paste.centos.org/view/84196848 lines 3525 -> 3537
<daviid>those are the proc i use in g-golf and used to trace the guile-cairo context effectively use the cairo context given by the gtk4 call to append-cairo ...
<daviid>in g-golf, i 'strictly' mimic te C code, here - https://paste.centos.org/view/37e68f22
<daviid>mwette: ok let me try
<daviid>does that call should be just after making the gule-cvairo context? before all the draw cals?
<mwette>There is no "C pointer" type per-se in GUile. What predicate call on ctx returns #t? (pointer? ctx) (number? ctx) ...
<daviid>cairo-get-reference-count is unbound in guile-cairo
<daviid>mwette: the guile scheme printer writes it as a pointer ...
<mwette>you need to be careful about calling scm_to/from_pointer
<daviid>ok, please check the guile-cairo patch, only two lines to check
<daviid>all i can tell you is that append-cairo returns a pointer one can use with a cairo ffi call
<mwette>OK, I have that now.
<mwette>OK. I was suggesting you call (cairo-get-reference-count cr) early in your nuclear-snapshot routine just to see if "cr" is valid. That call should return 1 nominally.
<daviid>problem is there is no cairo-get-reference-count in gule-cairo
<mwette>(Just for debugging purpose)
<daviid>i wish i'd do that
<mwette>Ah. And there doens't seem to be a cairo? or cairo-t? predicate that I can see.
<daviid>here is the guile-cairo doc - https://www.nongnu.org/guile-cairo/docs/html/
<daviid>i can't find any reference occurrence in the proc index
<daviid>but mwette if it wasn't a valid cairo context pointer, all cairo calls would fail, and prob segfault
<daviid>which is what happened 100x while trying to get this patch for the two proc i pasted ... cairo-pointer->context and context->cairo-pointer - these two procs sefault gule till dsmith kindely find a good patch ...
<mwette>I would hope so. Just trying to break down to something simple. Can you draw a simple line?
<daviid>mwette: i can try, can you suggest the code, i am a very 'not knowledgeable' cairo user (i used to kjnow a bit, i forogt, will get it back ...)
<mwette>I'm no expert, either.
<daviid>what i think is all drawing occurs, but somehow the surface isn't 'aware' and refreshed
<mwette>That might be something.
<daviid>anothyer thing i thought is it draws, but in the 'back' of the background yellow squarre
<daviid>really no sure .. just shooting
<daviid>be right back, 5min afk ... thanks very much for your help
<mwette>maybe cairo-fill-preserve to replace cairo-fill
<daviid>i hope we find why ...
<daviid>ok let me try
<daviid>mwette: no change, still no drawing
<mwette>and what are foreground and background rgba?
<mwette>values
<daviid> https://paste.centos.org/view/7029657c - lines 63 and 64
<daviid>just like the C code, the background is the yellow, the foregrond is back
<daviid>rotation is 0.0 [not really used, it is for the next incantation, an animated nucear icon ...]
<mwette>did you try commenting out the background (li. 82-84)?
<mwette>and make foreground blue or something
<daviid>let try
<daviid>ah - it works
<daviid> https://imgur.com/a/bMiI5qr -
<daviid>hum!
<daviid>idid think about tat and di not try :) - now why? ow to solve it
<mwette>maybe forground/background appends are in bad order or something
<mwette>cairo is fun
<mwette>(really)
<daviid>i agree, it is fun :)
<daviid>lt me indeed append the background first
<daviid>bingo! many thaks for your help
<mwette>yw
<civodul>lloda: hi! looks like optargs.test fails consistently: https://ci.guix.gnu.org/eval/234215?status=failed