IRC channel logs

2024-04-22.log

back to list of logs

<benjaminl>does guile make any forward-compatibility guarantees for the standard library's RNG? Specifically, if I seed random-state with a particular value, should I expect to get the same sequence from 'random' in future versions?
<tonyg>ooh i'm delighted i think i have a viable patch for the weird atomics bug on aarch64
<tonyg>(two actually, but one is more conservative)
<tonyg>wingo: you may be interested: https://github.com/wingo/fibers/issues/83#issuecomment-2068847127
<wingo>tonyg: the problem being in core fibers rather than channels sounds about right to me tbh
<wingo>ACTION goes to apply some patches ;)
<tonyg>wingo: I'm weirded out by the effectiveness and "it shouldn't have worked"ness of the move-the-branch-target patch
<wingo>i am wondering if the movr is not idempotent
<wingo>will think about it some more tho :P
<tonyg>wingo: hmmm. oh. hmm. yes if the registers overlapped with some of the registers used in the subsequent instrs
<tonyg>hm. i haven't seen the *actual* machine code generated for any of this
<tonyg>but it would be useful to see it!
<tonyg>is there an environment variable or similar for making it spit out the JIT output?
<wingo>there isn't something to print disassembly, though you can get code ranges. easiest if you have a debug build is to break on swap_atomic and disassemble the bytes that it writes to the buffer
<tonyg>oh you know i think you've got it
<tonyg>the mov isn't idempotent
<tonyg>grr. simple as that
<wingo>aw man
<wingo>ACTION hairshirt
<tonyg>when it comes round to run a second time, the source is already stomped on by the load if dest = val
<henriquelalves>hey peeps! have someone experience integrating RayLib with Guile?
<henriquelalves>I'm new to Guile and I'm creating a little integration for the Lisp Game Jam, but just a simple main loop is segfaulting after a while (probably a memory leak)
<wingo>tonyg: lol look at this garbage https://source.chromium.org/chromium/chromium/src/+/main:v8/src/base/cpu.cc;l=175-207
<wingo>i was trying to check for LSE (https://learn.arm.com/learning-paths/servers-and-cloud-computing/lse/intro/) and it seems the state of the art is much more annoying than cpuid() :P
<tonyg>wingo: oh wow that's grim
<tonyg>i wonder how the gcc out-of-line atomics select which implementation to use
<wingo>i saw https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/making-the-most-of-the-arm-architecture-in-gcc-10; dunno if it is current
<wingo>yeah but dunno what that does under the hood
<tonyg>looks like it interrogates HWCAP_ATOMICS
<henriquelalves>(the project is here: github.com/henriquelalves/SLGJ-2024). Basically, I'm calling an "update" and "draw" method from C (RayLib) to guile, and guile calls RayLib wrapped functions. But it looks like functions are always leaking (specially obvious when I use the "LoadTexture" wrapper, the Finalizers for the wrapper struct are never called)
<henriquelalves>sorry about the long question btw, I don't know what are the IRC customs haha
<tonyg>wingo: https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/aarch64/lse-init.c
<tonyg>henriquelalves: I can't answer your question, but IMO no worries about its length :) welcome
<henriquelalves>tonyg: ah, good to know. thanks!
<chrislck>sneek: botsnack
<sneek>:)
<wingo>tonyg: ok guile from git should have everything in it -- the compilation fix, the retry-branch fix, and the LSE instrs with dynamic feature detection
<tonyg>wingo: wow awesome! i'll take a look
<tonyg>wingo: glorious. builds and runs fine, no atomicity errors in sight.... is a patch release on the horizon or have things drifted a bit far for that?
<wingo>i talked to civodul last week and we are going to try for within 2-3 weeks
<tonyg>woohoo!
<abcdw>wingo: Waiting for this release so much! :)
<henriquelalves>Is there any reason for a segfault when using 'scm_to_stringn' with specific character lenghts?
<henriquelalves>I was testing my simples guile/raylib integration and I'm passing a string to a C method, and converting it with "scm_to_stringn" - but the app throws a segfault whenever the string has a specific lenght (e.g. 0 and 1 char strings crashes; 2 characters don't)
<henriquelalves>more specifically, if I replace it with "scm_to_utf8_stringn", I get a segfault with the string "a", but it's fine with the string "aa"
<henriquelalves>so, there is definetly something with me registering calls with "scm_c_define_gsubr". The problem I had was that a direct C call to a raylib function works, but a call from C to Guile ("scm_call_0") back to C (using a registered "scm_c_make_gsubr") calling a RayLib function makes it segfault with the same arguments
<henriquelalves>no idea what to do from here
<dthompson>henriquelalves: I can't help you with your C problems, sorry, but if you're feeling stuck with that approach I'd recommend binding to raylib from scheme instead using guile's ffi
<henriquelalves>yeah, I'm thinking this might be an alternative
<henriquelalves>I'll just create an MVP of this problem so I can at least work it out if it's a problem of the building process somehow
<dthompson>most of us tend to recommend writing less C (preferably none) and using scheme to call C libraries when needed. all of my game programming stuff has been through the ffi so I know it's feasible.
<dsmith>henriquelalves, Can you paste your code somewhere?
<henriquelalves>dsmith: sure thing, it's here: github.com/henriquelalves/SLGJ-2024 . I'll up the "mvp" of the problem shortly
<henriquelalves>dthompson: it makes sense! I'm just resisting this approach because I wanted to explore C a bit too, and I thought it would be fun to have a small game engine working like that. And problems of the type "it should work" are really annoying
<dthompson>sure, I get it :)
<dthompson>good luck bug hunting
<henriquelalves>thanks! I'll probably go with your suggestion of using ffi if I don't figure this out soon enough
<henriquelalves>dsmith: in case you are interested, I just pushed the MVP of the problem
<henriquelalves>I isolated it to one line to uncomment
<rlb>tomnor: fwiw, regarding variables, here's how you can get hold of one, say from the repl, if you want to: (module-variable (resolve-module '(guile)) 'car) And then variable-ref will get to the actual function it holds.
<dokma>dthompson: what could this be?
<dokma>scheme@(guile-user)> (add-to-load-path "/usr/local/share/guile/site/3.0")
<dokma>scheme@(guile-user)> (use-modules (web socket client))
<dokma>scheme@(guile-user)> (make-websocket "wss://socketsbay.com/wss/v2/1/demo/")
<dokma>ice-9/boot-9.scm:1685:16: In procedure raise-exception:
<dokma>invalid opcode: 12
<dokma>
<dokma>Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
<dokma>
<dokma>(make-websocket "wss://stream.binance.com:9443/ws/btcusdt@kline_1m")
<dokma>doesn't work either
<dokma>guile 3.0.8
<dthompson>dokma: I haven't looked at the websocket spec in years but looking at my code again I see that this error is thrown when a websocket frame has an unsupported opcode
<dthompson>perhaps a new op has been introduced in the years since I wrote the code
<dokma>how old is your code?
<dthompson>either that or the data stream is corrupt
<dthompson>I wrote most of this in 2015 but it's been updated in places since, most notably by flatwhatson last year who was using it.
<dthompson>I've also seen my colleague use it with success within the last month
<dthompson>could it be something about your tls setup? just brainstorming here
<dthompson>the spec doesn't say anything about an opcode 12 https://www.rfc-editor.org/rfc/rfc6455#section-5.2
<dokma>possible...
<dokma>dthompson: guile-websocket uses guile-gnutls ??
<dthompson>dokma: it doesn't depend on it, no
<dokma>dthompson: I have to dig through the code... I don't really understand how guile-websocket works
<dthompson>I'd recommend first getting something working locally that doesn't use tls, to eliminate that as a source of problems
<dokma>dthompson: damn, you're right
<dokma>% websocat -s 127.0.0.1:8080
<dokma>scheme@(guile-user)> (add-to-load-path "/usr/local/share/guile/site/3.0")
<dokma>scheme@(guile-user)> (use-modules (web socket client))
<dokma>scheme@(guile-user)> (make-websocket "ws://127.0.0.1:8080")
<dokma>$1 = #<websocket ws://127.0.0.1:8080 open>
<dokma>
<dokma>This works
<dthompson>everything is more complicated with tls :)
<kaizer>Hey guys, I hope y'all are doing fine. I had a quick question. What is the guile equivalent of list-position from MzScheme?
<kaizer>I'm working through Dorai's Teach Yourself Scheme in Fixnum Days and I'm having compatibility problems with some procedures
<kaizer>Also, generally, some guidance on how to solve these compatibility problems would be well appreciated. I gather that in principle all the different "families" are related but when I'm working through a book, sometimes they are not and I'm not sure whether its just a naming issue or they are just not supported. Thanks