Re: [Chicken-hackers] [PATCH] Move `quit' into (chicken repl)
On Thu, Jul 27, 2017 at 09:21:58AM +1200, Evan Hanson wrote: > Per Felix and Peter's recent proposal. Thanks, pushed. Cheers, Peter signature.asc Description: PGP signature ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Add chicken.blob module
On Thu, Jul 27, 2017 at 09:24:13AM +1200, Evan Hanson wrote: > Per Felix and Peter's recent proposal. Pushed, thanks! Cheers, Peter signature.asc Description: PGP signature ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] Add chicken.plist module
On Thu, Jul 27, 2017 at 05:15:07PM +1200, Evan Hanson wrote: > Again per Felix and Peter's proposal. Note that this patch is based on > the one that moves 'quit' to chicken.repl (to avoid conflicts), so that > one will need to be applied first. Thanks again, pushed! Cheers, Peter signature.asc Description: PGP signature ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH] correct size calculation for ffi return types
On Mon, Jul 31, 2017 at 06:31:28PM +0200, lemonboy wrote: > Hello hackers, > I managed to stumble across this nasty compiler bug while trying to figure out > why some code was segfaulting in a FFI stub. It turns out that I forgot to > place > a define-foreign-type form before the lines the type was referenced in and the > compiler happily assumed it had size 0 and skipped the generation of the > scratch > space buffer. > Here's a simple patch, I'm not too fond of the catch-all case but it shouldn't > be a problem (the `make check` shows no regression). Like I said on IRC, I'm not quite sure what to do with this one. A similar fix is already part of CHICKEN 5 (5bc3b2d25768f9bd89bafa3b9dd4b85376b0c10a), see http://lists.gnu.org/archive/html/chicken-hackers/2017-06/msg00081.html We could apply the error part to master too, but I don't know what kind of breakage it will cause. I know it's buggy and probably stupid and unsafe to leave it, but I'm not sure it's worth risking potentially massive breakage of existing code that already works. What do the other hackers think? Cheers, Peter signature.asc Description: PGP signature ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH][5] Minor srfi-4 fixes
On Sat, Jul 29, 2017 at 09:57:45AM +0200, lemonboy wrote: > Hello hackers, > I found and fixed two small problems in the srfi-4 module, here's a patch > (made > against the chicken-5 branch, it should be easily backported to master if > needed) that also includes some tests. Very nice, here's a signed-off copy of the patch. Thanks! Applying the safe fixnum calculation stuff to master: might be worthwhile, what do the other hackers think? Cheers, Peter From d5290595ecdc82ecc6763aa72e22ff061cd4034d Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 29 Jul 2017 09:54:01 +0200 Subject: [PATCH] Minor fixes in the srfi-4 module * subs64vector used the wrong element length (4 instead of 8) * Make sure the N parameter given to the make-NNvector is a fixnum, do not forcibly coerce it to a fixnum before doing so. Raise an error if the calculated vector length overflows. Signed-off-by: Peter Bex --- srfi-4.scm | 47 --- tests/srfi-4-tests.scm | 28 2 files changed, 52 insertions(+), 23 deletions(-) diff --git a/srfi-4.scm b/srfi-4.scm index 14c0f080..112837b8 100644 --- a/srfi-4.scm +++ b/srfi-4.scm @@ -80,6 +80,7 @@ EOF (import scheme chicken) (import chicken.bitwise + chicken.fixnum chicken.foreign chicken.gc chicken.platform @@ -367,16 +368,18 @@ EOF (foreign-lambda* void ((scheme-object bv)) "C_free((void *)C_block_item(bv, 1));") ) (alloc - (lambda (loc len ext?) - (##sys#check-fixnum len loc) - (when (fx< len 0) (##sys#error loc "size is negative" len)) - (if ext? - (let ((bv (ext-alloc len))) - (or bv - (##sys#error loc "not enough memory - cannot allocate external number vector" len)) ) - (let ((bv (##sys#allocate-vector len #t #f #t))) ; this could be made better... - (##core#inline "C_string_to_bytevector" bv) - bv) ) ) ) ) + (lambda (loc elem-size elems ext?) + (##sys#check-fixnum elems loc) + (when (fx< elems 0) (##sys#error loc "size is negative" elems)) + (let ((len (fx*? elems elem-size))) + (unless len (##sys#error "overflow - cannot allocate the required number of elements" elems)) + (if ext? + (let ((bv (ext-alloc len))) + (or bv + (##sys#error loc "not enough memory - cannot allocate external number vector" len)) ) + (let ((bv (##sys#allocate-vector len #t #f #t))) ; this could be made better... + (##core#inline "C_string_to_bytevector" bv) + bv) ) ) ) )) (set! release-number-vector (lambda (v) @@ -386,7 +389,7 @@ EOF (set! make-u8vector (lambda (len #!optional (init #f) (ext? #f) (fin? #t)) - (let ((v (##sys#make-structure 'u8vector (alloc 'make-u8vector len ext? + (let ((v (##sys#make-structure 'u8vector (alloc 'make-u8vector 1 len ext? (when (and ext? fin?) (set-finalizer! v ext-free)) (if (not init) v @@ -398,7 +401,7 @@ EOF (set! make-s8vector (lambda (len #!optional (init #f) (ext? #f) (fin? #t)) - (let ((v (##sys#make-structure 's8vector (alloc 'make-s8vector len ext? + (let ((v (##sys#make-structure 's8vector (alloc 'make-s8vector 1 len ext? (when (and ext? fin?) (set-finalizer! v ext-free)) (if (not init) v @@ -410,7 +413,7 @@ EOF (set! make-u16vector (lambda (len #!optional (init #f) (ext? #f) (fin? #t)) - (let ((v (##sys#make-structure 'u16vector (alloc 'make-u16vector (##core#inline "C_fixnum_shift_left" len 1) ext? + (let ((v (##sys#make-structure 'u16vector (alloc 'make-u16vector 2 len ext? (when (and ext? fin?) (set-finalizer! v ext-free)) (if (not init) v @@ -422,7 +425,7 @@ EOF (set! make-s16vector (lambda (len #!optional (init #f) (ext? #f) (fin? #t)) - (let ((v (##sys#make-structure 's16vector (alloc 'make-s16vector (##core#inline "C_fixnum_shift_left" len 1) ext? + (let ((v (##sys#make-structure 's16vector (alloc 'make-s16vector 2 len ext? (when (and ext? fin?) (set-finalizer! v ext-free)) (if (not init) v @@ -434,7 +437,7 @@ EOF (set! make-u32vector (lambda (len #!optional (init #f) (ext? #f) (fin? #t)) - (let ((v (##sys#make-structure 'u32vector (alloc 'make-u32vector (##core#inline "C_fixnum_shift_left" len 2) ext? + (let ((v (##sys#make-structure 'u32vector (alloc 'make-u32vector 4 len ext? (when (and ext? fin?) (set-finalizer! v ext-free)) (if (not init) v @@ -446,7 +449,7 @@ EOF (set! make-u64vector (lambda (len #!optional (init #f) (ext? #f) (fin? #t)) - (let ((v (##sys#make-structure 'u64vector (alloc 'make-u64vector (##core#inline "C_fixnum_shift_left" len 3) ext? + (let ((v (##sys#make-structure 'u64vector (alloc 'make-u64vector 8 len ext? (when (and ext? fin?) (set-finalizer! v ext-free)) (if (not init) v @@ -458,7 +461,7 @@ EOF (set! make-s32vector (lambda (len #!optional (init #f) (ext? #f) (fin? #t)) - (let ((v (##sys#make-structur
Re: [Chicken-hackers] [PATCH] correct size calculation for ffi return types
> On Mon, Jul 31, 2017 at 06:31:28PM +0200, lemonboy wrote: > > Hello hackers, > > I managed to stumble across this nasty compiler bug while trying to figure > > out > > why some code was segfaulting in a FFI stub. It turns out that I forgot to > > place > > a define-foreign-type form before the lines the type was referenced in and > > the > > compiler happily assumed it had size 0 and skipped the generation of the > > scratch > > space buffer. > > Here's a simple patch, I'm not too fond of the catch-all case but it > > shouldn't > > be a problem (the `make check` shows no regression). > > Like I said on IRC, I'm not quite sure what to do with this one. A similar > fix is already part of CHICKEN 5 (5bc3b2d25768f9bd89bafa3b9dd4b85376b0c10a), > see http://lists.gnu.org/archive/html/chicken-hackers/2017-06/msg00081.html > > We could apply the error part to master too, but I don't know what kind > of breakage it will cause. I know it's buggy and probably stupid and > unsafe to leave it, but I'm not sure it's worth risking potentially massive > breakage of existing code that already works. > > What do the other hackers think? When in doubt, I'd leave C4 as it is. felix ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH][5] Minor srfi-4 fixes
> On Sat, Jul 29, 2017 at 09:57:45AM +0200, lemonboy wrote: > > Hello hackers, > > I found and fixed two small problems in the srfi-4 module, here's a patch > > (made > > against the chicken-5 branch, it should be easily backported to master if > > needed) that also includes some tests. > > Very nice, here's a signed-off copy of the patch. Thanks! > > Applying the safe fixnum calculation stuff to master: might be worthwhile, > what do the other hackers think? When in doubt... well, you know what I mean. felix ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers
Re: [Chicken-hackers] [PATCH][5] Minor srfi-4 fixes
Looks good, applied to chicken-5. As Felix says, I've left master alone. Thanks much, Evan ___ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers