IRC channel logs

2025-09-09.log

back to list of logs

<euouae>Hey all, I'm trying something out with Geiser and I'm experiencing something that I'd consider a bug, I wonder if others have noticed it
<sneek>Welcome back euouae, you have 1 message!
<sneek>euouae, dsmith says: For a simple example, see: https://gitlab.com/dalepsmith/guile-sqlite/
<euouae>I set geiser-guile-binary to (list "$fullpath/pre-inst-env" "guile")
<euouae>Where substitute $fullpath with the directory where pre-inst-env is
<euouae>Now if I evaluate each line of my scheme file with C-c C-c, it loads fine. But if I try to use C-c C-b to load the entire buffer with `geiser-eval-buffer', it gives me an error that is related to pathing
<euouae>similarly, if I quit the REPL with C-c C-q and then bring it back with C-c C-z (as advertised by the prompt), now I can't load *even* with C-c C-c (`geiser-eval-definition') which tells me that the "brought back" guile repl is *different* from the pre-inst-env one
<euouae>What is going on? These seem to be bugs to me.
<dsmith>What if you use $fullpath/meta/guile (I assume $fullpath is the dir with guile sources)
<euouae>oh this is not the guile distribution, but my own package
<dsmith>Ahh.
<euouae>ah wait, I know
<euouae>the geiser REPL is different because I used setq-local instead of setq for geiser-guile-binary
<euouae>so at least /that/ is resolved. I still don't understand why C-c C-b doesn't work
<euouae>Ill try to setq geiser-guile-binary and see if that changes naything
<euouae>okay, this actually fixed my C-c C-b problem but bringing back the REPL with C-c C-z is still broken
<euouae>I was much more interested in fixing the issue with loading the buffer, restarting the REPL can also be done with M-x geiser. Still I might report this issue. Thanks!
<euouae>ah okay, I think I can move this to #emacs. something to do with `call-interactively'
<dsmith>euouae, I think there is a #geiser you also might try
<old>weird that we have `macro?' and not `syntax?'
<dsmith>old, macro? is probably from the before-times. When Guile only had CL style defmacro
<euouae>yeah speaking of before times I noticed your sqlite project is 15 years old!
<dsmith>Heh. yes. It's what the bot uses.
<euouae>I wonder how guile broke things as it upgraded from 2.0 to 2.2 and eventually to 3.0
<euouae>at least those are the versions searched for, I guess something to do with ABI
<old>Guile first commit is: 1996-07-25; I was 5 months old
<dsmith>I *think* there was guile-i guile-ii and guile-iii before that. Before it was under version control.
<dsmith>euouae, That guile-sqlite is a fairly minimal example of using load-extesion and installing it with auto* stuff
<euouae>dsmith: oh sure, I have that down working fine now
<dsmith>Cool
<euouae>what I'm trying to figure out now is how to exactly set up geiser with emacs to have the pre-inst environment loaded up
<dsmith>sneek, seen jao
<sneek>jao was last seen in #guile 2 years ago, saying: abcdw, i am leaving now, but if you can reproduce it every time and you can, please do fill a new issue and i'll take a look, or chime in in that one. thanks!.
<ieure>old, I really expected someone with a nick of "old" to be older.
<euouae>the old are young, the fools wise
<old>funny because I'm the yougest at my job
<old>one day it will fit well ;-)
<euouae>ah I fixed my issue entirely. it was a quirk.
<euouae>apparently in Emacs using `setq-local' means that subsequent `setq' behave locally too
<euouae>I had to kill the buffer and re-do whatever I was doing
<dsmith>euouae, Are you using paredit? If not, Recommended!
<rlb>*definitely*
<rlb> https://www.emacswiki.org/pics/static/PareditCheatsheet.png
<rlb>sure there's a nicer pdf or similar somewhere...
<euouae>sure, but what I care about is a good solution for setting the correct guile env variables for hacking the project
<dsmith>rlb, Ever use paredit-convolute-sexp ? I finally found a use. It's for let-over-lambda
<dsmith>(define (foo) (let ((bar baz)) | (something))) --> (let ((bar baz)) (define (foo) | (something)))
<dsmith>With | the cursor
<rlb>don't think so?
<rlb>I quite like, but never remember to use the threading/unthreading functions in clojure mode...
<euouae>This is sort of what I ended up with
<rlb>does what you'd think (w (x (y (z)))) becomes (-> (z) y x w)
<euouae> https://termbin.com/92ow
<euouae>I don't like that it relies on the VPATH build directory being named `build`.
<rlb>Poked at this a bit, but looks like I'd need to back up and understand structs a bit better first: https://debbugs.gnu.org/78789
<rlb>(Thought I'd see if it might be "easy" to fix for 3.0.11.)
<dsmith>Wow. Sure does
<rlb>yeah, trivial to reproduce, and meta/gdb-uninstalled-guile points right to it, so imagine/hope it won't be too hard to track down when someone (me or someone else) has time to focus on it.
<dsmith>scm_is_valid_vtable_layout (layout=0x2), but layout is a SCM. Is 0x2 a valid SCM ?
<rlb>Vague impression was that that might just be an unboxed "2" (structs appear to have both boxed (SCM) and unboxed long values).
<rlb>old: the patch for this is in main now so I was wondering about closing it, but wanted to see what you thought https://debbugs.gnu.org/76589 We could leave it open, or we could move your independent concerns to a new bug, or... No strong opinion, just hit it when reviewing some bugs.
<opoku>Hello, I'm new to guile and looking to understand how to leverage its FFI for experimenting with shared libs using the `(system foreign-library)` module. To start with, I'd like to call a function that accepts a `struct opaque_type **` parameter. This function allocates the memory for that opaque type and stores a pointer to the allocated memory in the parameter provided by the caller. I'm struggling to figure out h
<opoku>ow to invoke such a function from reading the docs/googling. Any help would be appreciated.
<old>rlb: POSIX says: "If an application attempts to use a thread ID whose lifetime has ended, the behavior is undefined."
<old>rlb: I can't see from the patch alone, but if `scm_i_is_finalizer_thread' is called in a thread after the `with_guile' but before the store of NULL to `finalizer_thread' in `run_finalization_thread', then we are effectively reaching that scenario
<old>in that, we will pass to `pthread_equal' a dangling pthread_t
<old>which could yield a false positive
<old>you could protect the access to `finalizer_thread' with a pthread_rwlock_t instead
<old>of using atomic operations
<old>I can't reply to the patch tomorrow for more details if you would like
<old>s/can't/can
<euouae>opoku: hey do you already have a function that allcoates the opaque type?
<euouae>i.e. does the C library come with make_foo()?
<euouae>shoot, now codeberg.org is offline?
<ieure>Yes: https://status.codeberg.org/status/codeberg
<euouae>ah thanks
<opoku>euouae: no. I don't think so? If it helps, i'm looking at libsystemd's sd_bus.h. An example prototype is `int sd_bus_default(sd_bus **ret);`. And all the sd_bus init functions are all like that.
<opoku> https://github.com/systemd/systemd/blob/main/src/systemd/sd-bus.h#L41-L55
<rlb>old: oh, I'm not sure I've ever really looked at the patch, I just noticed there was a patch in main and wondered about resolving the bug.
<euouae>opoku: you can't call those functions without having an sd_bus object
<euouae>opoku: so you can't use purely the (system foreign-library) stuff
<euouae>opoku: when two languages communicate, one of them has to do the "heavy lifting". (system foreign-library) means Guile does the "heavy lifting", i.e. the shim is Guile-side
<euouae>the problem is that you can't easily obtain e.g. the size of sd_bus to allocate it from Guile-side
<euouae>So what you have to do is write a Guile "extension" (see manual) which is effectively a shim on C-side and load it with `load-library`
<euouae>e.g. static SCM csvguileshim_make_csv_parser(void) { struct csv_parser *p = malloc(sizeof *p); return scm_from_pointer(p, free); }
<euouae>^ this is a library called csv-guile-shim.so that allocates and returns a `struct csv_parser *` from libcsv because libcsv does not provide a means to allocate one.
<euouae>opoku: if it's useful to you I can send you an entire project that I wrote that demonstrates this; but there's also <https://gitlab.com/dalepsmith/guile-sqlite> as an example
<opoku>euouae: Thanks so much! I'll take a look at this sqlite project but any other pointers would be very appreciated!
<euouae>opoku: I'm going through a big Guile examples project right now
<euouae>I have about 6 different use-cases, each with both flat and recursive make
<euouae>It should be ready soon, I can message you when it's done. I'm hoping that it'll be useful for anyone who is trying to start a Guile project
<opoku>Nice! Looking forward to it. I've just looked through the sqlite project above. It should be enough to unblock me for now.
<euouae>cool!
<old>rlb: I will have a look more closely by inspect the code to see if that situation can arise. If not, then I would add a commentary and an assertion. I'll send a patch in reply to this bug
<old>hmf port returned from `tmpfile' do not set the O_CLOEXEC flag
<old>a copy of the underyling filedescript is made using dup(2) without preserving the flags, thus leaking the temporat anonymous file to child processes
<rlb>old: hmm, I wasn't planning to pursue that code myself right now, so I'd say maybe either append to the exiting bug or create a new one? (For the moment, I was just trying to decide if we wanted to close the existing one since I saw the patch in main.)
<rlb>My primary concern at the moment is trying to help prepare for a 3.0.11 release.
<old>I don't think this is blocker for 3.0.11 since I doubt this race condition can happen or have side effect
<old>so I can you can go ahead with closing it and I will open a new one with a patch
<rlb>OK, thanks much.
<old>are patches still sent on the ML or are we opening things on codeberg now?
<rlb>As far as I know either is fine -- I'd imagine also still fine to include patches in the bug tracker.
<rlb>wingo: it looked like you might already have some familiarity with the struct code -- if you get a minute, this segfault is trivial to reproduce: https://debbugs.gnu.org/cgi/78789
<dsmith>rlb, Yeah, that 0x2 is INUM0
<rlb>Incidentally, I'm now wondering if the make-structu-layout info docs are wrong, i.e. the "one can define 'make vtable' in this way -- it calls make-struct/no-tail with three args, but it only takes two...
<rlb>"make-struct-layout"
<rlb>oh, wait, maybe nvm.
<rlb>those are the inits
<rlb>dsmith: oh, wait, right -- I think that's just crashing because we created a vtable with the standard-vtable-fields, and the docs basically say that it's "quacks like duck" territory, so if your struct has the right fields for a vtable, then it's marked as (via the "magic") a vtable, and when that code hits a raw 0 for the first field, it crashes.
<rlb>Basically, "insufficient validation".
<rlb>I'll see if that pans out.
<dsmith>I'm suspicious of `scm_is_true (SCM_VTABLE_LAYOUT (obj)` in scm_c_make_structv
<rlb>sure, that's what lets us proceed even though it's an integer.
<rlb>I think?
<dsmith>SCM_VTABLE_LAYOUT(obj) is evaluating to 0
<rlb>0 or INUM0?
<dsmith>INUM0
<rlb>right, so that's true and we proceed
<rlb>I'd noticed that too, but assumed maybe the other vetting was "fine", but I think we may need to guard better there, or elsewhere...
<dsmith>But I'm guessing that's not vldid layout...
<rlb>It's not.
<rlb>You can see from the scm_i_symbol_chars () calls, including the one that causes the segfault, that a layout's expected to be amenable to symbol_chars...
<dsmith>Does not fail with (make-struct/no-tail (make-vtable standard-vtable-fields #f) #f)
<rlb>nice :)
<dsmith>I'm guessing that scm_is_true should instead be checking for a valid layout?
<rlb>yeah, and as far as I can tell so far, that'd be just scm_is_symbol.
<rlb>does at least avoid the segfault
<rlb>and passes the tests
<rlb>I'll want to double-check layout contruction, but seems like a plausible fix -- thanks for the help.
<rlb>"construction"
<rlb>yep - it's a symbol (see make-struct-layout in struct.c)
<rlb>wingo: nvm - we figured it out.
<dsmith>Well. What more could you ask for..
<dsmith>(passes all the tests)
<rlb>:)
<rlb>well, eventually passes all the tests -- we need a bounty of some kind for that intermittent
<rlb>ERROR: 00-repl-server.test: repl-server: HTTP inter-protocol attack - arguments: ((system-error "fport_write" "~A" ("Broken pipe") (32)))
<rlb>failure
<rlb>I sometimes hit it repeatedly.
<rlb>with "make -j5 check" here.
<dsmith>Is 5 $(nproc) ?
<rlb>nproc is 4
<dsmith>Ok
<rlb>And to your earlier point, it halts the tests, so I have to try again.
<rlb>i.e. can't see if everything else would have been fine.
<dsmith>Heh: https://bpa.st/SXOQ
<rlb>:) I'm still wondering if we might want a more modal guile-test, but if so, not sure what the command line api should be, etc.
<dsmith>rlb, So what is the error with that HTTP inter-protocol attack ?
<dsmith>Broken pipe..
<rlb>The line above is all it prints.
<rlb>i.e. ERROR: 00-repl-server.test: repl-server: HTTP inter-protocol attack - arguments: ((system-error "fport_write" "~A" ("Broken pipe") (32)))
<rlb>I don't remember if I've looked at the log, but I can, next time, if you're interested :)
<old>rlb I'm sure you have plenty of other patches to merge, but if you have time for this: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=79415
<old>I've just sent it today. Nothing urgent I think, but since new bugs fixed version is coming I figured it could be nice to have
<rlb>old: ok, I'll plan to take a look -- might depend on how familiar I am with whatever the relevant bits are; thanks.
<old>ty
<rlb>Pushed the array-fill!, make-struct/no-tail, and test-suite reporter fixes to main.
<dsmith>rlb, So that HTTP attack test spawns off a guile repl and then sends an HTTP GET request to it?
<rlb>No idea -- only looked at it enough to know that I was likely to have to delve a good bit to figure it out.
<dsmith>heh ok
<dsmith>rlb, So, never fails for me. And yes, it's shoving an http get into the repl.
<dsmith>Running with -j$(($(nprocs) +1))
<rlb>here I can go a while without a failure, and then fairly frequently...
<rlb>No idea if the particular -j level matters...
<dsmith>Well, at least one more than nprocs should cause something to wait a bit somewhere.
<dsmith>rlb, And of course it never happens when run individually?
<rlb>As far as I've noticed, but I nearly always run with -j
<dsmith>Hmm..
<dsmith>That "broken pipe" message must be coming from the test harness, not the spawned repl. So the repl must have already exited, or maybe never started.
<dsmith>Or not started yet?
<dsmith>rlb, The guile-test script could examine the MFLAGS env var for "-S" (which means "cancel a previous -k flag") and then always return a success exit code.
<dsmith>Think of -S as "always print a summary"...
<dsmith>Assuming GNU Make. Which is already assumed.
<old>Hopefully I'm not breaking a flow of patches review here
<old>but I'm wondering if Guile can be bootstrap in a minimal way. Like just compiling a single C file
<old>in other words, is it possible to have a minimal Guile that can be bootstrapped with only a C toolchain?
<dsmith>rlb, As in https://bpa.st/V6ZA
<dsmith>old, As in no ./configure and friends?
<old>dsmith: ya
<old>assuming we have a build system entirely written in Guile that can compile guile itself somehow
<elb>dthompson: I'm banging up against a problem I've had several times in Haunt, and before I start hacking up a solution, I wanted to check and see if there's already something. I'd like to associate metadata with _any_ page, not just a blog post, so that I can use it in my theme engine. However, it looks like the only thing a layout function gets is site, which has only default metadata.
<elb>dthompson: is there a handy way to thread arbitrary metadata (e.g., metadata at the top of a commonmark file) through so that I can use it in the layout function of a theme
<elb>(that is, a theme function such as is called by flat-pages or the blog)
<dthompson>elb: the latest code in master has that for flat pages
<dthompson>ACTION needs to release 0.4.0