IRC channel logs

2025-07-09.log

back to list of logs

<daviid>I should update the manual, to inform there is an easier way to patch guile, which is to clone, then cherry-pick lloda's wip-exception-truncate patch, like this: git cherry-pick ed5e37caa, then run the configure/make/install danse
<daviid>ttz: fwiw, the branch is https://cgit.git.savannah.gnu.org/cgit/guile.git?h=wip-exception-truncate
<lechner>I have some issues with premature garbage collection when interfacing with foreign libraries. What are the rules when memory becomes available for collection, please?
<daviid>lechner: you need to keep track of your pointer to, we all have to ...
<daviid>any *->pointer, you must keep the pointer and what it points to alive
<daviid>till your ffi call returns ofc
<daviid>I said all *->pointer, assuming you already keep any other arg alive ...
<mwette>lechner: since c structs are encoded as bytevectors, they are not scanned for pointers, so you have to track those contents also ; guardians can be useful for this case
<daviid>mwette: does ffi-help takes care of this 'for us'?
<mwette>daviid: nope. That seems like a difficult problem to solve.
<daviid>mwette: fine, jyst asking
<daviid>mwette: i am going to use fiil-helper to 'pre'bind fluidsynth, then write a (maybe goops based) idiomatic scheme layer
<daviid>*the ffi-helper
<lechner>mwette / it's nice that you feel responsible but I think my issue is, solely, this intermediate byte vector, which makes it convenient to pass strings to syscalls but has nothing to do with CDATA. https://codeberg.org/lechner/guile-syscall/src/commit/50dbee079b0ffed73e5d9858537a03476e1f6075/scm/syscall.scm#L357-L359
<mwette>lechner: my bad (assumption). But anyhow, I've used guardians to hang on to pointers in the past. Here I'd add the object created by string->utf8.
<lechner>mwette / thank you for that suggestion! do you have an example how to use a guardian? What does it mean for an object to be "no longer referenced from outside any guardian." please?
<dsmith>lechner, https://www.gnu.org/software/guile/manual/html_node/Guardians.html
<dsmith>And https://dl.acm.org/doi/pdf/10.1145/173262.155110
<mwette>globally: (define myg (make-guardian)) ; later inside your procedure: (let ((bv (string->utf8 s))) (myg bv) (bytevector->pointer bv))
<lechner>dsmith / okay, thanks! the paper did it.
<lechner>mwette / thanks! that was my question
<lechner>mwette / do I have to release the hold the guardian has?
<lechner>or is the key to let the guardian go out of scope?
<mwette>you should when you know it's not used anymore; that's done with `(myg)' (which will release one item from the bag of items you put in it, IIRC.
<mwette>I don't know what happens when a guardian goes out of scope. Good Q.
<lechner>mwette / okay, thanks! do you have a favorite idiomatic way to release all items?
<mwette>I don't have any good ones. I wonder if (while (g) 1) would work.
<lechner>given the random nature of retrievals, wouldn't it be nicer if the guardian returned all of them at once?
<mwette>I don't know. Maybe that is to prevent GC CPU utilization spikes (from running all the finalizers at once).
<lechner>okay, thanks! your suggestion of a guardian is going to help a bunch of my projects. i have been getting desperate to trick the garbage collector. thanks so much!
<mwette>yw
<dodoyada>is there any implementation of server sent events (sse) for either (web server), (fibers web server), or otherwise already out there?
<sneek>wb dsmith!
<wingo>wip-whippet status: i think i have fixed all the trace-related bugs. remaining work is bugs around heuristics about when to grow the heap, and bugs related to making sure that all threads can promptly be brought to a halt.
<wingo>also, whippet currently only works on gnu/linux with gcc. (for clang, i need to fix all the atomic ops to cast to _Atomic; for other platforms, i need to add the necessary backend support for tracing data segments and finding stack bounds.)
<ArneBab>\o/
<dsmith>wingo, I'm always hearing this about the new gc: https://www.youtube.com/watch?v=j_QLzthSkfM
<wingo>i had never seen that video before :)
<dsmith>sneek, botsnack
<sneek>:)