Re: Chicken git egg: bug & patch

2021-06-15 Thread Evan Hanson
Hi there, Just to follow up on this, these issues have been fixed in version 0.2.0 of this egg. Thank you Kristian and megane for the helpful discussion! This is a good use case for (strong) locatives since they can be handled just like pointers by the FFI but still hook memory up to the GC. Eva

Re: Chicken git egg: bug & patch

2021-06-14 Thread Kristian Lein-Mathisen
Hi Megane, Like Evan says, the libgit2 project doesn't keep your pointers around so that should be safe. But thanks for pointing that out, errors caused by these things are very hard to track down. I'd actually never thought about a off-gc memory heap before. That is a very interesting idea! I'm

Re: Chicken git egg: bug & patch

2021-06-14 Thread Evan Hanson
I think we can probably just use blobs and locatives to keep things simple, without needing to involve finalizers or similar tricks. This library is pretty good about leaving memory management up to the client, and they provide an object for indirection (the git_buf) when that's not possible. I'll

Re: Chicken git egg: bug & patch

2021-06-14 Thread megane
Kristian Lein-Mathisen writes: > Hi, > > Indeed. We could malloc and set-finalizer! and that should work and be > safe. However, as far as I understand, this approach has some disadvantages: > > - malloc is relatively slow compared to chicken's internal allocation (eg > make-string) that uses t

Re: Chicken git egg: bug & patch

2021-06-13 Thread Kristian Lein-Mathisen
Hi, Indeed. We could malloc and set-finalizer! and that should work and be safe. However, as far as I understand, this approach has some disadvantages: - malloc is relatively slow compared to chicken's internal allocation (eg make-string) that uses the stack - there is a practical limit on finali

Re: Chicken git egg: bug & patch

2021-06-13 Thread megane
Kristian Lein-Mathisen writes: > From what I gather, there is no way to allocate memory and return a pointer > to it, safely, in CHICKEN. > Won't the garbage collector potentially overwrite whatever region was > allocated since it has no way of knowing it? There's allocate from chicken.memory

Re: Chicken git egg: bug & patch

2021-06-13 Thread Kristian Lein-Mathisen
Hi Evan, And thanks for getting back to me. I found another problem related to memory corruption and I've been digging around. I have patches for that too, but I don't know if they suffice. They sort of break existing conventions of everything in libgit2 being foreigners and c-pointers. I'm attac

Re: Chicken git egg: bug & patch

2021-06-13 Thread Evan Hanson
Hi Kristian, On 2021-06-12 15:36, Kristian Lein-Mathisen wrote: > I think I may have come across a bug in the git egg. You're right! THanks for pointing this out, I guess you must be the first person to use that `frombuffer` procedure. Everything you've said looks correct to me, I'll try to publ

Chicken git egg: bug & patch

2021-06-12 Thread Kristian Lein-Mathisen
Hi! I think I may have come across a bug in the git egg. klm@pisa ~/.c/chicken-install> chicken-status | grep git git . version: 0.1.0 klm@pisa ~/.c/chicken-install> csi -R git -P '(define r (create-repository "/tmp/repo")) (create-blob r #