These are chat archives for fourthbit/spheres

13th
Dec 2015
nortiero
@nortiero
Dec 13 2015 10:22

Hello! I'm having a curious problem with c structures. Here is a snippet:

(load (spheres/sdl2 sdl2))

(define (useless x) x)

(let ((xoxo (alloc-SDL_Color)))
    (SDL_Color-r-set! xoxo #xff)
    (SDL_Color-g-set! xoxo #xff)
    (SDL_Color-b-set! xoxo #xff)
    (let loop ()
        (useless (*->SDL_Color xoxo))
        (loop)))

*->SDL_Color segfaults dereferencing a null pointer. It seems to me that xoxo gets garbage collected.
It happens, sooner or later, depending on memory pressure..
The only way to avoid this is to copy it (for example with another (let ((clone xoxo)) .. ) and then using the copy.
Is this the expected behavior?

Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:25
No, I don't think that's expected...
nortiero
@nortiero
Dec 13 2015 10:26
If you can give me a hint i can look at it
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:26
I plan on getting back to spheres and fix any outstanding issues, but that won't happen until I finish current project (1-2 months).
Meanwhile, you can try to fix that yourself. I recommend the following approaches:
  • Expand these macros, to see the produced code.
  • Use a will to print a line when the object is removed
  • Try with a structure defined in your own, that prints some debugging info when alloc'ed and freed. Look into the SDL bindings for that.
nortiero
@nortiero
Dec 13 2015 10:29
fine, i will look into it and leave an issue. thx!
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:29
I understand is an important thing. If you really try and this is a blocker for you, and you are building something for real with this, I can try to get into it next week.
nortiero
@nortiero
Dec 13 2015 10:30
don't worry it's a funny side project with gambit and sdl2
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:30
:)
nortiero
@nortiero
Dec 13 2015 10:30
you are making an outstanding work with that library spheres
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:30
I'm glad you are using, I hope spheres can be useful to you!
nortiero
@nortiero
Dec 13 2015 10:30
having modularity inside gambit would help a lot, btw
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:30
Yes...
Actually, the next big project I'd love to get into is to really fix the modules+macros once and for all
now is just a hack.
I would expect bugs in that area
But not in FFI, that should be rock solid.
nortiero
@nortiero
Dec 13 2015 10:31
hic sunt leones
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:32
Definitely... I've fought them before
:fire: :fire:
nortiero
@nortiero
Dec 13 2015 10:32
there is a define-library but it's not complete, i see. no let-syntax for example
scsc overwrites "import"
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:32
Yes, and no hygiene at all
nortiero
@nortiero
Dec 13 2015 10:33
a full r7rs compliant module system would be a boon.
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:33
It's a bit of a mess anyway... Also blackhole doesn't get to the bottom of it, and latest version is unfinished spaghetti code
yes! That's what I'm aiming at
As soon as I finish current projects, I'd like to get into that
Let's see...
But I can be confident of fixing the issues... Not that confident of having all the time necessary for the macro system ;)
nortiero
@nortiero
Dec 13 2015 10:34
yes i have been trying them all. no way. i'd love to help but thats outside my comfort zone
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:34
I've tried all too ;)
Nothing perfect
Nobody wants to fix this, but everybody considers it important
We'll get there
nortiero
@nortiero
Dec 13 2015 10:35
i see. gambit community is small, methinks.
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:35
super small, and a individualistic
Everybody thinks his/her solution is better
It's a snob language ;)
Me included ;D
nortiero
@nortiero
Dec 13 2015 10:36
sad, because it's a pretty brisky environment
compiled code is quite fast
and the numeric tower is well made (i suppose). a lot of value
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:37
I'm using Clojure in production now and I think while it has some awesome things, Gambit is still superior
to be honest, if you want to help the community and Spheres in particular, there is one thing you can do
nortiero
@nortiero
Dec 13 2015 10:38
i'm hearing..
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:38
That project you are building, if you show some of your progress, or once it is finished you show it in schemespheres.org
That would show that it actually helps to build stuff
I've done little apps, completely cross platform with Gambit, but they were just tests, and unfortunately they were using the old Spheres, so I would have to rebuild them
They were showing how easy is to build for Android/iOS/desktops with live coding even
I want to show those examples in the web, but if you have anything that can be shown, it would be awesome
nortiero
@nortiero
Dec 13 2015 10:40
yes i've noticed. i will try to do my best. unfortunately lack of high level documents make it very hard -- and all of scheme in general
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:43
yes, I know
Improving documentation is definitely something I don't have time to do... but what I can start doing as soon as I come back is to improve in-code documentation and get the generator to work, to produce browsable documents of that
nortiero
@nortiero
Dec 13 2015 10:44
that would be wonderful. have to go, will check the memory issue, maybe it's unrelated or a hairy bug. thank you for the advice !!!
Álvaro Castro-Castilla
@alvatar
Dec 13 2015 10:47
thanks!