IRC channel logs

2024-12-24.log

back to list of logs

<dsmith>lechner, I would hazard a guess that you are the first to call into libguile from Rust.
<dsmith>lechner, The man page for madvise lists about 7 different reasons to return EINVAL. Maybe an strace will reveal more. Like not page aligned or something.
<dsmith>s/reveal more./ reveal more information as to why.
<lechner>Arsen / dsmith / Well, I just continued to use Greetd, which is written in Rust, after I converted my system to Guile-PAM. There is no such error in Mingetty. Maybe Rust's and Guile's memory management conflict?
<lechner>dsmith / Thanks for the strace hint. Due to Greetd's design I have been unable to provoke the error in a terminal.
<lechner>Arsen / There is are two crates, I think, but I don't know any Rust. https://lib.rs/crates/rust-guile https://github.com/guile-rs/guile-rs
<dsmith>lechner, Woah! Interesting!
<dsmith>After mainly working with C for about 40 years, I'm really digging Rust
<Arsen>lechner: no, rusts memory management is RAII
<Arsen>by crate I mean MRE rust project that hits the madvicse
<Arsen>madvise*
<lechner>My Guile-PAM only has 520 lines, so I can probably narrow it down
<lechner>dsmith / i also like the idea of Rust, but I don't think I really have the energy to learn it. I've looked at Zig as a compromise
<lechner>Hi, can changes to GUILE_LOAD_PATH and GUILE_EXTENSIONS_PATH take effect in a running Guile session?
<lechner>running Guile script, really
<dsmith>Check out %load-path and add-to-load-path
<lechner>dsmith / thanks!
<dsmith> https://www.gnu.org/software/guile/manual/html_node/Load-Paths.html
<dsmith>Also: https://www.gnu.org/software/guile/manual/html_node/Foreign-Libraries.html#index-guile_002dextensions_002dpath
<lechner>Thanks! How about GUILE_EXTENSIONS_PATH? Is that limited like LD_LIBRARY_PATH?
<lechner>dsmith / thanks!
<dsmith>Guile's .go file are elf format. Pretty sure they are mmap'ed into place. madvise is probably used to enable code execution or something.
<dsmith>And disagreements between Rust and Guile memory management seem likely to be the culprit.
<dsmith>But I'm certainly no expert here.
<dsmith>lechner, Please report back if/when you get to the bottom of it!
<lechner>Okay, I will. Does anyone know what 'madvise' does? It frees entire pages?
<dsmith>It's a system call that gives clues to the kernel about how the pages in the region are to be used.
<dsmith>lechner, man madvise
<lechner>dsmith / okay, thanks! i've read that manual page up a down but know too little about any memory management system
<dsmith>Hmm. It may be Guile uses madvise to return unused pages back to the system.
<lechner>yeah, that's what i think
<dsmith>rg for it in the Guile src and see where/how it's called.
<lechner>yeah, it's one call
<lechner>i just really don't know what it does, and there is nothing to do without strace
<dsmith>Yeah, looks like it's being used to free memory
<lechner>i'll report back if I can spin up Rust, but on Guix that's a major undertaking I think
<dsmith>MADV_DONTNEED "Do not expect access in the near future. (For the time being, the application is finished with the given range, so the kernel can free resources associated with it.)"
<dsmith>(From the man page)
<lechner>Yeah, it seems like such an odd thing to take the kernel. My guess Guile is not using malloc and friends, but i'm really in hot water. I don't understand RAII and MRE makes me think of Chicken a la King in the US Army. https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization
<lechner>to tell the kernel
<dsmith>Well, usually when a program aquires memory resources from the kernel, they pretty much stay, even if unused. So while calling "free" returns the memory so it can be later allocated again, it does NOT return it to the system for other progs to use.
<dsmith>The madvise allows the kernel to basicially reduce the memory footprint of the running program.
<dsmith>I vaguely remember wingo mentioning madvise in his blog or an email or something.
<lechner>dsmith / okay, thanks!
<dsmith>Hah! Check this out: https://logs.guix.gnu.org/guile/2014-01-31.log#201931
<dsmith>20 years ago!
<dsmith>s/20/10/
<lechner>dsmith / thanks! you have excellent memory! i'll save that URL for a code comment when I figure it out, or maybe for the manual
<lechner>Hi, anyone have elegant code to deal with PATH variables, i.e. for splitting and "intercalating" in Haskell lingo?
<daviid>lechner not sure it is elegant, but if it may help, i use this in my grip toolbox - https://bpa.st/EGCQ
<daviid>lechner oh, you did mean PATH as the env var ... sorry i missunderstood ...
<daviid>guix must probably have what you're looking for though ...
<efraim>sneek: later tell rlb tried the build again with the 0008 patch and after 44 hours failed the test-out-of-memory test, so I'm counting that as working
<sneek>Will do.
<efraim>sneek: botsnack
<sneek>:)
<rlb>Yeah, that one failed regularly for me too on perotto, and iirc we've long marked it as "expected to fail" in the debian patches atm.
<sneek>Welcome back rlb, you have 1 message!
<sneek>rlb, efraim says: tried the build again with the 0008 patch and after 44 hours failed the test-out-of-memory test, so I'm counting that as working
<efraim>we skip it in guix on all powerpc architectures
<rlb>I wonder if we might want something (likely more sophisticated than) that patch in guile proper...
<rlb>Though if you have to bootstrap for it to work (don't know offhand), we'd need additional complexity (or even just instructions) for the affected archs (only powerpc atm, afaik).
<rlb>and I mean wrt the compilation fix, not the test issue (though suppose that's another hazard)
<rlb>for someone trying to build
<AwesomeAdam54321>Hi, are there any recommendations in using getopt-long in Guile that go unstated in the manual?
<AwesomeAdam54321>I'm wondering if there's a way to parse command-line options with less boilerplate
<AwesomeAdam54321>Since getopt-long can't set a default value for each option, it has to be done with every call to option-ref
<AwesomeAdam54321>When a program has lots of command-line options, it becomes unwieldy to have lots of variables specifically for each command-line option, with a default if it's not given
<AwesomeAdam54321>At that point all initialised command-line option values have to be stored in a new data structure like an SRFI-9 record or a hash table, duplicating the option-spec
<AwesomeAdam54321>The list of options ends up being duplicated 3 times in my case, one in the option-spec, having to specify an equivalent options record, and then initialising an instance of the options record with (option-ref options key default) for every command-line option
<mwette>AwesomeAdam54321: mayby try srfi-37 instead of getopt-long
<mwette>I haven't used getopt-long in years, so probably can't help with that, sorry. Most folks here are using srfi-37.
<lechner>daviid / thanks!
<lechner>Hi, I'm not sure I like the dots in Alists, after all. Is there a name for doing the same thing without the dots (i.e. with more 'cadr')?
<dsmith>lechner, Check out srfi-1 for lists and srfi-13 for strings (splitting and "intercalating")
<dsmith>scheme@(guile-user)> (string-join '("foo" "bar" "baz") "/" 'prefix)
<dsmith>$1 = "/foo/bar/baz"
<dsmith> https://www.gnu.org/software/guile/manual/html_node/String-Constructors.html#index-string_002djoin
<lechner>dsmith / Thanks for the joining help! As for splitting, I worry about colons in PATH components.
<dsmith>As in <cluck> something like a css properties viewer would likely work
<dsmith>As in https://www.gnu.org/software/guile/manual/html_node/List_002fString-Conversion.html#index-scm_005fstring_005fsplit
<dsmith>scheme@(guile-user)> (string-split "/bin:/sbin:/usr/bin:/usr/sbin" #\:)
<dsmith>$1 = ("/bin" "/sbin" "/usr/bin" "/usr/sbin")
<lechner>dsmith / thanks!
<dsmith>OR parse-path or parse-path-with-ellipsis
<lechner>dsmith / thanks, parse-path is great!
<lechner>Hi, is %global-site-dir in %load-path still a thing?
<lechner>Also, what are those parenthesis doing inside, please? (list (%library-dir) (%site-dir) (%global-site-dir) (%package-data-dir))
<AwesomeAdam54321>mwette: Thanks!
<AwesomeAdam54321>I'll stick with getopt-long for now, I'll keep the SRFI-37 suggestion in mind if I feel the need to switch
<AwesomeAdam54321>s/I'll keep/though I'll keep
<daviid>lechner all those 'inside' are procedures