bug#54198: Guile 3.0.8 cross-compiled to i586-pc-gnu crashes

2022-02-28 Thread Ludovic Courtès
Hi,

Guix’s Guile 3.0.8 package cross-compiled to i586-pc-gnu (GNU/Hurd)
crashes when starting (3.0.7 was fine):

--8<---cut here---start->8---
ludo@childhurd ~$ 
/gnu/store/19dfmmsy41614n9nxkbpn73sr8xhccqy-guile-3.0.7/bin/guile --version
guile (GNU Guile) 3.0.7
Copyright (C) 2021 Free Software Foundation, Inc.

License LGPLv3+: GNU LGPL 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
ludo@childhurd ~$ 
/gnu/store/hh72mzfk2h4ss5rnzhbhycdibb8qy8wi-guile-3.0.8/bin/guile --version
Pre-boot error; key: out-of-range, args: (#f "Value out of range ~S to< ~S: ~S" 
(0 -1 1) (1))Aborted
ludo@childhurd ~$ gdb --args guile --version
GNU gdb (GDB) 11.1

[...]

Pre-boot error; key: out-of-range, args: (#f "Value out of range ~S to< ~S: ~S" 
(0 -1 1) (1))
Thread 4 received signal SIGABRT, Aborted.
0x015080cc in mach_msg_trap () at 
/tmp/guix-build-glibc-cross-i586-pc-gnu-2.33.drv-0/build/mach/mach_msg_trap.S:2
2   
/tmp/guix-build-glibc-cross-i586-pc-gnu-2.33.drv-0/build/mach/mach_msg_trap.S: 
No such file or directory.
(gdb) bt
#0  0x015080cc in mach_msg_trap () at 
/tmp/guix-build-glibc-cross-i586-pc-gnu-2.33.drv-0/build/mach/mach_msg_trap.S:2
#1  0x015087fa in __GI___mach_msg (msg=0x1038880, option=3, send_size=48, 
rcv_size=32, rcv_name=125, timeout=0, 
notify=0) at msg.c:111
#2  0x0176824e in __msg_sig_post (process=122, signal=0, sigcode=0, refport=1)
at 
/tmp/guix-build-glibc-cross-i586-pc-gnu-2.33.drv-0/build/hurd/RPC_msg_sig_post.c:149
#3  0x015291ea in __GI__hurd_raise_signal (ss=, signo=6, 
detail=0x103891c) at hurd-raise.c:56
#4  0x011f8c93 in __pthread_kill (thread=1, sig=6) at 
../sysdeps/hurd/htl/pt-kill.c:49
#5  0x01552e47 in __GI_raise (signo=6) at ../sysdeps/htl/raise.c:38
#6  0x01507e29 in __GI_abort () at abort.c:79
#7  0x010f2750 in scm_throw (key=0x20202e0, args=0x2047000) at throw.c:260
#8  0x010f27ce in scm_ithrow (key=0x20202e0, args=0x2047000, no_return=1) at 
throw.c:457
#9  0x01074fc8 in scm_error_scm (key=0x20202e0, subr=0x4, message=0x2046090, 
args=0x2047020, data=0x2047038)
at error.c:90
#10 0x0107502b in scm_error (key=0x20202e0, subr=0x0, message=0x1129cac "Value 
out of range ~S to< ~S: ~S", 
args=0x2047020, rest=0x2047038) at error.c:62
#11 0x010b68dc in range_error (bad_val=bad_val@entry=0x6, min=0x2, 
max=max@entry=0xfffe) at numbers.c:6611
#12 0x010b6b8f in inum_in_range (max=-1, min=0, x=0x6) at numbers.c:6630
#13 scm_to_uint32 (arg=0x6) at numbers.c:6787
#14 0x0109c1d0 in scm_make_list (n=0x6, init=0x20460a0) at list.c:113
#15 0x010806a1 in make_exp_vtable (n=0) at expand.c:1602
#16 scm_init_expand () at expand.c:1650
#17 0x01095211 in scm_i_init_guile (base=) at init.c:475
#18 0x010f1268 in scm_i_init_guile (base=0x1038cbc) at init.c:357
#19 scm_i_init_thread_for_guile.part.0.lto_priv.0 (base=0x1038cbc, 
dynamic_state=0x0) at threads.c:570
#20 0x010f037b in scm_i_init_thread_for_guile (dynamic_state=0x0, 
base=0x1038cbc) at threads.c:677
#21 with_guile (base=0x1038cbc, data=0x1038ce4) at threads.c:638
#22 0x011a51f4 in GC_call_with_stack_base ()
   from /gnu/store/y62sfzpnw3r7i5c0k4aqq9cy9c6hkr2g-libgc-8.0.4/lib/libgc.so.1
#23 0x010e8cda in scm_i_with_guile (dynamic_state=, 
data=0x1038d10, func=0x1088f40 )
at threads.c:688
#24 scm_with_guile (func=0x1088f40 , data=0x1038d10) at 
threads.c:694
#25 0x01092400 in scm_boot_guile (argc=2, argv=0x1038df4, main_func=0x80492b0 
, closure=0x0) at init.c:295
#26 0x0804911a in main (argc=2, argv=0x1038df4) at guile.c:94
--8<---cut here---end--->8---

The build process of Guile changed upstream to become multi-stage, in
support of cross-module inlining.  A possibility is that that somehow
ends up generating .go files with the wrong word size (although that
should prevent them from being loaded).  Or maybe it’s some interference
with the native Guile that’s being used.

Ludo’.





bug#54172: [PATCH] vectors: add (vector-last) support

2022-02-26 Thread Aleix Conchillo Flaqué
* libguile/vectors.c: add (vector-last) support.

* libguile/vectors.h: define scm_vector_last and scm_c_vector_last.

* doc/ref/api-data.texi (Vector Accessors): add documentation for
(vector-last).
---
 doc/ref/api-data.texi | 10 ++
 libguile/vectors.c| 30 +-
 libguile/vectors.h|  6 --
 test-suite/tests/srfi-43.test | 12 +++-
 4 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 8658b9785..cf7253b31 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -6277,6 +6277,16 @@ Return the contents of position @var{k} (a 
@code{size_t}) of
 @var{vec}.
 @end deftypefn
 
+@rnindex vector-last
+@deffn {Scheme Procedure} vector-last vec
+@deffnx {C Function} scm_vector_last (vec)
+Return the contents of the last element of @var{vec}.
+@end deffn
+
+@deftypefn {C Function} SCM scm_c_vector_last (SCM vec)
+Return the contents of the last element of @var{vec}.
+@end deftypefn
+
 A vector created by one of the dynamic vector constructor procedures
 (@pxref{Vector Creation}) can be modified using the following
 procedures.
diff --git a/libguile/vectors.c b/libguile/vectors.c
index 18c7dc54d..e5aa297df 100644
--- a/libguile/vectors.c
+++ b/libguile/vectors.c
@@ -188,7 +188,35 @@ scm_c_vector_ref (SCM v, size_t k)
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_vector_set_x, "vector-set!", 3, 0, 0, 
+SCM_DEFINE (scm_vector_last, "vector-last", 1, 0, 0,
+   (SCM vector),
+"@samp{Vector-ref} returns the contents of the last element of\n"
+"@var{vector}.\n\n"
+"@lisp\n"
+"(vector-ref '#(3 1 27 5)) @result{} 5\n"
+"@end lisp")
+#define FUNC_NAME s_scm_vector_last
+{
+  return scm_c_vector_last (vector);
+}
+#undef FUNC_NAME
+
+SCM
+scm_c_vector_last (SCM v)
+#define FUNC_NAME s_scm_vector_last
+{
+  SCM_VALIDATE_VECTOR (1, v);
+
+  size_t len = SCM_I_VECTOR_LENGTH (v);
+
+  if (len == 0)
+scm_out_of_range (NULL, 0);
+
+  return scm_c_vector_ref (v, len - 1);
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_vector_set_x, "vector-set!", 3, 0, 0,
(SCM vector, SCM k, SCM obj),
 "@var{k} must be a valid index of @var{vector}.\n"
 "@code{Vector-set!} stores @var{obj} in element @var{k} of 
@var{vector}.\n"
diff --git a/libguile/vectors.h b/libguile/vectors.h
index 005999a2b..b729e6105 100644
--- a/libguile/vectors.h
+++ b/libguile/vectors.h
@@ -1,7 +1,7 @@
 #ifndef SCM_VECTORS_H
 #define SCM_VECTORS_H
 
-/* Copyright 1995-1996,1998,2000-2002,2004-2006,2008-2009,2011,2014,2018
+/* Copyright 1995-1996,1998,2000-2002,2004-2006,2008-2009,2011,2014,2018,2020
  Free Software Foundation, Inc.
 
This file is part of Guile.
@@ -32,13 +32,14 @@ SCM_API SCM scm_vector_p (SCM x);
 SCM_API SCM scm_vector_length (SCM v);
 SCM_API SCM scm_vector (SCM l);
 SCM_API SCM scm_vector_ref (SCM v, SCM k);
+SCM_API SCM scm_vector_last (SCM v);
 SCM_API SCM scm_vector_set_x (SCM v, SCM k, SCM obj);
 SCM_API SCM scm_make_vector (SCM k, SCM fill);
 SCM_API SCM scm_vector_to_list (SCM v);
 SCM_API SCM scm_vector_fill_x (SCM v, SCM fill_x);
 SCM_API SCM scm_vector_move_left_x (SCM vec1, SCM start1, SCM end1,
SCM vec2, SCM start2);
-SCM_API SCM scm_vector_move_right_x (SCM vec1, SCM start1, SCM end1, 
+SCM_API SCM scm_vector_move_right_x (SCM vec1, SCM start1, SCM end1,
 SCM vec2, SCM start2);
 SCM_API SCM scm_vector_copy (SCM vec);
 SCM_API SCM scm_vector_copy_partial (SCM vec, SCM start, SCM end);
@@ -48,6 +49,7 @@ SCM_API int scm_is_vector (SCM obj);
 SCM_API SCM scm_c_make_vector (size_t len, SCM fill);
 SCM_API size_t scm_c_vector_length (SCM vec);
 SCM_API SCM scm_c_vector_ref (SCM vec, size_t k);
+SCM_API SCM scm_c_vector_last (SCM vec);
 SCM_API void scm_c_vector_set_x (SCM vec, size_t k, SCM obj);
 SCM_API const SCM *scm_vector_elements (SCM array,
scm_t_array_handle *h,
diff --git a/test-suite/tests/srfi-43.test b/test-suite/tests/srfi-43.test
index 554843e75..4d0093974 100644
--- a/test-suite/tests/srfi-43.test
+++ b/test-suite/tests/srfi-43.test
@@ -1,6 +1,6 @@
  srfi-43.test --- test suite for SRFI-43 Vector library -*- scheme -*-
 
- Copyright (C) 2014 Free Software Foundation, Inc.
+ Copyright (C) 2014, 2020 Free Software Foundation, Inc.
 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
@@ -390,6 +390,16 @@
   (pass-if-error "non-vector" (vector-ref '(a b c) 0))
   (pass-if-error "inexact index" (vector-ref '#(a b c) 1.0)))
 
+;;
+;; vector-last
+;;
+
+(with-test-prefix "vector-last"
+  (pass-if-equal "single element" 'a (vector-last '#(a)))
+  (pass-if-equal "multiple elements" 'c (vector-last '#(a b c)))
+  (pass-if-error "empty vector" (vector-last '#()))
+  (pass-if-error "non-ve

bug#54171: [PATCH] web: default to INADDR_ANY instead of INADDR_LOOPBACK

2022-02-26 Thread Aleix Conchillo Flaqué
Using INADDR_ANY instead of INADDR_LOOPBACK makes it convenient when
starting the web server inside containers without the need to having to
specify INADDR_ANY all the time. This is the default in most libraries
and languages.

This doesn't break backwards compatibility since INADDR_LOOPBACK is also
included in INADDR_ANY.

* doc/ref/web.texi (Web Server): update INADDR_LOOPBACK to INADDR_ANY
and related text.

* module/web/server/http.scm (http-open): default to INADDR_ANY for the
web server.
---
 doc/ref/web.texi   | 10 +-
 module/web/server/http.scm |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/doc/ref/web.texi b/doc/ref/web.texi
index 93cd0214f..6b42b8ff6 100644
--- a/doc/ref/web.texi
+++ b/doc/ref/web.texi
@@ -1807,7 +1807,7 @@ socket, listening for request on that port.
 
 @deffn {HTTP Implementation} http [#:host=#f] @
  [#:family=AF_INET] @
- [#:addr=INADDR_LOOPBACK] @
+ [#:addr=INADDR_ANY] @
  [#:port 8080] [#:socket]
 The default HTTP implementation.  We document it as a function with
 keyword arguments, because that is precisely the way that it is -- all
@@ -1815,7 +1815,7 @@ of the @var{open-params} to @code{run-server} get passed 
to the
 implementation's open function.
 
 @example
-;; The defaults: localhost:8080
+;; The defaults: any local IP on port 8080
 (run-server handler)
 ;; Same thing
 (run-server handler 'http '())
@@ -1866,9 +1866,9 @@ handler:
 (run-server hello-world-handler)
 @end example
 
-By default, the web server listens for requests on
-@code{localhost:8080}.  Visit that address in your web browser to
-test.  If you see the string, @code{Hello World!}, sweet!
+By default, the web server listens for requests on port @code{8080}.
+Visit @code{http://localhost:8080} in your web browser to test.  If you
+see the string, @code{Hello World!}, sweet!
 
 @subsubsection Inspecting the Request
 
diff --git a/module/web/server/http.scm b/module/web/server/http.scm
index 05bf46bf0..91354021c 100644
--- a/module/web/server/http.scm
+++ b/module/web/server/http.scm
@@ -1,6 +1,6 @@
 ;;; Web I/O: HTTP
 
-;; Copyright (C)  2010, 2011, 2012, 2015 Free Software Foundation, Inc.
+;; Copyright (C)  2010, 2011, 2012, 2015, 2022 Free Software Foundation, Inc.
 
 ;; This library is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU Lesser General Public
@@ -61,7 +61,7 @@
 (family AF_INET)
 (addr (if host
   (inet-pton family host)
-  INADDR_LOOPBACK))
+  INADDR_ANY))
 (port 8080)
 (socket (make-default-socket family addr port)))
   (listen socket 128)
-- 
2.35.1






bug#54163: guile 3.0.8 'make check' fails

2022-02-26 Thread Vijay Marupudi
> FAIL: test-out-of-memory

It looks like this test has not been very functional for a while, rlb
has marked it as an expected failure for Debian.

Link to his patch:
https://salsa.debian.org/rlb/deb-guile/-/blob/deb/guile-3.0/d/sid/master/debian/patches/0005-Mark-test-out-of-memory-as-an-expected-failure-for-n.patch

~ Vijay





bug#54163: guile 3.0.8 'make check' fails

2022-02-25 Thread Terry Phelps
I just got the 3.0.8 tarball and did a build on Fedora 35 x64. I used no
parameters to 'configure', except for '--prefix'. Then I did 'make' and
'make check'.

One test failed. The output ends with:

wrote
`/home/tgphelps/guile-3.0.8/cache/guile/ccache/3.0-LE-8-4.6/home/tgphelps/guile-3.0.8/test-suite/standalone/test-stack-overflow.go'
allocate_stack failed: Cannot allocate memory
allocate_stack failed: Cannot allocate memory
allocate_stack failed: Cannot allocate memory
allocate_stack failed: Cannot allocate memory
allocate_stack failed: Cannot allocate memory
PASS: test-stack-overflow
wrote
`/home/tgphelps/guile-3.0.8/cache/guile/ccache/3.0-LE-8-4.6/home/tgphelps/guile-3.0.8/test-suite/standalone/test-out-of-memory.go'
GC Warning: Failed to expand heap by 134742016 bytes
GC Warning: Failed to expand heap by 134217728 bytes
GC Warning: Out of Memory! Heap size: 2 MiB. Returning NULL!
error creating finalization thread: Cannot allocate memory
mmap(PROT_NONE) failed
FAIL: test-out-of-memory
======
1 of 40 tests failed
Please report to bug-guile@gnu.org
==

If you want more information, just ask.


bug#54147: [PATCH] doc: fix web (run-server) examples

2022-02-24 Thread Aleix Conchillo Flaqué
* doc/ref/web.texi (Web Server): need quasiquote to in order to evaluate
AF_INET6.
---
 doc/ref/web.texi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/ref/web.texi b/doc/ref/web.texi
index 93cd0214f..49a09d0ca 100644
--- a/doc/ref/web.texi
+++ b/doc/ref/web.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 2010, 2011, 2012, 2013, 2015, 2018, 2019, 2020 Free Software 
Foundation, Inc.
+@c Copyright (C) 2010, 2011, 2012, 2013, 2015, 2018, 2019, 2020, 2022 Free 
Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
 @node Web
@@ -1822,7 +1822,7 @@ implementation's open function.
 ;; On a different port
 (run-server handler 'http '(#:port 8081))
 ;; IPv6
-(run-server handler 'http '(#:family AF_INET6 #:port 8081))
+(run-server handler 'http `(#:family ,AF_INET6 #:port 8081))
 ;; Custom socket
 (run-server handler 'http `(#:socket ,(sudo-make-me-a-socket)))
 @end example
-- 
2.35.1






bug#54143: [PATCH] Add string-split-substring to ice-9 string-fun

2022-02-24 Thread Vijay Marupudi
Hello,

I've attached a patch adding a new function, (string-split-substring str
substr), that splits a string into a list of multiple strings delimited
by a substring. The behavior matches (string-split str char/pred)
exactly.

~ Vijay

>From 3c0940082ff49695ac9c2147c900b959be5f8e70 Mon Sep 17 00:00:00 2001
From: Vijay Marupudi 
Date: Sat, 12 Feb 2022 22:00:57 -0500
Subject: [PATCH] Add string-split-substring

* /ref/api-data.texi: Added documentation
* module/ice-9/string-fun.scm: Added implementation
* test-suite/tests/strings.test: Added tests
---
 doc/ref/api-data.texi | 10 ++
 module/ice-9/string-fun.scm   | 23 ++-
 test-suite/tests/strings.test | 22 +-
 3 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 8658b9785..a5fcc47b1 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -4245,6 +4245,16 @@ Return a new string where every instance of @var{substring} in string
 @end lisp
 @end deffn
 
+@deffn {Scheme Procedure} string-split-substring str substring
+Split the string @var{str} into a list of substrings delimited by the
+appearance of substring @var{substring}. For example:
+
+@lisp
+(string-replace-substring "item-1::item-2::item-3::item-4" "::")
+@result{} ("item-1" "item-2" "item-3" "item-4")
+@end lisp
+@end deffn
+
 @node Representing Strings as Bytes
 @subsubsection Representing Strings as Bytes
 
diff --git a/module/ice-9/string-fun.scm b/module/ice-9/string-fun.scm
index 03e0238fa..a1d4c0366 100644
--- a/module/ice-9/string-fun.scm
+++ b/module/ice-9/string-fun.scm
@@ -26,7 +26,7 @@
 	   separate-fields-before-char string-prefix-predicate string-prefix=?
 	   sans-surrounding-whitespace sans-trailing-whitespace
 	   sans-leading-whitespace sans-final-newline has-trailing-newline?
-   string-replace-substring))
+   string-replace-substring string-split-substring))
 
 
 ;;;
@@ -313,3 +313,24 @@
(else
 (display (substring/shared str start)
 
+(define (string-split-substring str substr)
+  "Split the string @var{str} into a list of substrings delimited by the
+substring @var{substr}."
+
+  (define substrlen (string-length substr))
+  (define strlen (string-length str))
+
+  (define (loop index start)
+(cond
+ ((>= start strlen) (list ""))
+ ((not index) (list (substring str start)))
+ (else
+  (cons (substring str start index)
+(let ((new-start (+ index substrlen)))
+  (loop (string-contains str substr new-start)
+new-start))
+
+  (cond
+   ((string-contains str substr) => (lambda (idx) (loop idx 0)))
+   (else (list str
+
diff --git a/test-suite/tests/strings.test b/test-suite/tests/strings.test
index 7393bc8ec..8bc26e3e3 100644
--- a/test-suite/tests/strings.test
+++ b/test-suite/tests/strings.test
@@ -699,4 +699,24 @@
 
   (pass-if "string-replace-substring"
 (string=? (string-replace-substring "a ring of strings" "ring" "rut")
-  "a rut of struts")))
+  "a rut of struts"))
+
+  (pass-if "string-split-substring - empty string"
+(equal? (string-split-substring "" "foo")
+'("")))
+
+  (pass-if "string-split-substring - non-empty, no delimiters"
+(equal? (string-split-substring "testing" "foo")
+'("testing")))
+
+  (pass-if "string-split-substring - non-empty, delimiters"
+(equal? (string-split-substring "testingfoobar" "foo")
+'("testing" "bar")))
+
+  (pass-if "string-split-substring - non-empty, leading delimiters"
+(equal? (string-split-substring "foobar" "foo")
+'("" "bar")))
+
+  (pass-if "string-split-substring - non-empty, trailing delimiters"
+(equal? (string-split-substring "barfoo" "foo")
+(list "bar" ""
-- 
2.35.1



bug#54142: [PATCH] Add srfi 214 - flexvectors

2022-02-24 Thread Vijay Marupudi
Hello,

I've attached a patch that adds support for dynamic vectors, aka
flexvectors.

Tests and documentation included.

~ Vijay

>From 42206dec4d5e9ae51665c6e98ef07715b89b12fe Mon Sep 17 00:00:00 2001
From: Vijay Marupudi 
Date: Tue, 18 Jan 2022 20:52:08 -0500
Subject: [PATCH] Added srfi-214: flexvectors

Included code, documentation, and tests
---
 doc/ref/api-data.texi  | 842 -
 doc/ref/srfi-modules.texi  |   6 +
 module/Makefile.am |   1 +
 module/srfi/srfi-214.scm   | 735 
 test-suite/Makefile.am |   1 +
 test-suite/tests/srfi-214.test | 437 +
 6 files changed, 2021 insertions(+), 1 deletion(-)
 create mode 100644 module/srfi/srfi-214.scm
 create mode 100644 test-suite/tests/srfi-214.test

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index b6c2c4d61..1ba7b57a9 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -26,7 +26,8 @@ complex.
 * Bit Vectors:: Vectors of bits.
 * Bytevectors:: Sequences of bytes.
 * Arrays::  Multidimensional matrices.
-* VLists::  Vector-like lists.
+* VLists::  Vector-like lists
+* Flexvectors:: Mutable vectors with adjustable size
 * Record Overview:: Walking through the maze of record APIs.
 * SRFI-9 Records::  The standard, recommended record API.
 * Records:: Guile's historical record API.
@@ -8393,6 +8394,845 @@ Return a new vlist whose contents correspond to @var{lst}.
 Return a new list whose contents match those of @var{vlist}.
 @end deffn
 
+@node Flexvectors
+@subsection Flexvectors
+@cindex flexvector
+
+Flexvectors are sometimes better known as a @url{https://en.wikipedia.org/wiki/Dynamic_array,dynamic arrays}. This data
+structure has a wide variety of names in different languages:
+
+@itemize @bullet{}
+
+@item
+JavaScript and Ruby call it an array
+@item
+Python calls it a list
+@item
+Java calls it an ArrayList (and, before that, it was called a Vector)
+
+@end itemize
+
+
+Flexvectors have the same O(1) random-access performance guarantees as
+ordinary vectors. Additionally, appending to the back of a flexvector
+has the same (amortized) performance as setting an existing location in
+the same flexvector.
+
+Functions in this module can be obtained with:
+
+@example
+(use-modules (srfi srfi-214))
+@end example
+
+The material in this section was derived from the
+@url{https://srfi.schemers.org/srfi-214/srfi-214.html,SRFI-214} proposal
+written by Adam Nelson, whose copyright notice is as follows.
+
+@quotation
+(C) Adam Nelson 2020-2021.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+@end quotation
+
+@subsubsection Constructors
+
+@deffn {Scheme Procedure} make-flexvector size [fill]
+
+Creates and returns a flexvector of size @var{size}. If @var{fill} is
+specified, all of the elements of the vector are initialized to
+@var{fill}. Otherwise, their contents are indeterminate.
+
+
+@example
+(make-flexvector 5 3) @result{} #
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} flexvector x ...
+
+Creates and returns a flexvector whose elements are @var{x ...}.
+
+@example
+(flexvector 0 1 2 3 4) @result{} #
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} flexvector-unfold p f g initial-seed ...
+@deffnx {Scheme Procedure} flexvector-unfold-right p f g initial-seed ...
+
+The fundamental flexvector constructor. @code{flexvector-unfold} is
+modeled on SRFI 1 @code{unfold} instead of SRFI 133
+@code{vector-unfold} because flexvectors are not limited to a
+predetermined length.
+
+@example
+;; List of squares: 1^2 ... 10^2
+(flexvector-unfold (lambda (x) (> x 10)) (lambda (x) (* x x)) (lambda (x) (+ x 1)) 1)
+@result{} #
+@end example
+@end deffn
+
+@deffn {Scheme Procedure} flexvector-copy fv [start [end]]
+@deffnx {Scheme Procedure} flexvector-reverse-cop

bug#54141: [PATCH] Allow utf[8/16/32]->string functions to take start and ends bounds

2022-02-24 Thread Vijay Marupudi
Hello,

I have attached a patch that extend the bytevector->string functions to
take an start and end range.

The second patch changes the r7rs compatibility layer to use this new
functionality instead of the making a new bytevector as an intermediate
step.

~ Vijay

>From c6be127b4818d43a0244592c18a52de113d3ff08 Mon Sep 17 00:00:00 2001
From: Vijay Marupudi 
Date: Thu, 20 Jan 2022 22:19:25 -0500
Subject: [PATCH 1/2] Allow utf8->string, utf16->string, utf32->string to take
 ranges

Added the following new functions, that behave like substring, but for
bytevector to string conversion.

scm_utf8_range_to_string (SCM, SCM, SCM);
scm_utf16_range_to_string (SCM, SCM, SCM, SCM);
scm_utf32_range_to_string (SCM, SCM, SCM, SCM);

* doc/ref/api-data.texi: Updated documentation to reflect new function
  and range constraints
* libguile/bytevectors.c: Added new function.
* libguile/bytevectors.h: Added new function declaration.
* test-suite/tests/bytevectors.test: Added tests for exceptions and
  behavior for edge cases
---
 doc/ref/api-data.texi |  15 +++-
 libguile/bytevectors.c| 144 +++---
 libguile/bytevectors.h|   3 +
 test-suite/tests/bytevectors.test |  37 
 4 files changed, 164 insertions(+), 35 deletions(-)

diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index b6c2c4d61..44b64454f 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -7139,16 +7139,25 @@ UTF-32 (aka. UCS-4) encoding of @var{str}.  For UTF-16 and UTF-32,
 it defaults to big endian.
 @end deffn
 
-@deffn {Scheme Procedure} utf8->string utf
-@deffnx {Scheme Procedure} utf16->string utf [endianness]
-@deffnx {Scheme Procedure} utf32->string utf [endianness]
+@deffn {Scheme Procedure} utf8->string utf [start [end]]
+@deffnx {Scheme Procedure} utf16->string utf [endianness [start [end]]]
+@deffnx {Scheme Procedure} utf32->string utf [endianness [start [end]]]
 @deffnx {C Function} scm_utf8_to_string (utf)
+@deffnx {C Function} scm_utf8_range_to_string (utf, start, end)
 @deffnx {C Function} scm_utf16_to_string (utf, endianness)
+@deffnx {C Function} scm_utf16_range_to_string (utf, endianness, start, end)
 @deffnx {C Function} scm_utf32_to_string (utf, endianness)
+@deffnx {C Function} scm_utf32_range_to_string (utf, endianness, start, end)
+
 Return a newly allocated string that contains from the UTF-8-, UTF-16-,
 or UTF-32-decoded contents of bytevector @var{utf}.  For UTF-16 and UTF-32,
 @var{endianness} should be the symbol @code{big} or @code{little}; when omitted,
 it defaults to big endian.
+
+@var{start} and @var{end}, when provided, must be exact integers
+satisfying:
+
+0 <= @var{start} <= @var{end} <= @code{(bytevector-length @var{utf})}.
 @end deffn
 
 @node Bytevectors as Arrays
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index f42fbb427..12d299042 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -2061,25 +2061,46 @@ SCM_DEFINE (scm_string_to_utf32, "string->utf32",
 
 /* Produce the body of a function that converts a UTF-encoded bytevector to a
string.  */
-#define UTF_TO_STRING(_utf_width)	\
+#define UTF_TO_STRING(_utf_width, utf, endianness, start, end)  \
   SCM str = SCM_BOOL_F;			\
   int err;\
   char *c_str = NULL;   \
   char c_utf_name[MAX_UTF_ENCODING_NAME_LEN];\
   char *c_utf;  \
-  size_t c_strlen = 0, c_utf_len = 0;	\
+  size_t c_strlen = 0, c_utf_len, c_start, c_end;   \
 	\
-  SCM_VALIDATE_BYTEVECTOR (1, utf);	\
-  if (scm_is_eq (endianness, SCM_UNDEFINED))\
-endianness = sym_big;		\
+  SCM_VALIDATE_BYTEVECTOR (1, (utf));	\
+  if (scm_is_eq ((endianness), SCM_UNDEFINED))  \
+(endianness) = sym_big;		\
   else	\
-SCM_VALIDATE_SYMBOL (2, endianness);\
+SCM_VALIDATE_SYMBOL (2, (endianness));\
 	\
-  c_utf_len = SCM_BYTEVECTOR_LENGTH (utf);\
-  c_utf = (char *) SCM_BYTEVECTOR_CONTENTS (utf);			\
-  utf_encoding_name (c_utf_name, (_utf_width), endianness);		\
+  c_utf_len = SCM_BYTEVECTOR_LENGTH ((utf));\
+  c_utf = (char *) SCM_BYTEVECTOR_CONTENTS ((utf));			\
+  utf_encoding_name (c_utf_name, (_utf_width), (endianness));		\
+\
+  if (!scm_is_eq ((start), SCM_UNDEFINED))  \
+{   \
+  c_start = scm_to_unsigned_integer ((start), 0, c_utf_len);\
+}   \
+  else  \
+{   \
+  c_start = 0;  \
+}

bug#52230: 'guild compile' and C(++) extensions (in the context of LilyPond)

2022-02-21 Thread Jean Abou Samra




Le 19/02/2022 à 22:25, Olivier Dion a écrit :

On Sat, 19 Feb 2022, Jean Abou Samra  wrote:

I had similar problem with Jami.  I added C++ primitives to Guile, but
these were not load using the foreign function interface.  Note, I'm
using Guile 3.0.8, but I think the same could be done for Guile 2.0.

Basically what I do is to add a `compile` command to my program so to
speak.

So usually the program does this:
 main -> install_scheme_primitives() -> Run the program

And for compilation
 main -> compile_in_guile() -> install_scheme_primitives() -> 
compile-file


To be clear here's what install_scheme_primitives() does:

void
install_scheme_primitives()
{
 /* Define modules here */
 auto load_module = [](auto name, auto init){
 scm_c_define_module(name, init, NULL);
 };

 load_module("jami account", install_account_primitives);
 load_module("jami call", install_call_primitives);
 load_module("jami conversation", install_conversation_primitives);
 load_module("jami logger bindings", install_logger_primitives);
 load_module("jami signal bindings", install_signal_primitives);
}


and here's what compile_in_guile() does:

void*
compile_in_guile(void* args_raw)
{
 // ...
 install_scheme_primitives();

 // This string is usually formatted
 scm_c_eval_string("(use-modules (system base compile))"
   "(compile-file \"foo.scm\" #:output-file \"foo.go\")")

// ..
}


so now I can correctly compile any file in the project.  I just add this
to Makefile.am:

MODULES  = foo.scm
GOBJECTS = $(MODULES:%=%.go)

%.go: %.scm | program
 @echo GUILD; ./program compile $< $@


Hope that can help.




Thank you Olivier, this is hugely helpful. So far we thought
we'd need to restructure our set of Scheme files in proper
modules to make separate byte-compilation happen. This works
in my experiments, and can compile several files that are
part of the same module as well, using the #:env argument
of compile-file. Thanks again, much appreciated.

Best regards,
Jean






bug#52230: 'guild compile' and C(++) extensions (in the context of LilyPond)

2022-02-19 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
On Sat, 19 Feb 2022, Jean Abou Samra  wrote:

I had similar problem with Jami.  I added C++ primitives to Guile, but
these were not load using the foreign function interface.  Note, I'm
using Guile 3.0.8, but I think the same could be done for Guile 2.0.

Basically what I do is to add a `compile` command to my program so to
speak.

So usually the program does this:
main -> install_scheme_primitives() -> Run the program

And for compilation
main -> compile_in_guile() -> install_scheme_primitives() -> 
compile-file


To be clear here's what install_scheme_primitives() does:

void
install_scheme_primitives()
{
/* Define modules here */
auto load_module = [](auto name, auto init){
scm_c_define_module(name, init, NULL);
};

load_module("jami account", install_account_primitives);
load_module("jami call", install_call_primitives);
load_module("jami conversation", install_conversation_primitives);
load_module("jami logger bindings", install_logger_primitives);
load_module("jami signal bindings", install_signal_primitives);
}


and here's what compile_in_guile() does:

void*
compile_in_guile(void* args_raw)
{
// ...
install_scheme_primitives();

// This string is usually formatted
scm_c_eval_string("(use-modules (system base compile))"
  "(compile-file \"foo.scm\" #:output-file \"foo.go\")")

   // ..
}


so now I can correctly compile any file in the project.  I just add this
to Makefile.am:

MODULES  = foo.scm
GOBJECTS = $(MODULES:%=%.go)

%.go: %.scm | program
@echo GUILD; ./program compile $< $@


Hope that can help.

-- 
Olivier Dion
Polymtl





bug#52230: 'guild compile' and C(++) extensions (in the context of LilyPond)

2022-02-19 Thread Jean Abou Samra

Hi,

(Cross-posted to guile-user, guile-devel and the debbugs
issue, I'm unsure where this should go.)

In LilyPond, we have now made a development release with
binaries using Guile 2.2. However, a major problem is that
we don't ship Guile bytecode yet. Notably, one problem
to get the bytecode in a build system is that we are
currently forced to use GUILE_AUTO_COMPILE=1 to generate
it -- which means we need to compile the entire suite of
regression tests in order to exercise all files. This
also means spurious test differences when Guile gets
noisy about byte-compilation 
(https://debbugs.gnu.org/cgi/bugreport.cgi?bug=16364).

In summary: it would mean a lot less headache to be
able to use 'guild compile'. Unfortunately, this does
not work. One issue is that our Scheme files are mostly
not Guile modules, but loaded directly with primitive-load-path.
This will be a lot of work to fix, but it is on our end.
However, I don't understand how to get around another
issue, which is how our Scheme code interfaces with C++.

  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=52230

Basically, if a Scheme file has something like

  (define-public point-stencil (ly:make-stencil "" '(0 . 0) '(0 . 0)))

where ly:make-stencil is a procedure defined in C++,
I can get this file to compile, but I can't get files
using it as a module to compile. Investigation shows
that Guile is apparently trying to load the module
when compiling.

$ cat print.scm
(define-module (print))

(display "Module running!")
$ guild compile print.scm
wrote 
`/home/jean/.cache/guile/ccache/3.0-LE-8-4.4/home/jean/repos/lilypond/print.scm.go' 


$ cat import.scm
(use-modules (print))
$ guild compile -L . print.scm
wrote 
`/home/jean/.cache/guile/ccache/3.0-LE-8-4.4/home/jean/repos/lilypond/print.scm.go' 


$ guild compile -L . import.scm
Module running!wrote 
`/home/jean/.cache/guile/ccache/3.0-LE-8-4.4/home/jean/repos/lilypond/import.scm.go' 




For functions defined in C++, that does not work: they
are added by the entry point in the function that scm_boot_guile
calls, using scm_c_define_gsubr. They aren't defined until
the program is actually run.

So how is 'guild compile' supposed to work with C(++) code?

Thanks in advance,
Jean






bug#53928: [PATCH] Allow null bytes in UNIX sockets.

2022-02-10 Thread Liliana Marie Prikler
The current socket address constructors all assume, that there are no
null bytes in the socket path.  This assumption does not hold in Linux,
which uses an initial null byte to demarcate abstract sockets and
ignores all further null bytes [1].

[1] https://www.man7.org/linux/man-pages/man7/unix.7.html

* libguile/sockets.c (scm_fill_sockaddr)[HAVE_UNIX_DOMAIN_SOCKETS]:
Use scm_to_locale_stringn to construct c_address.
Use memcpy instead of strcpy and calculate size directly instead of
using SUN_LEN.
(_scm_from_sockaddr): Copy the entire path up to the limits imposed by
addr_size.
* test-suite/tests/00-socket.test: ("make-socket-address"): Add case for
abstract unix sockets.
("AF_UNIX/SOCK_STREAM"): Add abstract socket versions of bind, listen,
connect and accept.
---
This patch is identical to the one sent in [1].  The full thread is visible
over at yhetil[2] -- one reply from May 2021 [3] isn't shown as part of it in
the GNU archive.

I haven't built or tested it on top of current master, but given that the
patch applied cleanly, I have high hopes to say the least 🙂

[1] https://lists.gnu.org/archive/html/guile-devel/2021-03/msg00038.html
[2] 
https://yhetil.org/guile-devel/20210329153757.16476-1-leo.pri...@student.tugraz.at/
[3] https://lists.gnu.org/archive/html/guile-devel/2021-05/msg00012.html

 libguile/socket.c   | 18 +---
 test-suite/tests/00-socket.test | 78 +++--
 2 files changed, 86 insertions(+), 10 deletions(-)

diff --git a/libguile/socket.c b/libguile/socket.c
index 77cdd74ef..6b77b3a14 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -813,10 +813,11 @@ scm_fill_sockaddr (int fam, SCM address, SCM *args, int 
which_arg,
struct sockaddr_un *soka;
int addr_size;
char *c_address;
+   size_t c_address_size;
 
scm_dynwind_begin (0);
 
-   c_address = scm_to_locale_string (address);
+   c_address = scm_to_locale_stringn (address, &c_address_size);
scm_dynwind_free (c_address);
 
/* the static buffer size in sockaddr_un seems to be arbitrary
@@ -826,12 +827,14 @@ scm_fill_sockaddr (int fam, SCM address, SCM *args, int 
which_arg,
   connect/bind etc., to fail.  sun_path is always the last
   member of the structure.  */
addr_size = sizeof (struct sockaddr_un)
- + MAX (0, strlen (c_address) + 1 - (sizeof soka->sun_path));
+ + MAX (0, c_address_size + 1 - (sizeof soka->sun_path));
soka = (struct sockaddr_un *) scm_malloc (addr_size);
-   memset (soka, 0, addr_size);  /* for sun_len: see sin_len above. */
+   memset (soka, 0, addr_size);
soka->sun_family = AF_UNIX;
-   strcpy (soka->sun_path, c_address);
-   *size = SUN_LEN (soka);
+/* we accept 0-bytes here (used for abstract sockets in Linux);
+   therefore do not use strlen() or SUN_LEN!  */
+   memcpy (soka->sun_path, c_address, c_address_size);
+   *size = offsetof (struct sockaddr_un, sun_path) + c_address_size;
 
scm_dynwind_end ();
return (struct sockaddr *) soka;
@@ -1045,7 +1048,10 @@ _scm_from_sockaddr (const scm_t_max_sockaddr *address, 
unsigned addr_size,
if (addr_size <= offsetof (struct sockaddr_un, sun_path))
  SCM_SIMPLE_VECTOR_SET(result, 1, SCM_BOOL_F);
else
- SCM_SIMPLE_VECTOR_SET(result, 1, scm_from_locale_string 
(nad->sun_path));
+  {
+size_t path_size = addr_size - offsetof (struct sockaddr_un, 
sun_path);
+SCM_SIMPLE_VECTOR_SET(result, 1, 
scm_from_locale_stringn(nad->sun_path, path_size));
+  }
   }
   break;
 #endif
diff --git a/test-suite/tests/00-socket.test b/test-suite/tests/00-socket.test
index 027bd8519..5196b4b7d 100644
--- a/test-suite/tests/00-socket.test
+++ b/test-suite/tests/00-socket.test
@@ -128,10 +128,15 @@
   (= (sockaddr:flowinfo sa*) 1)
 
   (if (defined? 'AF_UNIX)
-  (pass-if "AF_UNIX"
-   (let ((sa (make-socket-address AF_UNIX "/tmp/unix-socket")))
- (and (= (sockaddr:fam sa) AF_UNIX)
-  (string=? (sockaddr:path sa) "/tmp/unix-socket"))
+  (begin
+(pass-if "AF_UNIX"
+ (let ((sa (make-socket-address AF_UNIX "/tmp/unix-socket")))
+   (and (= (sockaddr:fam sa) AF_UNIX)
+(string=? (sockaddr:path sa) "/tmp/unix-socket"
+(pass-if "AF_UNIX abstract"
+  (let ((sa (make-socket-address AF_UNIX "\x00/tmp/abstract-socket")))
+   (and (= (sockaddr:fam sa) AF_UNIX)
+(string=? (sockaddr:path sa) "\x00/tmp/abstract-socket")))
 
 ;;;
 ;;; setsockopt
@@ -319,6 +324,71 @@
 
#t)
 
+  ;; testing `bind', `listen' and `connect' on abstract stream-oriented 
sockets
+
+  (let ((server-socket (socket AF_UNIX SOCK_STREAM 0))
+   (server-bound? #f)
+   (server-listening? #f)
+   (server-pid #f)
+   (path (temp-file-path)))
+
+   (false-if-e

bug#53898: The module name for using weak vectors is undocumented.

2022-02-09 Thread Maxime Devos
Hi,

Weak vectors are documented in ‘6.17.3.2  Weak vectors’.
However, they are not available from the (guile) module
and that section does not document which module needs to
be imported to use the procedures from that section.

I only found the required module (ice-9 weak-vector) by doing

$ git grep -F 'make-weak-vector'

It would be nice to document the module name, and not only
the procedures theirselves.

Greetings,
Maxime.


signature.asc
Description: This is a digitally signed message part


bug#52835: [PATCH v3] Fix child spawning closing standard fds prematurely

2022-02-07 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
* libguile/posix.c (renumber_file_descriptor): Refactor it as
dup_handle_error.
(dup_handle_error, dup2_handle_error): New functions that wrap around
dup and dup2 by retrying on EINTR or EBUSY, as well as erroring out on
other errors.
(start_child): Close standard file descriptors only
after all of them have been dup2'd.
---
Hello,

This is a new version of the fix that should now handle possible
dup/dup2 errors properly.

Best,
Josselin
 libguile/posix.c | 82 +++-
 1 file changed, 53 insertions(+), 29 deletions(-)

diff --git a/libguile/posix.c b/libguile/posix.c
index 3ab12b99e..dc3080b3c 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1280,14 +1280,14 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0,
 #endif /* HAVE_FORK */
 
 #ifdef HAVE_FORK
-/* 'renumber_file_descriptor' is a helper function for 'start_child'
-   below, and is specialized for that particular environment where it
-   doesn't make sense to report errors via exceptions.  It uses dup(2)
-   to duplicate the file descriptor FD, closes the original FD, and
-   returns the new descriptor.  If dup(2) fails, print an error message
-   to ERR and abort.  */
+/* 'dup_handle_error' is a helper function for 'start_child' below, and
+   is specialized for that particular environment where it doesn't make
+   sense to report errors via exceptions.  It uses dup(2) to duplicate
+   the file descriptor FD, does *not* close the original FD, and returns
+   the new descriptor.  If dup(2) fails, print an error message to ERR
+   and abort.  */
 static int
-renumber_file_descriptor (int fd, int err)
+dup_handle_error (int fd, int err)
 {
   int new_fd;
 
@@ -1304,7 +1304,33 @@ renumber_file_descriptor (int fd, int err)
   _exit (127);  /* Use exit status 127, as with other exec errors. */
 }
 
-  close (fd);
+  return new_fd;
+}
+
+/* 'dup2_handle_error' is a helper function for 'start_child' below, and
+   is specialized for that particular environment where it doesn't make
+   sense to report errors via exceptions.  It uses dup2(2) to duplicate
+   the file descriptor FD, does *not* close the original FD, and returns
+   the new descriptor.  If dup2(2) fails, print an error message to ERR
+   and abort.  */
+static int
+dup2_handle_error (int fd, int to, int err)
+{
+  int new_fd;
+
+  do
+new_fd = dup2 (fd, to);
+  while (new_fd == -1 && (errno == EINTR || errno == EBUSY));
+
+  if (new_fd == -1)
+{
+  /* At this point we are in the child process before exec.  We
+ cannot safely raise an exception in this environment.  */
+  const char *msg = strerror (errno);
+  fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg);
+  _exit (127);  /* Use exit status 127, as with other exec errors. */
+}
+
   return new_fd;
 }
 #endif /* HAVE_FORK */
@@ -1357,27 +1383,25 @@ start_child (const char *exec_file, char **exec_argv,
   if (err == -1)
 err = open ("/dev/null", O_WRONLY);
 
-  if (in > 0)
-{
-  if (out == 0)
-out = renumber_file_descriptor (out, err);
-  if (err == 0)
-err = renumber_file_descriptor (err, err);
-  do dup2 (in, 0); while (errno == EINTR);
-  close (in);
-}
-  if (out > 1)
-{
-  if (err == 1)
-err = renumber_file_descriptor (err, err);
-  do dup2 (out, 1); while (errno == EINTR);
-  close (out);
-}
-  if (err > 2)
-{
-  do dup2 (err, 2); while (errno == EINTR);
-  close (err);
-}
+  /* Dup each non-yet-dup2'd fd that's in the way to the next available fd,
+ so that we can safely dup2 to 0/1/2 without potentially overwriting
+ in/out/err.  Note that dup2 doesn't do anything if its arguments are
+ equal. */
+  if (out == 0)
+out = dup_handle_error (out, err);
+  if (err == 0)
+err = dup_handle_error (err, err);
+  dup2_handle_error (in, 0, err);
+
+  if (err == 1)
+err = dup_handle_error (err, err);
+  dup2_handle_error (out, 1, err);
+
+  dup2_handle_error (err, 2, err);
+
+  if (in > 2) close (in);
+  if (out > 2) close (out);
+  if (err > 2) close (err);
 
   execvp (exec_file, exec_argv);
 
-- 
2.34.0






bug#53201: string->uri-reference rejects domain names with final ‘.’

2022-01-27 Thread dsmich
New patch. Now with 3 test cases!

-Dale


From f4eece6395e75197030bff42a583e847e5a34e15 Mon Sep 17 00:00:00 2001
From: "Dale P. Smith" 
Date: Thu, 27 Jan 2022 19:20:57 -0500
Subject: [PATCH] Allow trailing "." in urls

bug #53201
---
 module/web/uri.scm| 17 ++---
 test-suite/tests/web-uri.test | 10 ++
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/module/web/uri.scm b/module/web/uri.scm
index 8e0b9bee7..8c5c0d6f0 100644
--- a/module/web/uri.scm
+++ b/module/web/uri.scm
@@ -206,13 +206,16 @@ for ‘build-uri’ except there is no scheme."
((regexp-exec ipv6-regexp host)
 (false-if-exception (inet-pton AF_INET6 host)))
(else
-(let lp ((start 0))
-  (let ((end (string-index host #\. start)))
-(if end
-(and (regexp-exec domain-label-regexp
-  (substring host start end))
- (lp (1+ end)))
-(regexp-exec top-label-regexp host start)))
+(let ((last (1- (string-length host
+  (let lp ((start 0))
+(let ((end (string-index host #\. start)))
+  (if (and end (< end last))
+  (and (regexp-exec domain-label-regexp
+(substring host start end))
+   (lp (1+ end)))
+  (if end
+  (regexp-exec top-label-regexp (substring host start end))
+  (regexp-exec top-label-regexp host start)
 
 (define userinfo-pat
   (string-append "[" letters digits "_.!~*'();:&=+$,-]+"))
diff --git a/test-suite/tests/web-uri.test b/test-suite/tests/web-uri.test
index 95fd82f16..e9fb766f0 100644
--- a/test-suite/tests/web-uri.test
+++ b/test-suite/tests/web-uri.test
@@ -367,6 +367,16 @@
   (pass-if "//bad.host.1"
 (not (string->uri-reference "//bad.host.1")))
 
+  (pass-if "//bad.host.1."
+(not (string->uri-reference "//bad.host.1.")))
+
+  (pass-if "//bad.host.."
+(not (string->uri-reference "//bad.host..")))
+
+  (pass-if "//1.good.host."
+(uri=? (string->uri-reference "//1.good.host.")
+   #:host "1.good.host." #:path ""))
+
   (pass-if "http://1.good.host";
 (uri=? (string->uri-reference "http://1.good.host";)
#:scheme 'http #:host "1.good.host" #:path ""))
-- 
2.30.2



bug#53201: string->uri-reference rejects domain names with final ‘.’

2022-01-26 Thread dsmich
Probably not the best fix. Seems to work. Includes a few tests.

-Dale

diff --git a/module/web/uri.scm b/module/web/uri.scm
index 8e0b9bee7..d6758fcc6 100644
--- a/module/web/uri.scm
+++ b/module/web/uri.scm
@@ -212,7 +212,9 @@ for ‘build-uri’ except there is no scheme."
 (and (regexp-exec domain-label-regexp
 (substring host start end))
 (lp (1+ end)))
- (regexp-exec top-label-regexp host start)))
+ (if (< start (string-length host))
+ (regexp-exec top-label-regexp host start)
+ #t)))

 (define userinfo-pat
 (string-append "[" letters digits "_.!~*'();:&=+$,-]+"))
diff --git a/test-suite/tests/web-uri.test
b/test-suite/tests/web-uri.test
index 95fd82f16..c49142d48 100644
--- a/test-suite/tests/web-uri.test
+++ b/test-suite/tests/web-uri.test
@@ -367,6 +367,9 @@
 (pass-if "//bad.host.1"
 (not (string->uri-reference "//bad.host.1")))

+ (pass-if "//bad.host.."
+ (not (string->uri-reference "//bad.host..")))
+
 (pass-if "http://1.good.host";
 (uri=? (string->uri-reference "http://1.good.host";)
 #:scheme 'http #:host "1.good.host" #:path ""))
@@ -375,6 +378,10 @@
 (uri=? (string->uri-reference "//1.good.host")
 #:host "1.good.host" #:path ""))

+ (pass-if "//1.good.host."
+ (uri=? (string->uri-reference "//1.good.host.")
+ #:host "1.good.host." #:path ""))
+
 (when (memq 'socket *features*)
 (pass-if "http://192.0.2.1";
 (uri=? (string->uri-reference "http://192.0.2.1";)




bug#53408: guile site broken link

2022-01-21 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
Hi !

The link for Greg Badros' Scheme Lecture Notes on the page
https://www.gnu.org/software/guile/learn/ is broken.

Seems that there's just a / missing :
https://courses.cs.washington.edu/courses/cse341/99su/lectures/scheme/
works.

Cheers,





bug#52559: guix pull fails with `Unknown command: nix fish: nix show-derivation "~/.fr-sqOEpp/....-module-import-compiled.drv"

2022-01-17 Thread Maxime Devos
reopen 52559
reassign 52559 guile
retitle 52559 Guile doesn't like carriage returns after \
thanks

(I thought I renamed it already?)

Grigory Shepelev schreef op ma 17-01-2022 om 22:37 [+0300]:
> Same problem is: 
> Computing Guix derivation for 'x86_64-linux'... |ice-
> 9/read.scm:126:4: In procedure read-string:
> gnu/packages/virtualization.scm:643:1: invalid character in escape
> sequence: #\return
> guix pull: error: You found a bug: the program
> '/gnu/store/kms78b5wzmp763lljsazbp8v8a88p1z8-compute-guix-derivation'
> failed to compute the derivation for Guix ...
> 
> on "guix pull".

I reassigned the bug to Guile since that is were the issue appears to
be.  To Guile people who haven't seen this bug report before, there's
a minimal reproducer at <https://issues.guix.gnu.org/52559#15>.

Greetings,
Maxime.



signature.asc
Description: This is a digitally signed message part


bug#53244: Guile 3.0.7.14-118ee re-export bug

2022-01-13 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
There's a difference in exports depending on if you use use-modules vs 
resolve-module.

If a module re-exports a function and the module is imported using use-modules 
the re-export seems to work as one would expect as the documentation says, the 
cdr of the pair is the member of the public interface. 

If you use a resolve-module and then try to pull out the cdr using module-ref 
it fails with a "No variable named" If you try module-variable you simply 
get a #f. If you try doing the module-ref with the original name then it pulls 
it through just fine.

Is this the expected behavior? As the user I would've expected no difference 
between use modules and the resolve-module method. Thank you.

#! guiles/main.scm
(add-to-load-path "$LOC")
;(use-modules (guiles two))

(define m (resolve-module '(guiles two)))
(define no-print (module-ref m 'no-print))
(display m)
(display "\n")
(display no-print)
!#

#! guiles/one.scm
(define-module (guiles one)
  #:export (print))

(define (print str)
  (display str))
!#

#! guiles/two.scm
(define-module (guiles two)
  #:use-module (guiles one)
  #:re-export ((print . no-print)))
!#






bug#53201: string->uri-reference rejects domain names with final ‘.’

2022-01-11 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language

Guilers,

What the subject says :-)  Omitting the final dot is optional (and 
common), not mandatory.


 scheme@(guile-user)> (string->uri-reference "http://x.org";)
 $1 = #< … host: "x.org" …>

 scheme@(guile-user)> (string->uri-reference "http://x.org.";)
 $2 = #f ; wrong!

This actually breaks redirects in the wild:

Starting download […]
From 
https://pyropus.ca/software/getmail/old-versions/getmail-5.16.tar.gz...

Bad uri-reference header component:
https://pyropus.ca./software/getmail/old-versions/getmail-5.16.tar.gz

Kind regards,

T G-R


signature.asc
Description: PGP signature


bug#53139: sleep return value error, with pselect6 system call on Linux

2022-01-09 Thread Christopher Baines
The sleep procedure is documented as returning 0 when it's not
interrupted by a signal.

This behaviour seems to have changed in guile as distributed by GNU Guix
(see the time-machine commands below). Previously, guile used the select
system call which seemed to change the timeout argument to the time
left. The updated guile uses the pselect6 system call, which doesn't do
this.

→ guix time-machine --commit=b603554ed044638dd40b6863d5dada59eefe03b8 -- 
environment --ad-hoc guile -- guile -c '(peek (sleep 5))'

;;; (0)

select(4, [3], NULL, NULL, {tv_sec=5, tv_usec=0}) = 0 (Timeout)

→ guix time-machine --commit=6dffced09ecda024e0884e352778c221ad066fd6 -- 
environment --ad-hoc guile -- guile -c '(peek (sleep 5))'

;;; (5)

pselect6(4, [3], NULL, NULL, {tv_sec=5, tv_nsec=0}, NULL) = 0 (Timeout)





bug#53125: Missing abstract unix socket support

2022-01-08 Thread Zhu Zihao
Currently, It's not valid to create abstract unix socket in Guile via
`connect` procedure, because it rejects string with leading NUL.

Abstract unix socket is widely used in D-Bus. Missing support for it
hurts the ability of Guile in D-Bus programming.

I see a patch at
https://lists.gnu.org/archive/html/guile-devel/2021-03/msg00038.html

But looks that nobody cares it. Would someone can help review and merge it? 
-- 
Retrieve my PGP public key:

  gpg --recv-keys D47A9C8B2AE3905B563D9135BE42B352A9F6821F

Zihao


signature.asc
Description: PGP signature


bug#53023: A global variable gets an erroneous value

2022-01-05 Thread Tommi Höynälänmaa

This bug is present only in hppa and m68k architectures, see

https://buildd.debian.org/status/fetch.php?pkg=theme-d&arch=hppa&ver=4.1.0-2&stamp=1640945222&raw=0

and

https://buildd.debian.org/status/fetch.php?pkg=theme-d&arch=m68k&ver=4.1.0-2&stamp=1640945363&raw=0

The backtrace in those logs contains the following lines:

In theme-d/translator/theme-d-representation.scm:
   2275:0  2 (_)
In theme-d/translator/theme-d-entities.scm:
297:2  1 (tno-field-set! 1 type #(#(#(#t "hrecord-type" 5 …) …) …))

See 
https://salsa.debian.org/tohoyn-guest/theme-d/-/blob/master/theme-d/translator/theme-d-representation.scm.in 
for theme-d-representation.scm.


Now the call argument to procedure tno-field-set! in line 2275 is 
tc-pair-fields, which is initialized to a list in line 1356. However, 
the backtrace shows that the value of this argument is 1.


 - Tommi Höynälänmaa

--
Kotisivu / Homepage:http://www.iki.fi/tohoyn/
Sähköposti / E-Mail:tommi.hoynalan...@iki.fi
GPG-sormenjälki / GPG fingerprint:
55F4 2477 7155 3528 5CB2 2B7A BB86 1FDE 4046 0F83
FM, Debian-ylläpitäjä / M.Sc., Debian Maintainer



OpenPGP_0xBB861FDE40460F83.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly

2021-12-28 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
Hello Timothy,

Timothy Sample  writes:

> One thing that ‘renumber_file_descriptor’ does that we seem to be losing
> here is error checking.  To my eye, the old code will try and warn the
> user if they run out of file descriptors, but the new code will not.

I may have been too hasty on that front, you're right that we should
check for errors when dup'ing.  Note though that we should not run out
of fds, as we close all of them except for in/out/err right before using
it, but still, here are the interesting error codes:
* EINTR, although OpenBSD and Linux will never set that error from my
light research;
* EBUSY, not POSIX though, only Linux, so should we?
* EMFILE, if we run out of fds;
* EBADF if either of the fds are invalid.

As for error reporting, should we keep the parent's stderr fd open while
we do all of this, just to be able to report an error in case it
happens?  The old code used to try reporting the errors to the new `err`
fd instead, but it might be clearer to use stderr.

WDYT?

-- 
Josselin Poiret





bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly

2021-12-28 Thread Timothy Sample
Hey Josselin,

Thanks for finding this bug!  I have one concern about your patches:

Josselin Poiret writes:

> The second patch removes renumber_file_descriptor, as it is no longer
> used.

One thing that ‘renumber_file_descriptor’ does that we seem to be losing
here is error checking.  To my eye, the old code will try and warn the
user if they run out of file descriptors, but the new code will not.

The other thing that I like is how ‘renumber_file_descriptor’ checks the
return value of ‘dup’ in addition to checking ‘errno’.  (I realize that
the old code skips that check for ‘dup2’ – I’m kinda just stating a
preference here.)  A quick check of POSIX turns up the following: “the
value of ‘errno’ should only be examined when it is indicated to be
valid by a function’s return value” [1].


-- Tim

[1] https://pubs.opengroup.org/onlinepubs/9699919799/





bug#52835: [PATCH v2 2/2] Remove unused renumber_file_descriptor

2021-12-27 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
* libguile/posix.c (renumber_file_descriptor): Remove it.
---
Sorry for the noise, but I just saw that this patch omitted a closing
*/, here is a fixed version.

 libguile/posix.c | 30 --
 1 file changed, 30 deletions(-)

diff --git a/libguile/posix.c b/libguile/posix.c
index 148ebeb3d..1d9996565 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1279,36 +1279,6 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0,
 #undef FUNC_NAME
 #endif /* HAVE_FORK */
 
-#ifdef HAVE_FORK
-/* 'renumber_file_descriptor' is a helper function for 'start_child'
-   below, and is specialized for that particular environment where it
-   doesn't make sense to report errors via exceptions.  It uses dup(2)
-   to duplicate the file descriptor FD, closes the original FD, and
-   returns the new descriptor.  If dup(2) fails, print an error message
-   to ERR and abort.  */
-static int
-renumber_file_descriptor (int fd, int err)
-{
-  int new_fd;
-
-  do
-new_fd = dup (fd);
-  while (new_fd == -1 && errno == EINTR);
-
-  if (new_fd == -1)
-{
-  /* At this point we are in the child process before exec.  We
- cannot safely raise an exception in this environment.  */
-  const char *msg = strerror (errno);
-  fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg);
-  _exit (127);  /* Use exit status 127, as with other exec errors. */
-}
-
-  close (fd);
-  return new_fd;
-}
-#endif /* HAVE_FORK */
-
 #ifdef HAVE_FORK
 #define HAVE_START_CHILD 1
 /* Since Guile uses threads, we have to be very careful to avoid calling
-- 
2.34.0






bug#52835: [PATCH 2/2] Remove unused renumber_file_descriptor

2021-12-27 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
* libguile/posix.c (renumber_file_descriptor): Remove it.
---
 libguile/posix.c | 32 +---
 1 file changed, 1 insertion(+), 31 deletions(-)

diff --git a/libguile/posix.c b/libguile/posix.c
index 148ebeb3d..2624d07c2 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1277,37 +1277,7 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0,
   return scm_from_int (pid);
 }
 #undef FUNC_NAME
-#endif /* HAVE_FORK */
-
-#ifdef HAVE_FORK
-/* 'renumber_file_descriptor' is a helper function for 'start_child'
-   below, and is specialized for that particular environment where it
-   doesn't make sense to report errors via exceptions.  It uses dup(2)
-   to duplicate the file descriptor FD, closes the original FD, and
-   returns the new descriptor.  If dup(2) fails, print an error message
-   to ERR and abort.  */
-static int
-renumber_file_descriptor (int fd, int err)
-{
-  int new_fd;
-
-  do
-new_fd = dup (fd);
-  while (new_fd == -1 && errno == EINTR);
-
-  if (new_fd == -1)
-{
-  /* At this point we are in the child process before exec.  We
- cannot safely raise an exception in this environment.  */
-  const char *msg = strerror (errno);
-  fprintf (fdopen (err, "a"), "start_child: dup failed: %s\n", msg);
-  _exit (127);  /* Use exit status 127, as with other exec errors. */
-}
-
-  close (fd);
-  return new_fd;
-}
-#endif /* HAVE_FORK */
+#endif /* HAVE_FORK *
 
 #ifdef HAVE_FORK
 #define HAVE_START_CHILD 1
-- 
2.34.0






bug#52835: [PATCH 1/2] Fix child spawning closing standard fds prematurely

2021-12-27 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
* libguile/posix.c (start_child): Close standard file descriptors only
after all of them have been dup2'd.
---
 libguile/posix.c | 40 +++-
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/libguile/posix.c b/libguile/posix.c
index 3ab12b99e..148ebeb3d 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1357,27 +1357,25 @@ start_child (const char *exec_file, char **exec_argv,
   if (err == -1)
 err = open ("/dev/null", O_WRONLY);
 
-  if (in > 0)
-{
-  if (out == 0)
-out = renumber_file_descriptor (out, err);
-  if (err == 0)
-err = renumber_file_descriptor (err, err);
-  do dup2 (in, 0); while (errno == EINTR);
-  close (in);
-}
-  if (out > 1)
-{
-  if (err == 1)
-err = renumber_file_descriptor (err, err);
-  do dup2 (out, 1); while (errno == EINTR);
-  close (out);
-}
-  if (err > 2)
-{
-  do dup2 (err, 2); while (errno == EINTR);
-  close (err);
-}
+  /* Dup each non-yet-dup2'd fd that's in the way to the next available fd,
+ so that we can safely dup2 to 0/1/2 without potentially overwriting
+ in/out/err.  Note that dup2 doesn't do anything if its arguments are
+ equal. */
+  if (out == 0)
+do out = dup (out); while (errno == EINTR);
+  if (err == 0)
+do err = dup (err); while (errno == EINTR);
+  do dup2 (in, 0); while (errno == EINTR);
+
+  if (err == 1)
+do err = dup (err); while (errno == EINTR);
+  do dup2 (out, 1); while (errno == EINTR);
+
+  do dup2 (err, 2); while (errno == EINTR);
+
+  if (in > 2) close (in);
+  if (out > 2) close (out);
+  if (err > 2) close (err);
 
   execvp (exec_file, exec_argv);
 
-- 
2.34.0






bug#52835: [PATCH 0/2] Fix spawning a child not setting standard fds properly

2021-12-27 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
Hello,

While working on the Guix installer (that needs to use system* quite a
lot), I've noticed that output/error redirection doesn't behave as
intended when combined with system*.  Here's a test you can try
at home:
--8<---cut here---start->8---
(call-with-output-file "/tmp/test.log"
  (lambda (port) (with-output-to-port port
   (lambda () (with-error-to-port port
(lambda () (system* "bash" "-c" "echo bong 
>&2")))
--8<---cut here---end--->8---

With current Guix, you will notice that /tmp/test.log is empty,
instead of the expected "bong".

Worse even, when testing with
--8<---cut here---start->8---
(with-error-to-port (current-output-port) (lambda () (system* "bash" "-c" "echo 
$$; sleep 10")))
--8<---cut here---end--->8---
you can actually inspect `/proc//fd/` and see that the stderr fd,
2, is actually closed.  This means that the next opened fd will take
its place, to which writes to stderr may end up.

The logic behind the stdin/out/err redirection for child processes
lies in `start_child`, in libguile/posix.c, and doesn't take into
account cases like:
* in/out/err having common values, as the common fd will be closed
before it has been dup2'd to all the std fds (which happens in the
first example);
* in/out/err having values between 0 and 2 which aren't their
corresponding std fd number, as they will not be dup2'd to
the stdin/out/err (which happens in the second example).

The first patch addresses this by:
* moving in/out/err closing logic after they've all been dup2'd;
* removing the check that in/out/err are > the corresponding
stdin/out/err;
* replacing renumber_file_descriptor by simply dup, as the former
closes fds that might be shared.  The closing logic of the first point
is enough here.

The second patch removes renumber_file_descriptor, as it is no longer
used.

Best,
Josselin

Josselin Poiret (2):
  Fix child spawning closing standard fds prematurely
  Remove unused renumber_file_descriptor

 libguile/posix.c | 72 ++--
 1 file changed, 20 insertions(+), 52 deletions(-)

-- 
2.34.0






bug#52646: GC thread freeze

2021-12-22 Thread Mathieu Othacehe


Hey!

> This is happening in this order, right?

Right, plus I don't see the following warning:

--8<---cut here---start->8---
warning: call to primitive-fork while multiple threads are running;
 further behavior unspecified.  See "Processes" in the
 manual, for more information
--8<---cut here---end--->8---

so I guess the issue is elsewhere.

> POSIX leaves unspecified the behavior of a child process forked from a
> multi-threaded process; there could be deadlocks, etc.  ‘primitive-fork’
> prints a warning when called from a multi-threaded Guile process.
>
> The solution is for multi-threaded Guile processes to not fork at all,
> or to fork only via ‘open-pipe*’, ‘system*’, etc., which are “known
> good” (they take care of post-fork handling in the child and call ‘exec’
> before anything bad could happen.)

Thanks for clarifying that anyway.

Mathieu





bug#52646: GC thread freeze

2021-12-21 Thread Ludovic Courtès
Hello!

Mathieu Othacehe  skribis:

> I experiment a strange behaviour with this Guile 3.0.7 process:
> https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git/tree/src/cuirass/scripts/remote-worker.scm.
>
> The process is forking N processes that in turn start 4 threads.

This is happening in this order, right?

POSIX leaves unspecified the behavior of a child process forked from a
multi-threaded process; there could be deadlocks, etc.  ‘primitive-fork’
prints a warning when called from a multi-threaded Guile process.

The solution is for multi-threaded Guile processes to not fork at all,
or to fork only via ‘open-pipe*’, ‘system*’, etc., which are “known
good” (they take care of post-fork handling in the child and call ‘exec’
before anything bad could happen.)

Thanks,
Ludo’.





bug#52646: GC thread freeze

2021-12-18 Thread Mathieu Othacehe


Hello,

I experiment a strange behaviour with this Guile 3.0.7 process:
https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git/tree/src/cuirass/scripts/remote-worker.scm.

The process is forking N processes that in turn start 4 threads. On
aarch64 machines specifically, some of those threads are freezing. Here
is what GDB is reporting:

--8<---cut here---start->8---
(gdb) attach 5660 ;frozen cuirass-remote-worker PID
(gdb) info thr
  Id   Target Id   Frame 
* 1Thread 0xafd32e20 (LWP 5660) "yHg3r3fS" 0xafb3fa80 in 
do_futex_wait.constprop () from 
/gnu/store/cb88z63hyg1icd2kkahiink2p291mhr2-glibc-2.31/lib/libpthread.so.0
  2Thread 0xa6c1c1d0 (LWP 5666) "ZMQbg/Reaper" 0xaf7ec294 in 
epoll_pwait () from 
/gnu/store/cb88z63hyg1icd2kkahiink2p291mhr2-glibc-2.31/lib/libc.so.6
  3Thread 0xaf0071d0 (LWP 5667) "ZMQbg/IO/0"   0xaf7ec294 in 
epoll_pwait () from 
/gnu/store/cb88z63hyg1icd2kkahiink2p291mhr2-glibc-2.31/lib/libc.so.6
  4Thread 0xa641b1d0 (LWP 5674) "yHg3r3fS" 0xaf7b9d04 in 
clock_nanosleep@@GLIBC_2.17 () from 
/gnu/store/cb88z63hyg1icd2kkahiink2p291mhr2-glibc-2.31/lib/libc.so.6
(gdb) bt
#0  0xafb3fa80 in do_futex_wait.constprop () from 
/gnu/store/cb88z63hyg1icd2kkahiink2p291mhr2-glibc-2.31/lib/libpthread.so.0
#1  0xafb3fb78 in __new_sem_wait_slow.constprop.0 () from 
/gnu/store/cb88z63hyg1icd2kkahiink2p291mhr2-glibc-2.31/lib/libpthread.so.0
#2  0xafb80318 in GC_stop_world () from 
/gnu/store/jsda4njqwjp4kb60fwa7n4mlfi1aanpq-libgc-7.6.12/lib/libgc.so.1
#3  0xafb6c020 in GC_stopped_mark () from 
/gnu/store/jsda4njqwjp4kb60fwa7n4mlfi1aanpq-libgc-7.6.12/lib/libgc.so.1
#4  0xafb6c8dc in GC_try_to_collect_inner () from 
/gnu/store/jsda4njqwjp4kb60fwa7n4mlfi1aanpq-libgc-7.6.12/lib/libgc.so.1
#5  0xafb6d598 in GC_collect_or_expand () from 
/gnu/store/jsda4njqwjp4kb60fwa7n4mlfi1aanpq-libgc-7.6.12/lib/libgc.so.1
#6  0xafb73b4c in GC_alloc_large () from 
/gnu/store/jsda4njqwjp4kb60fwa7n4mlfi1aanpq-libgc-7.6.12/lib/libgc.so.1
#7  0xafb74038 in GC_generic_malloc () from 
/gnu/store/jsda4njqwjp4kb60fwa7n4mlfi1aanpq-libgc-7.6.12/lib/libgc.so.1
#8  0xafb74298 in GC_malloc_kind_global () from 
/gnu/store/jsda4njqwjp4kb60fwa7n4mlfi1aanpq-libgc-7.6.12/lib/libgc.so.1
#9  0xafc11fa8 in scm_make_bytevector () from 
/gnu/store/7g3nbnf2kf31jk696k0nyz9ck55b11a0-guile-3.0.7/lib/libguile-3.0.so.1
#10 0xacacc418 in ?? ()
#11 0xacc2ef2c in ?? ()
(gdb) thr 4
[Switching to thread 4 (Thread 0xa641b1d0 (LWP 5674))]
#0  0xaf7b9d04 in clock_nanosleep@@GLIBC_2.17 () from 
/gnu/store/cb88z63hyg1icd2kkahiink2p291mhr2-glibc-2.31/lib/libc.so.6
(gdb) bt
#0  0xaf7b9d04 in clock_nanosleep@@GLIBC_2.17 () from 
/gnu/store/cb88z63hyg1icd2kkahiink2p291mhr2-glibc-2.31/lib/libc.so.6
#1  0xaf7bf55c in nanosleep () from 
/gnu/store/cb88z63hyg1icd2kkahiink2p291mhr2-glibc-2.31/lib/libc.so.6
#2  0xafb7e844 in GC_lock () from 
/gnu/store/jsda4njqwjp4kb60fwa7n4mlfi1aanpq-libgc-7.6.12/lib/libgc.so.1
#3  0xafb7ecdc in GC_do_blocking_inner () from 
/gnu/store/jsda4njqwjp4kb60fwa7n4mlfi1aanpq-libgc-7.6.12/lib/libgc.so.1
#4  0xafb73998 in GC_with_callee_saves_pushed () from 
/gnu/store/jsda4njqwjp4kb60fwa7n4mlfi1aanpq-libgc-7.6.12/lib/libgc.so.1
#5  0xafb79654 in GC_do_blocking () from 
/gnu/store/jsda4njqwjp4kb60fwa7n4mlfi1aanpq-libgc-7.6.12/lib/libgc.so.1
#6  0xafc96d94 in scm_without_guile () from 
/gnu/store/7g3nbnf2kf31jk696k0nyz9ck55b11a0-guile-3.0.7/lib/libguile-3.0.so.1
#7  0xafc97050 in scm_std_select () from 
/gnu/store/7g3nbnf2kf31jk696k0nyz9ck55b11a0-guile-3.0.7/lib/libguile-3.0.so.1
#8  0xafc97b5c in scm_std_sleep () from 
/gnu/store/7g3nbnf2kf31jk696k0nyz9ck55b11a0-guile-3.0.7/lib/libguile-3.0.so.1
#9  0xafc75918 in scm_sleep () from 
/gnu/store/7g3nbnf2kf31jk696k0nyz9ck55b11a0-guile-3.0.7/lib/libguile-3.0.so.1
#10 0xa6c50d94 in ?? ()
#11 0xacc2ee0c in ?? ()
--8<---cut here---end--->8---

The threads 1 and 4 do no respond anymore and are stuck, thread 1 on a
futex wait and thread 4 on a sleep, both in the GC library. For what
it's worth, I do not experiment this behaviour on x86 machines.

I tried to come up with a smaller reproducer without success, but I'll
keep trying.

Thanks,

Mathieu





bug#52482: [PATCH] doc/ref/texinfo.texi: corrected typo generare->generate

2021-12-14 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
Signed-off-by: Blake Shaw 
---
 doc/ref/texinfo.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/ref/texinfo.texi b/doc/ref/texinfo.texi
index 64a866b23..59df7f8e7 100644
--- a/doc/ref/texinfo.texi
+++ b/doc/ref/texinfo.texi
@@ -472,7 +472,7 @@ Serialize the stexi @var{tree} into plain texinfo.
 @node texinfo reflection
 @subsection (texinfo reflection)
 @subsubsection Overview
-Routines to generare @code{stexi} documentation for objects and modules.
+Routines to generate @code{stexi} documentation for objects and modules.
 
 Note that in this context, an @dfn{object} is just a value associated
 with a location. It has nothing to do with GOOPS.
-- 
2.33.1






bug#52436: [patch] autoconf: Check for gperf if running from git

2021-12-11 Thread Dr. Arne Babenhauserheide
Hi,

the attached patch adds a check for gperf.

From 478eb18a38eb8d15cc96fde148842cf0329bfba5 Mon Sep 17 00:00:00 2001
From: Arne Babenhauserheide 
Date: Mon, 11 Oct 2021 07:33:23 +0200
Subject: [PATCH] autoconf: Check for gperf if running from git

this avoids breaking at runtime.
---
 configure.ac | 9 +
 1 file changed, 9 insertions(+)

diff --git a/configure.ac b/configure.ac
index bd49bf162..bd4e9fd2f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,15 @@ else
   fi
 fi
 
+# Check for gperf if running from git
+AC_MSG_CHECKING([Checking for gperf if built from git])
+if ! test -f ".tarball-version" && false; then
+  AC_CHECK_TOOL([GPERF], [gperf], [no])
+  if test x"$GPERF" = x"no"; then
+AC_MSG_ERROR([Building from git requires gperf, but it could not be found. Please install gperf.])
+  fi
+fi
+
 gl_EARLY
 AC_PROG_CPP
 AC_PROG_SED
-- 
2.34.0


Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


bug#52434: [patch] [doc] add http-request example to web examples

2021-12-11 Thread Dr. Arne Babenhauserheide
Hi,

the attached patch adds a client example that access the hello-world server.

From 7d41deec7a550a186fb5e653a7007ae38fd62dbd Mon Sep 17 00:00:00 2001
From: Arne Babenhauserheide 
Date: Sat, 11 Dec 2021 15:43:21 +0100
Subject: [PATCH] doc: Provide full server<->client example

* doc/ref/web.texi: (Server: Hello, World!): Add Server:-Prefix to subsubsection

* doc/ref/web.texi: (Client: Visit the server): Example to access the
defined header.
---
 doc/ref/web.texi | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/ref/web.texi b/doc/ref/web.texi
index 93cd0214f..7d54a8f42 100644
--- a/doc/ref/web.texi
+++ b/doc/ref/web.texi
@@ -1833,7 +1833,7 @@ implementation's open function.
 
 Well, enough about the tedious internals.  Let's make a web application!
 
-@subsubsection Hello, World!
+@subsubsection Server: Hello, World!
 
 The first program we have to write, of course, is ``Hello, World!''.
 This means that we have to implement a web handler that does what we
@@ -1870,6 +1870,30 @@ By default, the web server listens for requests on
 @code{localhost:8080}.  Visit that address in your web browser to
 test.  If you see the string, @code{Hello World!}, sweet!
 
+@subsubsection Client: Visit the server
+
+The second program talks to our server.
+
+@example
+(use-modules (web client)
+ (web http)
+ (web uri)
+ (ice-9 receive))
+(receive (response-status response-body) 
+  (http-request "http://localhost:8080";
+#:method 'GET
+#:headers `((content-encoding . (gzip deflate))
+(user-agent . "guile web client")
+(referer . ,(string->uri "http://www.gnu.org";))
+(accept (*/*))
+(content-type . (application/json)))
+#:streaming? #f
+#:decode-body? #t
+#:body #f)
+ (display response-body))
+@end example
+
+
 @subsubsection Inspecting the Request
 
 The Hello World program above is a general greeter, responding to all
-- 
2.34.0


Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


bug#52218: Unable to define more than one R7RS library per file

2021-12-03 Thread Linus Björnstam
It is the same bug. The r7rs define-library expands to a r6rs library, which 
expands to a guile module form that lacks support for multiple libraries. The 
solution would probably include a non-trivial (but probably not very big) 
change to guile's module system.

First you would have to save and restore the current module before and after a 
module definition (maybe in save-module-excursion?). Then I would separate the 
library form the guile library form (since that doesn't encapsulate the body), 
by expanding it directly to the lower level module forms.

I might give it a shot.

-- 
  Linus Björnstam

On Thu, 2 Dec 2021, at 03:55, Sam Lee wrote:
> On 2021-12-01 11:00 +0100, Linus Björnstam wrote:
>> This is in line with the limitations of guile's R6RS implementation. I
>> think this is a long standing, low priority bug. It has to do with the
>> expansion of library (or define-library in this case) not properly
>> resetting the current module.
>>
>> In the manual there is a section called "R6RS incompatibilities" that
>> mentions this. Maybe an "R7RS incompatibilities" should be added.
>
> Hi Linus,
>
> There already exist a page in the manual about "Incompatibilities with
> the R7RS" [1]. Perhaps a paragraph similar to that found in the R6RS
> incompatibilities page should be added to the R7RS incompatibilities
> page. Something like this:
>
> "Multiple @code{define-library} forms in one file are not yet supported.
> This is because the expansion of @code{define-library} sets the current
> module, but does not restore it.  This is a bug."
>
> [1]: 
> https://www.gnu.org/software/guile/manual/html_node/R7RS-Incompatibilities.html





bug#52239: (No Subject)

2021-12-03 Thread Amirouche
fixed in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=40252





bug#52239: (No Subject)

2021-12-03 Thread Amirouche
I do not reproduce with guile (GNU Guile) 3.0.7.70-6af33





bug#52239: R7RS define-library does not support cond-expand

2021-12-02 Thread Amirouche
workaround:

#;> find live -type f -exec sh -c "echo \";;; cat {}\"; cat {}" \;
;;; cat live/hello/body.scm
(define (hello name)
  (display "Hello schemer ")
  (display name)
  (display "!")
  (newline))
;;; cat live/hello.scm
(define-library (live hello)
  (import (scheme base)
  (scheme write))
  (export hello)

  (include "hello/body.scm"))
;;; cat live/hello.sld
(define-library (live hello)
  (import (scheme base)
  (scheme write))
  (export hello)
  (cond-expand
   ((or mit guile chibi gambit gerbil loko)
(include "hello/body.scm"))
   ;; That is the rule picked up by chicken
   (else (include "live/hello/body.scm"
;;; cat live/hello.rkt
#!r7rs
(define-library (live hello)
  (export hello)

  (import (scheme base)
  (scheme write))

  (include "hello/body.scm"))
;;; cat live/hello.chez.sls
(library (live hello)
  (export hello)
  (import (chezscheme))

  (include "hello/body.scm"))
#;>

The following command

  guile myprogram.scm

will pick `live/hello.scm` as the library `(live hello)`

Unlike:

  guile --r7rs myprogram.scm

that will pick `live/hello.sld` that contains a cond-expand, and that is not 
supported  by guile.





bug#52218: Unable to define more than one R7RS library per file

2021-12-01 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
On 2021-12-01 11:00 +0100, Linus Björnstam wrote:
> This is in line with the limitations of guile's R6RS implementation. I
> think this is a long standing, low priority bug. It has to do with the
> expansion of library (or define-library in this case) not properly
> resetting the current module.
>
> In the manual there is a section called "R6RS incompatibilities" that
> mentions this. Maybe an "R7RS incompatibilities" should be added.

Hi Linus,

There already exist a page in the manual about "Incompatibilities with
the R7RS" [1]. Perhaps a paragraph similar to that found in the R6RS
incompatibilities page should be added to the R7RS incompatibilities
page. Something like this:

"Multiple @code{define-library} forms in one file are not yet supported.
This is because the expansion of @code{define-library} sets the current
module, but does not restore it.  This is a bug."

[1]: 
https://www.gnu.org/software/guile/manual/html_node/R7RS-Incompatibilities.html





bug#52230: Variable not visible to compiler causes compilation failure when importing module

2021-12-01 Thread Jean Abou Samra

In experiments with using guild for byte compilation
in LilyPond, I am hitting what seems like a bug. When
a variable is not defined declaratively in a way that
makes the compiler aware of it, the module it is
defined in can compile, but modules using it cannot.
Here is an example. fail.scm contains:

(define-module (fail))

variable-coming-from-somewhere-but-not-known-at-compile-time


import.scm is just:

(use-modules (fail))


Compiling fail.scm works:

$ guild compile fail.scm
fail.scm:3:0: warning: possibly unbound variable 
`variable-coming-from-somewhere-but-not-known-at-compile-time'

wrote `/home/jean/.cache/guile/ccache/3.0-LE-8-4.4/.../fail.scm.go'

Compiling import.scm gives this traceback:

$ guild compile -L . import.scm
Backtrace:
In system/base/compile.scm:
   327:39 19 (read-and-compile # #:from _ #:to …)
   261:27 18 (_ _ _)
In ice-9/boot-9.scm:
   2835:4 17 (save-module-excursion #)
In language/scheme/compile-tree-il.scm:
    31:15 16 (_)
In ice-9/psyntax.scm:
  1230:36 15 (expand-top-sequence (#) …)
  1222:19 14 (parse _ (("placeholder" placeholder)) ((top) #(# # …)) …)
   259:10 13 (parse _ (("placeholder" placeholder)) (()) _ c&e (# #) #)
In ice-9/boot-9.scm:
  3927:20 12 (process-use-modules _)
   222:17 11 (map1 (((fail
  3928:31 10 (_ ((fail)))
  3326:17  9 (resolve-interface (fail) #:select _ #:hide _ #:prefix _ …)
In ice-9/threads.scm:
    390:8  8 (_ _)
In ice-9/boot-9.scm:
  3252:13  7 (_)
In ice-9/threads.scm:
    390:8  6 (_ _)
In ice-9/boot-9.scm:
  3536:20  5 (_)
   2835:4  4 (save-module-excursion #)
  3556:26  3 (_)
In unknown file:
   2 (primitive-load-path "fail" #)
In fail.scm:
  3:0  1 (_)
In ice-9/boot-9.scm:
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Unbound variable: 
variable-coming-from-somewhere-but-not-known-at-compile-time



I would appreciate any workarounds.





bug#52218: Unable to define more than one R7RS library per file

2021-12-01 Thread Linus Björnstam
Hi Sam!

I am not a maintainer , nor a very proficient guile hacker, but I do have some 
input.

This is in line with the limitations of guile's R6RS implementation. I think 
this is a long standing, low priority bug. It has to do with the expansion of 
library (or define-library in this case) not properly resetting the current 
module. 

In the manual there is a section called "R6RS incompatibilities" that mentions 
this. Maybe an "R7RS incompatibilities" should be added.


Best regards
  Linus Björnstam

On Wed, 1 Dec 2021, at 08:45, Sam Lee via Bug reports for GUILE, GNU's 
Ubiquitous Extension Language wrote:
> Guile is unable to handle more than one define-library per file. For
> example, this is "mylibs.sld", which contains two define-library:
>
> (define-library (example mylib)
>   (import (scheme base))
>   (export f)
>   (begin
> (define (f x)
>   (+ x 1
>
> (define-library (example main)
>   (import (scheme base)
>   (scheme write)
>   (example mylib))
>   (export main)
>   (begin
> (define (main)
>   (display "The answer is: ")
>   (display (f 1))
>   (newline
>
>
> When loading this file into Guile using "guile -l mylibs.sld", or by
> using (load "mylibs.sld"), Guile will show this error:
>
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;;   or pass the --no-auto-compile argument to disable.
> ;;; compiling /home/user/mylibs.sld
> ;;; WARNING: compilation of /home/user/mylibs.sld failed:
> ;;; Syntax error:
> ;;; unknown location: definition in expression context, where 
> definitions are not allowed, in form (define (main) (display "The 
> answer is: ") (display (f 1)) (newline))
> ice-9/psyntax.scm:2794:12: In procedure syntax-violation:
> Syntax error:
> /home/user/mylibs.sld:14:4: definition in expression context, where 
> definitions are not allowed, in form (define (main) (display "The 
> answer is: ") (display (f 1)) (newline))
>
>
> The error is always caused by the second define-library. Apparently,
> Guile no longer understands that define-library is a special form by the
> time the second define-library is evaluated. Is it not possible to
> define two R7RS libraries in the same file?
>
> Guile version: 3.0.7





bug#52218: Unable to define more than one R7RS library per file

2021-12-01 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
Guile is unable to handle more than one define-library per file. For
example, this is "mylibs.sld", which contains two define-library:

(define-library (example mylib)
  (import (scheme base))
  (export f)
  (begin
(define (f x)
  (+ x 1

(define-library (example main)
  (import (scheme base)
  (scheme write)
  (example mylib))
  (export main)
  (begin
(define (main)
  (display "The answer is: ")
  (display (f 1))
  (newline


When loading this file into Guile using "guile -l mylibs.sld", or by
using (load "mylibs.sld"), Guile will show this error:

;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;   or pass the --no-auto-compile argument to disable.
;;; compiling /home/user/mylibs.sld
;;; WARNING: compilation of /home/user/mylibs.sld failed:
;;; Syntax error:
;;; unknown location: definition in expression context, where definitions are 
not allowed, in form (define (main) (display "The answer is: ") (display (f 1)) 
(newline))
ice-9/psyntax.scm:2794:12: In procedure syntax-violation:
Syntax error:
/home/user/mylibs.sld:14:4: definition in expression context, where definitions 
are not allowed, in form (define (main) (display "The answer is: ") (display (f 
1)) (newline))


The error is always caused by the second define-library. Apparently,
Guile no longer understands that define-library is a special form by the
time the second define-library is evaluated. Is it not possible to
define two R7RS libraries in the same file?

Guile version: 3.0.7





bug#52112: Compilation of macro returning record type fails

2021-11-26 Thread Jean Abou Samra

Thanks for your reply.

Le 26/11/2021 à 19:54, Taylan Kammer a écrit :

I don't think that's supposed to work.  I find it surprising that
record-type objects are self-evaluating, and in any case they can't
be turned into bytecode.

Your macro could return code that evaluates to a record definition.
Would that solve your use-case?



Yes, that is how I solved it in LilyPond
(https://gitlab.com/lilypond/lilypond/-/merge_requests/1026).

I was also somewhat surprised to see that
record types are self-evaluating. I don't
know where to check in R6RS what the expected
behavior would be. At any rate, it seems that
there is an inconsistency between the interpreter
and the compiler that would warrant resolving
either way.





bug#52112: Compilation of macro returning record type fails

2021-11-26 Thread Taylan Kammer
On 25.11.2021 18:45, Jean Abou Samra wrote:
> Record types are self-evaluating:
> 
> scheme@(guile-user)> (eval (make-record-type 'my-record '()) (current-module))
> $1 = #
> 
> Yet, when a macro returns a record type, Guile fails
> to byte-compile the code, even though the execution
> (via the evaluator) works fine. Here is a simple example:
> 
> 
> (define-macro (my-macro)
>   (make-record-type 'my-record-2 '()))
> 
> (display (my-macro))
> (newline)
> 
> 
> Execution log:
> 
> 
> $ guile --no-auto-compile test.scm
> #
> 
> $ guile test.scm
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;;   or pass the --no-auto-compile argument to disable.
> ;;; compiling /home/jean/test.scm
> ;;; WARNING: compilation of /home/jean/test.scm failed:
> ;;; unhandled constant #
> #
> 
> This is with Guile version 3.0.5.130-5a1e7.

I don't think that's supposed to work.  I find it surprising that
record-type objects are self-evaluating, and in any case they can't
be turned into bytecode.

Your macro could return code that evaluates to a record definition.
Would that solve your use-case?

-- 
Taylan





bug#52112: Compilation of macro returning record type fails

2021-11-25 Thread Jean Abou Samra

Record types are self-evaluating:

scheme@(guile-user)> (eval (make-record-type 'my-record '()) 
(current-module))

$1 = #

Yet, when a macro returns a record type, Guile fails
to byte-compile the code, even though the execution
(via the evaluator) works fine. Here is a simple example:


(define-macro (my-macro)
  (make-record-type 'my-record-2 '()))

(display (my-macro))
(newline)


Execution log:


$ guile --no-auto-compile test.scm
#

$ guile test.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;   or pass the --no-auto-compile argument to disable.
;;; compiling /home/jean/test.scm
;;; WARNING: compilation of /home/jean/test.scm failed:
;;; unhandled constant #
#

This is with Guile version 3.0.5.130-5a1e7.





bug#39947: [3.0.0] Compiler mishandles literal bignums passed to

2021-11-07 Thread lloda


Related: https://debbugs.gnu.org/50609






bug#50609: number overflow

2021-11-05 Thread lloda


I've applied the patch in c6b1171c6b5632ac04120f482af786444e17d3fe. Thanks for 
the report!






bug#48150: breaking gmp

2021-11-05 Thread lloda


Fixed in bf9d30f3c3fd03cb37d604f1927e9ce5c699338b. Thanks!






bug#50609: number overflow

2021-11-04 Thread lloda

Not quite comfortable poking around in the compiler, but find a patch attached.

I also found this related bug: 
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32644.




0001-Limit-the-range-of-ash-round-ash-count-argument-to-I.patch
Description: Binary data


0002-Avoid-ash-with-arguments-that-might-overflow-in-lang.patch
Description: Binary data




bug#45595: recvfrom! optional start and end parameter invalid

2021-11-03 Thread lloda


Hi,

Your patch didn't allow for start == end, which is valid as far as I can tell.

With that amended, applied in 1a8294f495cb202f8fcd0f260627c58e7a4c4d10. Thanks!







bug#50127: [PATCH] doc: Fix typos.

2021-11-03 Thread lloda


Patch applied in c5f443de79d1cb16ddf34873adb185599836a91b. Thanks!






bug#43987: strerror return value

2021-11-03 Thread lloda


Patch applied in ab9c0c9ca787da60ac9b956fdbcf4c1fa68c3300. Thanks!






bug#48816: guile: Add ARC support

2021-11-03 Thread lloda


Applied in 492bd638835c4c00623239190032770583e09714. Thanks!





bug#39601: srfi library naming in r7rs

2021-11-03 Thread Linus Björnstam
Well, as someone who has written a lot of macros 
https://srfi.schemers.org/srfi-206/ is a fantastic utility SRFI. It allows 
several libraries to define the same aux syntax (say like srfi-26's <>) without 
having collisions.

That is not strictly what you were looking for if I understand the patch 
correctly, though.

-- 
  Linus Björnstam

On Mon, 1 Nov 2021, at 19:42, Taylan Kammer wrote:
> On 01.11.2021 18:52, lloda wrote:
>> 
>> Hi Taylan,
>> 
>> Your patch leaks a bunch of identifiers, could you fix that?
>> 
>> thanks
>> 
>>  Daniel
>> 
>
> Apparently anything defined in boot-9 is implicitly made public in
> the (guile) module, I wasn't aware of that.
>
> Is there a work-around that allows one to define helpers that can
> be used by multiple definitions?
>
> Attached is a naive fix that duplicates a bunch of helpers which is
> not very nice.
>
> -- 
> Taylan
> Attachments:
> * 0001-Improve-support-for-R6-R7-SRFI-module-name-formats.patch





bug#39601: srfi library naming in r7rs

2021-11-02 Thread lloda


Applied in a960d7869bc82bb56d5446ece01b8efff9b15fef. Thank you!






bug#39601: srfi library naming in r7rs

2021-11-01 Thread Taylan Kammer
On 01.11.2021 18:52, lloda wrote:
> 
> Hi Taylan,
> 
> Your patch leaks a bunch of identifiers, could you fix that?
> 
> thanks
> 
>   Daniel
> 

Apparently anything defined in boot-9 is implicitly made public in
the (guile) module, I wasn't aware of that.

Is there a work-around that allows one to define helpers that can
be used by multiple definitions?

Attached is a naive fix that duplicates a bunch of helpers which is
not very nice.

-- 
TaylanFrom 1c655b291cfeb7f89bcc95c9c23c6013708e103a Mon Sep 17 00:00:00 2001
From: Taylan Kammer 
Date: Mon, 10 May 2021 18:12:34 +0200
Subject: [PATCH] Improve support for R6/R7 SRFI module name formats.

Fixes .

Partly fixes .

It was already possible to import an SRFI module by referencing it
as (srfi :n) which is automatically translated to (srfi srfi-n), but
this conversion was only done during import.  After this change, it's
also possible to define a library as (srfi :n) which is automatically
translated to (srfi srfi-n) during definition.

It was not possible at all to define or import SRFI module names in the
R7RS format, (srfi n), where n is a non-negative exact integer.  It is
now possible both to define and import them as such, realized through
the same kind of conversion to a canonical (srfi srfi-n) name.

* module/ice-9/r6rs-libraries.scm: Numerous changes.
---
 module/ice-9/r6rs-libraries.scm | 130 ++--
 1 file changed, 108 insertions(+), 22 deletions(-)

diff --git a/module/ice-9/r6rs-libraries.scm b/module/ice-9/r6rs-libraries.scm
index c6ba6a496..f27b07841 100644
--- a/module/ice-9/r6rs-libraries.scm
+++ b/module/ice-9/r6rs-libraries.scm
@@ -20,7 +20,53 @@
 ;; This file is included from boot-9.scm and assumes the existence of (and 
 ;; expands into) procedures and syntactic forms defined therein.
 
+;; Note that we can't use top-level define for helpers here as it will
+;; pollute the (guile) module.
+
 (define (resolve-r6rs-interface import-spec)
+  (define (sym? stx)
+(symbol? (syntax->datum stx)))
+
+  (define (n? stx)
+(let ((n (syntax->datum stx)))
+  (and (exact-integer? n)
+   (not (negative? n)
+
+  (define (colon-n? x)
+(let ((sym (syntax->datum x)))
+  (and (symbol? sym)
+   (let ((str (symbol->string sym)))
+ (and (string-prefix? ":" str)
+  (let ((num (string->number (substring str 1
+(and (exact-integer? num)
+ (not (negative? num)
+
+  (define (srfi-name? stx)
+(syntax-case stx (srfi)
+  ((srfi n rest ...)
+   (and (and-map sym? #'(rest ...))
+(or (n? #'n)
+(colon-n? #'n
+  (_ #f)))
+
+  (define (module-name? stx)
+(or (srfi-name? stx)
+(syntax-case stx ()
+  ((name name* ...)
+   (and-map sym? #'(name name* ...)))
+  (_ #f
+
+  (define (make-srfi-n context n)
+(datum->syntax
+ context
+ (string->symbol
+  (string-append
+   "srfi-"
+   (let ((n (syntax->datum n)))
+ (if (symbol? n)
+ (substring (symbol->string n) 1)
+ (number->string n)))
+
   (define (make-custom-interface mod)
 (let ((iface (make-module)))
   (set-module-kind! iface 'custom-interface)
@@ -37,27 +83,13 @@
 (for-each (lambda (mod)
 (module-for-each f mod))
   (module-and-uses mod)))
-  (define (sym? x) (symbol? (syntax->datum x)))
 
   (syntax-case import-spec (library only except prefix rename srfi)
 ;; (srfi :n ...) -> (srfi srfi-n ...)
 ;; (srfi n ...) -> (srfi srfi-n ...)
 ((library (srfi n rest ... (version ...)))
- (and (and-map sym? #'(srfi rest ...))
-  (or (and
-   (symbol? (syntax->datum #'n))
-   (let ((str (symbol->string (syntax->datum #'n
- (and (string-prefix? ":" str)
-  (and=> (string->number (substring str 1))
- exact-integer?
-  (exact-integer? (syntax->datum #'n
- (let ((srfi-n (string->symbol
-(string-append
- "srfi-"
- (let ((n (syntax->datum #'n)))
-   (if (symbol? n)
-   (substring (symbol->string n) 1)
-   (number->string n)))
+ (srfi-name? #'(srfi n rest ...))
+ (let ((srfi-n (make-srfi-n #'srfi #'n)))
(resolve-r6rs-interface
 (syntax-case #'(rest ...) ()
   (()
@@ -152,15 +184,58 @@
  (lp (cdr in) (cons (vector to replace? var) out
 
 ((name name* ... (version ...))
- (and-map sym? #'(name name* ...))
+ (module-name? #'(name name* ...))
  (resolve-r6rs-interface #'(library (name name* ... (version ...)
 
-((name name* ...) 
- (and-map sym? #'(name name* ...))
+((name name* ...)
+ (module-name?

bug#39601: srfi library naming in r7rs

2021-11-01 Thread lloda


Hi Taylan,

Your patch leaks a bunch of identifiers, could you fix that?

thanks

Daniel






bug#51445: (no subject)

2021-10-27 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
This is more of a feature request.  Apologies if this is an annoying
request.

So I made a pretty noobie-like mistake a few days ago using (guix
records).  When one tries to create a , he
invariably creates an infinite number of records.  The guile compiler
eventually runs out of memory and stops compiling with an error
message like:

fish: Job 1, 'guile break-guile-compiler.scm' terminated by signal SIGKILL 
(Forced quit)

I submitted this "bug" report to bug-g...@gnu.org as well.

http://issues.guix.gnu.org/51383

It probably will not be fixed at the (guix records) macro level
anytime soon, so I am submitting it here in case guile developers are
interested in improving their compiler error messages.  I came across
this compiler error while debugging my 1,000 line program.  Trying to
figure out what was wrong without any hints from appropriate error
messages was slightly confusing.

Here is the bad code:

(use-modules (guix records))

(define-record-type* 
  record-configuration make-record-configuration
  record-configuration?

  (command record-configuration-command
;; the error is here is on the next line
(default (record-configuration  

(record-configuration)


Thanks,
Joshua





bug#51264: Calling ‘texi-fragment->stexi’ in parallel leads to crashes

2021-10-22 Thread Ludovic Courtès
Ludovic Courtès  skribis:

> I just stumbled upon this bug (here I use Guix to feed Texinfo strings
> but I suppose we could reduce the test case to be Guix-less.)

Here’s a standalone reproducer:

(use-modules (texinfo)
 (sxml simple)
 (ice-9 threads))

(define sequential? (getenv "SEQUENTIAL"))

(define (for-each/maybe-parallel proc lst)
  (if (pk 'sequential? sequential?)
  (for-each proc lst)
  (n-par-for-each 6 proc lst)))

(setvbuf (current-output-port) 'none)
(for-each/maybe-parallel
 (lambda (str)
   (catch 'parser-error
 (lambda ()
   (texi-fragment->stexi str))
 (lambda args
   (pk 'bah! args '<<>> str)
   (error "failed"
 (make-list 5000 "Hello @code{world}, this is @emph{Texinfo}."))

It turned out that (sxml ssax input-parse) would reuse the same global
buffer for each call to ‘next-token’ and ‘next-token-of’ (the Texinfo
parser uses the latter).

Fixed in 3b42b1eb526a85e4fac772e1837046e56e3b9bdc.

Ludo’.


bug#51276: Problems with format and scaling floats

2021-10-19 Thread Bengt Richter
Nice catch :)

On +2021-10-18 17:22:49 -0400, Timothy Sample wrote:
> Hi Guilers,
> 
> It turns out there’s a little blunder in ‘format’ (from ‘ice-9’).  Look
> at what happens when using the SCALE argument to format a fixed-point
> float (this is Guile from the Git repo at the time of writing):
> 
> GNU Guile 3.0.7.6-22120
> Copyright (C) 1995-2021 Free Software Foundation, Inc.
> 
> Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
> This program is free software, and you are welcome to redistribute it
> under certain conditions; type `,show c' for details.
> 
> Enter `,help' for help.
> scheme@(guile-user)> (format #t "~,,3f~%" 0.00123)
> 0.23
> $3 = #t
> scheme@(guile-user)> (format #t "~,,1f~%" 0.00123)
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> Value out of range 0 to 400: -1
> 
> Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
> 
> The first example gives the wrong result.  Scaling 0.00123 by 3 should
> yield 1.23, not 0.23.  For the second example, instead of 0.0123, we get
> an error!  What’s going on here?
> 
> Well, our ‘format’ code comes from SLIB and was written in 1998, so it’s
> not easy to explain.  There’s so much mutation even a C programmer would
> blush!  ;)  The issue happens in the ‘format:parse-float’ procedure
> (which is defined inside of ‘format’).  It normalizes the string
> representation of a number, and applies the scale argument when needed.
> It does this by keeping a string of digits and the location of the
> decimal point.  Another thing it keeps track of the leading zeros in a
> variable called ‘left-zeros’.  Here’s the code that does the final
> shifting and places the decimal point:
> 
> (if (> left-zeros 0)
> (if (<= left-zeros shift) ; shift always > 0 here
> (format:fn-shiftleft shift) ; shift out 0s
> (begin
>   (format:fn-shiftleft left-zeros)
>   (set! format:fn-dot (- shift left-zeros
> (set! format:fn-dot (+ format:fn-dot shift)))
> 
> The issue is that the cases in the inner ‘if’ form are reversed.  That
> is, if there are MORE leading zeros than we need to shift, we can just
> shift.  Otherwise (if there are FEWER leading zeros), we need to shift
> out the zeros and then move the decimal point (‘format:fn-dot’).
> 
> AFAICS, this bug was in the original SLIB implementation (1998) and has
> not been fixed since then.  It’s been in Guile since 1999.
> 
> Anyway, that’s more than anyone cares to know  Here’s a patch with
> tests!  :)
> 

1999 until now (2021), /and/ reliably reproduced all that time! :)

-- 
Regards,
Bengt Richter





bug#51276: Problems with format and scaling floats

2021-10-18 Thread lloda


Thank you very much, patch applied!

Now that you've dived into (ice-9 format), what about this one:

(format #t "~,,2f~%" 0.01)
=> 1.0
(format #t "~,,3f~%" 0.01) ; !!
=> 010.0
(format #t "~,,3f~%" 0.001)
=> 1.0
(format #t "~,,4f~%" 0.001) ; !!
=> 0010.0
(format #t "~,,4f~%" 0.0001)
=> 1.0
(format #t "~,,5f~%" 0.0001) ; ok somehow...
=> 10.0

regards


> On 18 Oct 2021, at 23:22, Timothy Sample  wrote:
> 
> Hi Guilers,
> 
> It turns out there’s a little blunder in ‘format’ (from ‘ice-9’).  Look
> at what happens when using the SCALE argument to format a fixed-point
> float (this is Guile from the Git repo at the time of writing):
> 
>GNU Guile 3.0.7.6-22120
>Copyright (C) 1995-2021 Free Software Foundation, Inc.
> 
>Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
>This program is free software, and you are welcome to redistribute it
>under certain conditions; type `,show c' for details.
> 
>Enter `,help' for help.
>scheme@(guile-user)> (format #t "~,,3f~%" 0.00123)
>0.23
>$3 = #t
>scheme@(guile-user)> (format #t "~,,1f~%" 0.00123)
>ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>Value out of range 0 to 400: -1
> 
>Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
> 
> The first example gives the wrong result.  Scaling 0.00123 by 3 should
> yield 1.23, not 0.23.  For the second example, instead of 0.0123, we get
> an error!  What’s going on here?
> 
> Well, our ‘format’ code comes from SLIB and was written in 1998, so it’s
> not easy to explain.  There’s so much mutation even a C programmer would
> blush!  ;)  The issue happens in the ‘format:parse-float’ procedure
> (which is defined inside of ‘format’).  It normalizes the string
> representation of a number, and applies the scale argument when needed.
> It does this by keeping a string of digits and the location of the
> decimal point.  Another thing it keeps track of the leading zeros in a
> variable called ‘left-zeros’.  Here’s the code that does the final
> shifting and places the decimal point:
> 
>(if (> left-zeros 0)
>(if (<= left-zeros shift) ; shift always > 0 here
>(format:fn-shiftleft shift) ; shift out 0s
>(begin
>  (format:fn-shiftleft left-zeros)
>  (set! format:fn-dot (- shift left-zeros
>(set! format:fn-dot (+ format:fn-dot shift)))
> 
> The issue is that the cases in the inner ‘if’ form are reversed.  That
> is, if there are MORE leading zeros than we need to shift, we can just
> shift.  Otherwise (if there are FEWER leading zeros), we need to shift
> out the zeros and then move the decimal point (‘format:fn-dot’).
> 
> AFAICS, this bug was in the original SLIB implementation (1998) and has
> not been fixed since then.  It’s been in Guile since 1999.
> 
> Anyway, that’s more than anyone cares to know  Here’s a patch with
> tests!  :)
> 
> From c31d1f5d44343da1201ea1be86bc6b2ac8af6c8d Mon Sep 17 00:00:00 2001
> From: Timothy Sample 
> Date: Mon, 18 Oct 2021 17:07:41 -0400
> Subject: [PATCH] ice-9 format: Fix scaling floats with leading zeros
> 
> ---
> module/ice-9/format.scm  |  4 ++--
> test-suite/tests/format.test | 10 --
> 2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/module/ice-9/format.scm b/module/ice-9/format.scm
> index 48d9c0c84..ee7cba910 100644
> --- a/module/ice-9/format.scm
> +++ b/module/ice-9/format.scm
> @@ -1359,10 +1359,10 @@
>   (else
>(if (> left-zeros 0)
>(if (<= left-zeros shift) ; shift always > 0 here
> -   (format:fn-shiftleft shift) ; shift out 0s
>(begin
>  (format:fn-shiftleft left-zeros)
> - (set! format:fn-dot (- shift left-zeros
> + (set! format:fn-dot (- shift left-zeros)))
> +   (format:fn-shiftleft shift)) ; shift out 0s
>(set! format:fn-dot (+ format:fn-dot shift
> 
>(let ((negexp  ; expon format m.nnnEee
> diff --git a/test-suite/tests/format.test b/test-suite/tests/format.test
> index b9aa7a854..d5111f1c6 100644
> --- a/test-suite/tests/format.test
> +++ b/test-suite/tests/format.test
> @@ -2,7 +2,7 @@
>  Matthias Koeppe  --- June 2001
> 
>  Copyright (C) 2001, 2003, 2004, 2006, 2010, 2011, 2012,
> -   2014, 2017 Free Software Foundati

bug#51276: Problems with format and scaling floats

2021-10-18 Thread Timothy Sample
Hi Guilers,

It turns out there’s a little blunder in ‘format’ (from ‘ice-9’).  Look
at what happens when using the SCALE argument to format a fixed-point
float (this is Guile from the Git repo at the time of writing):

GNU Guile 3.0.7.6-22120
Copyright (C) 1995-2021 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (format #t "~,,3f~%" 0.00123)
0.23
$3 = #t
scheme@(guile-user)> (format #t "~,,1f~%" 0.00123)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Value out of range 0 to 400: -1

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.

The first example gives the wrong result.  Scaling 0.00123 by 3 should
yield 1.23, not 0.23.  For the second example, instead of 0.0123, we get
an error!  What’s going on here?

Well, our ‘format’ code comes from SLIB and was written in 1998, so it’s
not easy to explain.  There’s so much mutation even a C programmer would
blush!  ;)  The issue happens in the ‘format:parse-float’ procedure
(which is defined inside of ‘format’).  It normalizes the string
representation of a number, and applies the scale argument when needed.
It does this by keeping a string of digits and the location of the
decimal point.  Another thing it keeps track of the leading zeros in a
variable called ‘left-zeros’.  Here’s the code that does the final
shifting and places the decimal point:

(if (> left-zeros 0)
(if (<= left-zeros shift) ; shift always > 0 here
(format:fn-shiftleft shift) ; shift out 0s
(begin
  (format:fn-shiftleft left-zeros)
  (set! format:fn-dot (- shift left-zeros
(set! format:fn-dot (+ format:fn-dot shift)))

The issue is that the cases in the inner ‘if’ form are reversed.  That
is, if there are MORE leading zeros than we need to shift, we can just
shift.  Otherwise (if there are FEWER leading zeros), we need to shift
out the zeros and then move the decimal point (‘format:fn-dot’).

AFAICS, this bug was in the original SLIB implementation (1998) and has
not been fixed since then.  It’s been in Guile since 1999.

Anyway, that’s more than anyone cares to know  Here’s a patch with
tests!  :)

>From c31d1f5d44343da1201ea1be86bc6b2ac8af6c8d Mon Sep 17 00:00:00 2001
From: Timothy Sample 
Date: Mon, 18 Oct 2021 17:07:41 -0400
Subject: [PATCH] ice-9 format: Fix scaling floats with leading zeros

---
 module/ice-9/format.scm  |  4 ++--
 test-suite/tests/format.test | 10 --
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/module/ice-9/format.scm b/module/ice-9/format.scm
index 48d9c0c84..ee7cba910 100644
--- a/module/ice-9/format.scm
+++ b/module/ice-9/format.scm
@@ -1359,10 +1359,10 @@
   (else
(if (> left-zeros 0)
(if (<= left-zeros shift) ; shift always > 0 here
-   (format:fn-shiftleft shift) ; shift out 0s
(begin
  (format:fn-shiftleft left-zeros)
- (set! format:fn-dot (- shift left-zeros
+ (set! format:fn-dot (- shift left-zeros)))
+   (format:fn-shiftleft shift)) ; shift out 0s
(set! format:fn-dot (+ format:fn-dot shift
 
(let ((negexp  ; expon format m.nnnEee
diff --git a/test-suite/tests/format.test b/test-suite/tests/format.test
index b9aa7a854..d5111f1c6 100644
--- a/test-suite/tests/format.test
+++ b/test-suite/tests/format.test
@@ -2,7 +2,7 @@
  Matthias Koeppe  --- June 2001
 
  Copyright (C) 2001, 2003, 2004, 2006, 2010, 2011, 2012,
-   2014, 2017 Free Software Foundation, Inc.
+   2014, 2017, 2021 Free Software Foundation, Inc.
 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
@@ -121,7 +121,13 @@
   ;; in guile prior to 1.6.9 and 1.8.1, leading zeros were incorrectly
   ;; stripped, moving the decimal point and giving "25.0" here
   (pass-if "string 02.5"
-(string=? "2.5" (format #f "~f" "02.5"
+(string=? "2.5" (format #f "~f" "02.5")))
+
+  (pass-if "scale with few leading zeros"
+(string=? "1.23" (format #f "~,,3f" "0.00123")))
+
+  (pass-if "scale with many leading zeros"
+(string=? "0.0123" (format #f "~,,1f" "0.00123"
 
 ;;;
 ;;; ~h
-- 
2.33.0



bug#51264: Calling ‘texi-fragment->stexi’ in parallel leads to crashes

2021-10-18 Thread Ludovic Courtès
Hello!

I just stumbled upon this bug (here I use Guix to feed Texinfo strings
but I suppose we could reduce the test case to be Guix-less.)

Test case:

(use-modules (guix) (gnu) (texinfo)
 (ice-9 threads))

(define sequential? (getenv "SEQUENTIAL"))

(define (for-each/maybe-parallel proc lst)
  (if (pk 'sequential? sequential?)
  (for-each proc lst)
  (n-par-for-each 10 proc lst)))

(for-each/maybe-parallel
 (lambda (package)
   (and=> (package-description package)
  (lambda (str)
(catch 'parser-error
  (lambda ()
(texi-fragment->stexi str))
  (lambda args
(pk 'bah! args)
(error "failed"))
 (fold-packages cons '()))

This code crashes when using ‘n-par-for-each’ but passes when run
sequentially:

--8<---cut here---start->8---
$ guix time-machine --commit=9cda21cf20a5c9bdf97e3a6d6c8f901fc3e4307d -- repl 
-- bug-texi-parser-parallel.scm

;;; (sequential? #f)

;;; (bah! (parser-error #f "Unknown command" codeand))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" endm))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" cod))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" comm))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" enum))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" cod))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" enem))
In thread:
failed


;;; (bah! (parser-error #f "Unknown command" endmand))
In thread:
failed
; (bah! (parser-error #f "Unknown command" eomm))
In thread:
failed
$ SEQUENTIAL=y guix time-machine 
--commit=9cda21cf20a5c9bdf97e3a6d6c8f901fc3e4307d -- repl -- 
bug-texi-parser-parallel.scm

;;; (sequential? "y")
$ guix repl -- <(echo '(pk (version))')

;;; ("3.0.7")
--8<---cut here---end--->8---

The bits shown in the ‘parser-error’ arguments suggests memory
corruption.

Ludo’.


bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase

2021-10-12 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
jaku...@riseup.net writes:

> You're right but you didn't address my second point.
> The fact that with this patch
>
> (call-with-input-string "HTTP/1.1 \n"
>   (lambda (port) (read-response-line port)))

I see, my bad, thanks! Please find a newly attached patch.

I added a test for such a case, but I am not sure about the indentation
though. Please let me know what you think.

-- 
Alexey

>From b589595db9ab448aa52d002c34d7919a601904e4 Mon Sep 17 00:00:00 2001
From: Alexey Abramov 
Date: Thu, 7 Oct 2021 13:45:02 +0200
Subject: [PATCH] http: Tolerate http response line without a reason phrase

* module/web/http.scm (read-response-line): Use the end of the string,
in case a line doesn't have char-set:whitespace at the end.
* test-suite/tests/web-http.test ("read-response-line"): Add tests.
* .dir-locals.el (scheme-mode): Add indentation rule for pass-if-named-exception.
---
 .dir-locals.el |  1 +
 module/web/http.scm| 20 +---
 test-suite/tests/web-http.test |  8 +++-
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index 90257e7bf..e94ceb723 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -10,6 +10,7 @@
  (eval . (put 'let/ec  'scheme-indent-function 1))
  (eval . (put 'pass-if 'scheme-indent-function 1))
  (eval . (put 'pass-if-exception   'scheme-indent-function 2))
+ (eval . (put 'pass-if-named-exception   'scheme-indent-function 3))
  (eval . (put 'pass-if-equal   'scheme-indent-function 2))
  (eval . (put 'with-test-prefix'scheme-indent-function 1))
  (eval . (put 'with-test-prefix/c&e 'scheme-indent-function 1))
diff --git a/module/web/http.scm b/module/web/http.scm
index 4276e1744..4053e5271 100644
--- a/module/web/http.scm
+++ b/module/web/http.scm
@@ -1187,14 +1187,20 @@ values: the HTTP version, the response code, and the (possibly empty)
 \"reason phrase\"."
   (let* ((line (read-header-line port))
  (d0 (string-index line char-set:whitespace)) ; "delimiter zero"
- (d1 (and d0 (string-index line char-set:whitespace
-   (skip-whitespace line d0)
-(unless (and d0 d1)
+ (d1 (and d0 (or (string-index line char-set:whitespace
+   (skip-whitespace line d0))
+ ;; tolerate responses with empty "reason phrase"
+ (string-length line)
+(cond
+ ((not d0)
+  (bad-response "Bad Response-Line: ~s" line))
+ ((and d0 d1 (string-null? (string-trim (substring line d0 d1
   (bad-response "Bad Response-Line: ~s" line))
-(values (parse-http-version line 0 d0)
-(parse-non-negative-integer line (skip-whitespace line d0 d1)
-d1)
-(string-trim-both line char-set:whitespace d1
+ (else
+  (values (parse-http-version line 0 d0)
+  (parse-non-negative-integer line (skip-whitespace line d0 d1)
+  d1)
+  (string-trim-both line char-set:whitespace d1))
 
 (define (write-response-line version code reason-phrase port)
   "Write the first line of an HTTP response to PORT."
diff --git a/test-suite/tests/web-http.test b/test-suite/tests/web-http.test
index 63377349c..7d4885722 100644
--- a/test-suite/tests/web-http.test
+++ b/test-suite/tests/web-http.test
@@ -216,7 +216,13 @@
 
   ;; Empty reason phrases are valid; see .
   (pass-if-read-response-line "HTTP/1.1 302 "
-  (1 . 1) 302 ""))
+  (1 . 1) 302 "")
+  (pass-if-read-response-line "HTTP/1.1 302"
+  (1 . 1) 302 "")
+  (pass-if-named-exception "missing HTTP code" bad-response "Bad Response-Line"
+(call-with-input-string "HTTP/1.1 \n"
+  (lambda (port)
+(read-response-line port)
 
 (with-test-prefix "write-response-line"
   (pass-if-write-response-line "HTTP/1.0 404 Not Found"
-- 
2.31.1



bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase

2021-10-12 Thread jakub-w
You're right but you didn't address my second point.
The fact that with this patch

(call-with-input-string "HTTP/1.1 \n"
  (lambda (port) (read-response-line port)))

passes the check for 'bad-response error inside read-response-line. It
throws 'bad-header-component from non-negative-integer instead because
d1 is always true if d0 is true.





bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase

2021-10-12 Thread tomas
On Tue, Oct 12, 2021 at 10:26:22AM +0200, Alexey Abramov via Bug reports for 
GUILE, GNU's Ubiquitous Extension Language wrote:
> Hi,
> 
> I agree that it is not a complient http response,

According to The Book [1] ;-) there should be at least one
space (SP) (as far as I understand this is really a true
honest space, Unicode codepoint 32. It is /not/ part of the
message (aka "reason phrase") , but a separator. The rule
is:

  status-line = HTTP-version SP status-code SP reason-phrase CRLF

The reason phrase itself can contain whatever funny whitespace
it wants:

  reason-phrase  = *( HTAB / SP / VCHAR / obs-text )

and it /can/ be empty.

That said I'd agree that it makes sense to tolerate a missing
SP there. The legal minimum seems thus to be

  HTTP-version SP status-code SP CRLF

>  but unfortunately I
> came across with some http services (redfish, cimc from Cisco )

uh-oh. All bets are off, then ;-)


> where they don't put a reason phrase.

That would be OK, but they also eat the mandatory separator space
before the empty reason phrase. Bad folks, bad ;-)

As an onlooker I haven't much to say, but I think you are right
(but not Cisco :)

Cheers
 - t


signature.asc
Description: Digital signature


bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase

2021-10-12 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
Hi,

I agree that it is not a complient http response, but unfortunately I
came across with some http services (redfish, cimc from Cisco ), where
they don't put a reason phrase. As you can see the difference is that
response line doesn't have a space after the response code, that is why
it raise an exception even though the documentation says 'and the
(possibly empty) "reason phrase"'. 

I would call it as a follow up to f53145d41.

-- 
Alexey





bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase

2021-10-12 Thread jakub-w
I don't think the reason phrase is optional, even though it can be just
a whitespace.
Even if I'm not mistaken, however, I don't see the reason for Guile not
to be able to parse the status line without a space at the end.

Aside from that consider a string "HTTP/1.1 ", which should be a bad
response because the status code should definitely be obligatory,
however it passes through the (and d0 d1) check after applying this
patch.





bug#51133: [PATCH 1/1] Tolerate http response line without reason phrase

2021-10-11 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
* module/web/http.scm (read-response-line): Use the end of the string,
in case a line doesn't have char-set:whitespace at the end.
* test-suite/tests/web-http.test ("read-response-line"): Add test.
---
 module/web/http.scm| 6 --
 test-suite/tests/web-http.test | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/module/web/http.scm b/module/web/http.scm
index 4276e1744..7443bd6a4 100644
--- a/module/web/http.scm
+++ b/module/web/http.scm
@@ -1187,8 +1187,10 @@ values: the HTTP version, the response code, and the 
(possibly empty)
 \"reason phrase\"."
   (let* ((line (read-header-line port))
  (d0 (string-index line char-set:whitespace)) ; "delimiter zero"
- (d1 (and d0 (string-index line char-set:whitespace
-   (skip-whitespace line d0)
+ (d1 (and d0 (or (string-index line char-set:whitespace
+   (skip-whitespace line d0))
+ ;; tolerate responses with empty "reason phrase"
+ (string-length line)
 (unless (and d0 d1)
   (bad-response "Bad Response-Line: ~s" line))
 (values (parse-http-version line 0 d0)
diff --git a/test-suite/tests/web-http.test b/test-suite/tests/web-http.test
index 63377349c..6d8cd1642 100644
--- a/test-suite/tests/web-http.test
+++ b/test-suite/tests/web-http.test
@@ -216,6 +216,8 @@
 
   ;; Empty reason phrases are valid; see .
   (pass-if-read-response-line "HTTP/1.1 302 "
+  (1 . 1) 302 "")
+  (pass-if-read-response-line "HTTP/1.1 302"
   (1 . 1) 302 ""))
 
 (with-test-prefix "write-response-line"
-- 
2.31.1






bug#51129: Check for gperf if running from git: this avoids breaking at runtime.

2021-10-10 Thread Dr. Arne Babenhauserheide
From 0b70a54dd7df0075c392067a7ce17d0f05a59adf Mon Sep 17 00:00:00 2001
From: Arne Babenhauserheide 
Date: Mon, 11 Oct 2021 07:33:23 +0200
Subject: [PATCH] autoconf: Check for gperf if running from git

this avoids breaking at runtime.
---
 configure.ac | 9 +
 1 file changed, 9 insertions(+)

diff --git a/configure.ac b/configure.ac
index a3cdaff78..5e1231a6e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,6 +80,15 @@ else
   fi
 fi
 
+# Check for gperf if running from git
+AC_MSG_CHECKING([Checking for gperf if built from git])
+if ! test -f ".tarball-version" && false; then
+  AC_CHECK_TOOL([GPERF], [gperf], [no])
+  if test x"$GPERF" = x"no"; then
+AC_MSG_ERROR([Building from git requires gperf, but it could not be found. Please install gperf.])
+  fi
+fi
+
 gl_EARLY
 AC_PROG_CPP
 AC_PROG_SED
-- 
2.33.0


-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de


signature.asc
Description: PGP signature


bug#45214: guile segfaults on 32-bit big-endian targets

2021-10-04 Thread John Paul Adrian Glaubitz
On 10/4/21 18:08, John David Anglin wrote:
> On 2021-10-03 5:38 a.m., John Paul Adrian Glaubitz wrote:
>> I can confirm that adding "-Oresolve-primitives -Ocps" to GUILE_OPTIMIZATIONS
>> in bootstrap/Makefile.am fixes the problem for me on 32-bit PowerPC on 
>> Debian.
>
> It also fixes the build on Debian hppa.

And m68k as I verified today.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913






bug#45214: guile segfaults on 32-bit big-endian targets

2021-10-04 Thread John David Anglin
On 2021-10-03 5:38 a.m., John Paul Adrian Glaubitz wrote:
> I can confirm that adding "-Oresolve-primitives -Ocps" to GUILE_OPTIMIZATIONS
> in bootstrap/Makefile.am fixes the problem for me on 32-bit PowerPC on Debian.
It also fixes the build on Debian hppa.

Dave

-- 
John David Anglin  dave.ang...@bell.net






bug#45214: guile segfaults on 32-bit big-endian targets

2021-10-03 Thread John Paul Adrian Glaubitz
Hi Efraim!

On 4/14/21 16:18, Efraim Flashner wrote:
> I spent some more time bisecting guile so I could create a diff against
> 3.0.5 and then spent another two weeks or so bootstrapping Guix from my
> custom bootstrap binaries out to mesa.
> 
> I've attached the patch that's likely to go into Guix to add powerpc
> support. Other than the mysterious failing test I've changed the
> GUILE_OPTIMIZATIONS in bootstrap/Makefile.in to '-O1
> -Oresolve-primitives -Ocps' on powerpc and it seems to be working fine.

I can confirm that adding "-Oresolve-primitives -Ocps" to GUILE_OPTIMIZATIONS
in bootstrap/Makefile.am fixes the problem for me on 32-bit PowerPC on Debian.

I will have to figure out how to add "-Oresolve-primitives -Ocps" on 32-bit
big-endian conditionally so that it is not passed for other architectures.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913






bug#50730: suspendable-ports.test: test case fails

2021-09-21 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
This bug was originally reported to bug-g...@gnu.org. Copying here.
Guix bug report: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=50729

I suspect it may be a bug in my kernel if not a bug in guile itself.

The test case fails on both master and v3.0.7 (git).

./build-aux/config.guess
x86_64-pc-linux-gnu

./config.status --config
--enable-mini-gmp
PKG_CONFIG_PATH=/gnu/store/06prap3plk2f59n8m3diqzqd6dxvklhn-profile/lib/pkgconfig

-

This test case is consistently failing on my machine when building guile:

./pre-inst-env guix build guile

...
Running suspendable-ports.test
UNRESOLVED: suspendable-ports.test: non-revealed port is closed
ERROR: suspendable-ports.test: revealed port fdes not closed -
arguments: ((system-error "seek" "~A" ("Bad file descriptor") (9)))

Totals for this test run:
passes: 42439
failures:   0
unexpected passes:  0
expected failures:  10
unresolved test cases:  554
untested test cases:1
unsupported test cases: 1
errors: 1

Kernel: Linux bb11 5.14.3 #1 SMP 1 x86_64 GNU/Linux

Guix commit: c4b7bcc2569e40c6b925bc9e8fde01c5744c29f7

Log file attached.

--
Sincerely,
Ryan Sundberg



r9v799msq0y4d2cml9kcs9bizfm52v-guile-3.0.7.drv.bz2
Description: application/bzip


OpenPGP_signature
Description: OpenPGP digital signature


bug#50719: Cannot add a no-applicable-method implementation for a generic with no method

2021-09-21 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
Dear guile,

The following program should just return 'foo, but it enters an
infinite loop:

(use-modules (oop goops))

(define-class  ())

(define-method (no-method (generic ) args)
  'foo)

(define-method (no-applicable-method (generic ) args)
  'foo)

(define hello
  (make 
#:name 'hello))

(hello)

I don’t know GOOPS enough to understand what happens, but when I
slightly change the last line:

(use-modules (oop goops))

(define-class  ())

(define-method (no-method (generic ) args)
  'foo)

(define-method (no-applicable-method (generic ) args)
  'foo)

(define hello
  (make 
#:name 'hello))

(apply-generic hello '())

Now it returns 'foo, as expected. So my guess is that the infinite
loops happens during the memoization phase. More specifically, the no-
applicable-method is called over and over again.

Please find a failing test case attached.

Best regards,

Vivien
From 435d4d7569a25dda05489c3eda3086e0dbf531af Mon Sep 17 00:00:00 2001
From: Vivien Kraus 
Date: Tue, 21 Sep 2021 11:40:43 +0200
Subject: [PATCH] goops: cannot override no-applicable-method for a generic
 that has no methods

---
 test-suite/tests/goops.test | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/test-suite/tests/goops.test b/test-suite/tests/goops.test
index b06ba98b2..626eeaacd 100644
--- a/test-suite/tests/goops.test
+++ b/test-suite/tests/goops.test
@@ -761,3 +761,22 @@
   #:metaclass )))
   (pass-if-equal 123 (get-the-bar (make )))
   (pass-if-equal 123 (get-the-bar (make ))
+
+(with-test-prefix "Can override no-applicable-method in a generic without methods"
+  (let ((patience-no-method 10)
+(patience-no-applicable-method 10))
+(define-class  ())
+(define-method (no-method (generic ) args)
+  (when (= patience-no-method 0)
+(error "Infinite loop detected in no-method"))
+  (set! patience-no-method (- patience-no-method 1))
+  'foo)
+(define-method (no-applicable-method (generic ) args)
+  (when (= patience-no-applicable-method 0)
+(error "Infinite loop detected in no-applicable-method"))
+  (set! patience-no-applicable-method (- patience-no-applicable-method 1))
+  'foo)
+(define hello
+  (make 
+#:name 'hello))
+(pass-if-equal (hello) 'foo)))
-- 
2.33.0



bug#50609: number overflow

2021-09-15 Thread Stefan Israelsson Tampe
This does not compile on guile 3.0.7,

(define (f . l)
  (let lp2 ((i 0) (s 0) (l l))
(if (and (pair? l) (< i 64))
 (lp2 (+ i 1) (if (car l) (logior (ash 1 i) s) s) (cdr l))
 s)))

While compiling expression:
Throw to key `numerical-overflow' with args `("ash" "Numerical ove
rflow" #f #f)'.


bug#50608: Fix for ‘, trace (method ()) --> no applicable method for ...’

2021-09-15 Thread Maxime Devos
Hi guile,

Attached is a fix for <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=50608>
and a similar issue for 'procedure-name'.

Greetings,
Maxime.
From fe518ed4fb2c7e55f69a229349e3183ccfdcfc97 Mon Sep 17 00:00:00 2001
From: Maxime Devos 
Date: Wed, 15 Sep 2021 19:57:20 +0200
Subject: [PATCH 1/2] goops: Let 'write' succeed when objects are
 uninitialised.

* module/oop/goops.scm (generic-function-methods)[fold-upwards,fold-downward]:
Allow 'gfs' to be #f.
(write)[]: Allow 'spec' to be #f.
* test-suite/tests/goops.test ("writing uninitialised objects"): New test.
---
 module/oop/goops.scm| 18 +++---
 test-suite/tests/goops.test | 19 +++
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/module/oop/goops.scm b/module/oop/goops.scm
index de5e8907d..4a4cdd034 100644
--- a/module/oop/goops.scm
+++ b/module/oop/goops.scm
@@ -3,6 +3,7 @@
  Copyright (C) 1998-2003,2006,2009-2011,2013-2015,2017-2018,2021
    Free Software Foundation, Inc.
  Copyright (C) 1993-1998 Erick Gallesio - I3S-CNRS/ESSI 
+ Copyright (C) 2021 Maxime Devos 
 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
@@ -1990,7 +1991,9 @@ function."
   (() method-lists)
   ((gf . gfs)
(lp (fold-upward (cons (slot-ref gf 'methods) method-lists) gf)
-   gfs)
+   gfs))
+  ;; See 'fold-downwards'.
+  (#f '()
  (else method-lists)))
   (define (fold-downward method-lists gf)
 (let lp ((method-lists (cons (slot-ref gf 'methods) method-lists))
@@ -1998,7 +2001,14 @@ function."
   (match gfs
 (() method-lists)
 ((gf . gfs)
- (lp (fold-downward method-lists gf) gfs)
+ (lp (fold-downward method-lists gf) gfs))
+;; 'write' may be called on an uninitialised 
+;; (e.g. from ,trace in a REPL) in which case
+;; 'generic-function-methods' will be called
+;; on a  whose 'extended-by' slot is #f.
+;; In that case, just return the empty list to make 'write'
+;; happy.
+(#f '()
   (unless (is-a? obj )
 (scm-error 'wrong-type-arg #f "Not a generic: ~S"
(list obj) #f))
@@ -2394,7 +2404,9 @@ function."
   (display (class-name meta) file)
   (display #\space file)
   (display (map* (lambda (spec)
-   (if (slot-bound? spec 'name)
+   ;; 'spec' is false if 'o' is not yet
+   ;; initialised
+   (if (and spec (slot-bound? spec 'name))
(slot-ref spec 'name)
spec))
  (method-specializers o))
diff --git a/test-suite/tests/goops.test b/test-suite/tests/goops.test
index b06ba98b2..f70c1e1e4 100644
--- a/test-suite/tests/goops.test
+++ b/test-suite/tests/goops.test
@@ -1,6 +1,7 @@
  goops.test --- test suite for GOOPS  -*- scheme -*-
 
  Copyright (C) 2001,2003,2004, 2006, 2008, 2009, 2011, 2012, 2014, 2015, 2017, 2021 Free Software Foundation, Inc.
+ Copyright (C) 2021 Maxime Devos 
  
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
@@ -761,3 +762,21 @@
   #:metaclass )))
   (pass-if-equal 123 (get-the-bar (make )))
   (pass-if-equal 123 (get-the-bar (make ))
+
+;; 'write' can be called on initialised objects, e.g. from
+;; ,trace in a REPL.  Make sure this doesn't result in any
+;; exceptions.  The exact output doesn't matter in this case.
+(with-test-prefix "writing uninitialised objects"
+  (define (make-uninitialised class)
+(allocate-struct class (length (class-slots class
+  (define (test class)
+(pass-if (class-name class)
+  (string? (object->string (make-uninitialised class)
+  (module-for-each
+   (lambda (name variable)
+ (define value (and (variable-bound? variable)
+(variable-ref variable)))
+ (when (and (is-a? value )
+(not (eq? value )))
+   (test value)))
+   (resolve-module '(oop goops
-- 
2.33.0

From 4e1c9e9d5f90f39f2bec033399c3e77127aa5e1f Mon Sep 17 00:00:00 2001
From: Maxime Devos 
Date: Wed, 15 Sep 2021 20:25:58 +0200
Subject: [PATCH 2/2] procedure-name: Allow uninitialised applicable structs.

* libguile/procproc.c (scm_procedure_name): Allow the procedure in an
applicable struct to be #f.
* test-suite/tests/procproc.test ("uninitialised applicable struct"):
Test it.
---
 libguile/procprop.c| 21 ++---
 test-suite/tests/

bug#50608: ,trace (method ()) --> no applicable method for ...

2021-09-15 Thread Maxime Devos
Hi guile,

Try running the following from a repl:

(use-modules (oop goops))
(method ())
;; --> $1 = #< () 7fbb1bcb47c0>
,trace (method ())
--->
[...]
trace: |  |  (_ #<  7fbb1bc67c80> (#:specializers () #:formals 
() #:body ((if #f …)) …))
trace: |  |  |  (struct-ref/unboxed #<  7fbb1bc67c80> 5)
trace: |  |  |  6
trace: |  |  |  (allocate-struct #<  7fbb1bc67c80> 6)
trace: |  |  |  While executing meta-command:
No applicable method for #< slot-missing (3)> in call (slot-missing 
#<  7fbb1bc67180> #f name)

The issue is that an instance of  is being written to
a port before it has been initialised, which various procedures in
(oop goops) don't expect.

I'll send a patch to guile-de...@gnu.org with a fix for 
and some other classes.

Greetings,
Maxime.


signature.asc
Description: This is a digitally signed message part


bug#50562: Wrong link at the "further reading" section of doc.

2021-09-13 Thread slbtty
Dorai Sitaram’s online Scheme tutorial, Teach Yourself Scheme in
Fixnum Days, is no longer at the link as indicated by current guile
doc.

The new link is https://ds26gte.github.io/tyscheme/index.html

Link to the wrong guile doc ->
https://www.gnu.org/software/guile/manual/html_node/Further-Reading.html#Further-Reading





bug#50561: Wrong link at the "further reading" section of doc.

2021-09-13 Thread slbtty
Dorai Sitaram’s online Scheme tutorial, Teach Yourself Scheme in
Fixnum Days, is no longer at the link as indicated by current guile
doc.

The new link is https://ds26gte.github.io/tyscheme/index.html


Link to the wrong guile doc ->
https://www.gnu.org/software/guile/manual/html_node/Further-Reading.html#Further-Reading





bug#48816: Ping

2021-08-27 Thread Bug reports for GUILE, GNU's Ubiquitous Extension Language
Hello,

Just a gentle reminder.
We need this package for bootstrapping Debian port for ARC.
Hopefully already attached patch would help.

-Alexey

X-Debbugs-CC: 
linux-snps-...@lists.infradead.org,guil...@debian.org,hel...@subdivi.de




bug#39954: bug#50153: Acknowledgement (call-with-values outside tail position + backtrace + compilation causes segfault)

2021-08-22 Thread Maxime Devos
I did some debugging on the C side, using 'rr':

LD_LIBRARY_PATH=.libs ../meta/uninstalled-env rr record ./.libs/guile 
--fresh-auto-compile -l ../crash.scm

it leads to a segfault, as expected.  According to #39954, which looks
similar, 'frame-local-ref' returns (SCM)0x0.  So I tried some reverse debugging:

rr replay guile-3
break scm_frame_local_ref
reverse-continue
reverse-continue

I noticed "repr" was STACK_ITEM_SCM, and item->as_scm was set to 0x07
(which is invalid).  On another run, it was set to 0x09 (also invalid?).
I modified scm_frame_local_ref a bit so it ignores these 0x07 and 0x09
and treats them like SCM_EOF_VAL instead.  That allows printing the backtrace,
though I don't see those # appearing in the output.

Would someone know what's going on here?

Greetings,
Maxime
diff --git a/libguile/frames.c b/libguile/frames.c
index 0bb40579c..87afaec3d 100644
--- a/libguile/frames.c
+++ b/libguile/frames.c
@@ -41,6 +41,7 @@
 
 #include "frames.h"
 
+#include 
 
 SCM
 scm_c_make_frame (enum scm_vm_frame_kind kind, const struct scm_frame *frame)
@@ -272,6 +273,11 @@ scm_frame_local_ref (SCM frame, SCM index, SCM representation)
   switch (repr)
 {
   case STACK_ITEM_SCM:
+fprintf(stderr, "i: %u  SCM: %p\n", (unsigned) i, (void*)item->as_u64);
+if (item->as_u64 == 0x07)
+  return SCM_EOF_VAL;
+if (item->as_u64 == 0x09)
+  return SCM_EOF_VAL;
 return item->as_scm;
   case STACK_ITEM_F64:
 return scm_from_double (item->as_f64);


signature.asc
Description: This is a digitally signed message part


bug#50153: Acknowledgement (call-with-values outside tail position + backtrace + compilation causes segfault)

2021-08-21 Thread Maxime Devos
This looks rather similar to 39...@debbugs.gnu.org,
looking at the backtrace from GDB, maybe the cause is the same?

Thread 1 "guile" received signal SIGSEGV, Segmentation fault.
0x77f40f3f in scm_is_values (x=) at values.h:30
30return SCM_HAS_TYP7 (x, scm_tc7_values);
(gdb) bt
#0  0x77f40f3f in scm_is_values (x=) at values.h:30
#1  vm_debug_engine (thread=0x7744cd80) at vm-engine.c:974
#2  0x77f45c2d in scm_call_n (proc=0x749612a0, 
argv=argv@entry=0x7fffc080, 
nargs=nargs@entry=4) at vm.c:1608
#3  0x77ec1234 in scm_call_4 (proc=, 
arg1=arg1@entry=0x735162d0, 
arg2=arg2@entry=0x75ad4600, arg3=arg3@entry=0x7495a0b0, 
arg4=arg4@entry=0x52) at eval.c:517
#4  0x77eb3815 in display_backtrace_body (a=) at 
backtrace.c:239
#5  0x77ec29ea in scm_c_with_exception_handler (type=type@entry=0x404, 
handler=handler@entry=0x77f3aed0 , 
handler_data=handler_data@entry=0x7fffc230, 
thunk=thunk@entry=0x77f3b010 , 
thunk_data=thunk_data@entry=0x7fffc230) at exceptions.c:170
#6  0x77f3b20d in scm_c_catch (tag=tag@entry=0x404, 
body=body@entry=0x77eb36f0 , 
body_data=body_data@entry=0x7fffc2a0, 
handler=handler@entry=0x77eb3b20 , 
handler_data=handler_data@entry=0x75ad4600, 
pre_unwind_handler=pre_unwind_handler@entry=0x0, 
pre_unwind_handler_data=0x0) at throw.c:168
#7  0x77f3b22e in scm_internal_catch (tag=tag@entry=0x404, 
body=body@entry=0x77eb36f0 , 
body_data=body_data@entry=0x7fffc2a0, 
handler=handler@entry=0x77eb3b20 , 
handler_data=handler_data@entry=0x75ad4600) at throw.c:177
#8  0x77eb36e5 in scm_display_backtrace_with_highlights 
(stack=stack@entry=0x738604a0, 
port=port@entry=0x75ad4600, first=first@entry=0x4, 
depth=depth@entry=0x4, 
highlights=highlights@entry=0x304) at backtrace.c:277
#9  0x77eb3970 in scm_backtrace_with_highlights (highlights=0x304) at 
backtrace.c:310
#10 0x77f40f3b in vm_debug_engine (thread=0x7744cd80) at 
vm-engine.c:972
#11 0x77f45c2d in scm_call_n (proc=0x75a2e030, 
argv=argv@entry=0x7fffc498, 
nargs=nargs@entry=1) at vm.c:1608
#12 0x77ec2337 in scm_primitive_eval (exp=, 
exp@entry=0x75ba1a40)
at eval.c:671
#13 0x77ec2393 in scm_eval (exp=0x75ba1a40, 
module_or_state=module_or_state@entry=0x75b93c80) at eval.c:705
#14 0x77f1b780 in scm_shell (argc=4, argv=0x7fffcb08) at 
script.c:357
#15 0x77edb1bd in invoke_main_func (body_data=0x7fffc9a0) at 
init.c:313
#16 0x77ebc06a in c_body (d=0x7fffc8e0) at continuations.c:430
#17 0x77f447d8 in vm_regular_engine (thread=0x7744cd80) at 
vm-engine.c:972
#18 0x77f45c2d in scm_call_n (proc=0x75b088a0, 
argv=argv@entry=0x7fffc6a0, 
nargs=nargs@entry=2) at vm.c:1608
#19 0x77ec11da in scm_call_2 (proc=, arg1=, arg2=)
at eval.c:503
#20 0x77ec29ea in scm_c_with_exception_handler (type=type@entry=0x404, 
handler=handler@entry=0x77f3aed0 , 
handler_data=handler_data@entry=0x7fffc810, 
thunk=thunk@entry=0x77f3b010 , 
thunk_data=thunk_data@entry=0x7fffc810) at exceptions.c:170
#21 0x77f3b20d in scm_c_catch (tag=tag@entry=0x404, 
body=body@entry=0x77ebc060 , 
body_data=body_data@entry=0x7fffc8e0, 
handler=handler@entry=0x77ebc300 , 
handler_data=handler_data@entry=0x7fffc8e0, 
pre_unwind_handler=pre_unwind_handler@entry=0x77ebc160 
, 
pre_unwind_handler_data=0x75ad45c0) at throw.c:168
#22 0x77ebc603 in scm_i_with_continuation_barrier 
(body=body@entry=0x77ebc060 , 
body_data=body_data@entry=0x7fffc8e0, 
handler=handler@entry=0x77ebc300 , 
handler_data=handler_data@entry=0x7fffc8e0, 
pre_unwind_handler=pre_unwind_handler@entry=0x77ebc160 
, 
--Type  for more, q to quit, c to continue without paging--c
pre_unwind_handler_data=0x75ad45c0) at continuations.c:368
#23 0x77ebc695 in scm_c_with_continuation_barrier (func=, data=) at continuations.c:464
#24 0x77f39c9f in with_guile (base=0x7fffc948, data=0x7fffc970) 
at threads.c:645
#25 0x77e16b48 in GC_call_with_stack_base () from 
/gnu/store/f6kngpp27585xh4564y9rvshqn8hph8v-libgc-8.0.4/lib/libgc.so.1
#26 0x77f39fc8 in scm_i_with_guile (dynamic_state=, 
data=data@entry=0x7fffc970, func=func@entry=0x77edb1a0 
) at threads.c:688
#27 scm_with_guile (func=func@entry=0x77edb1a0 , 
data=data@entry=0x7fffc9a0) at threads.c:694
#28 0x77edb332 in scm_boot_guile (argc=argc@entry=4, 
argv=argv@entry=0x7fffcb08, main_func=main_func@entry=0x401230 
, closure=closure@entry=0x0) at init.c:296
#29 0x004010f6 in main (argc=4, argv=0x7fffcb08) at guile.c:94


signature.asc
Description: This is a digitally signed message part


bug#50153: call-with-values outside tail position + backtrace + compilation causes segfault

2021-08-21 Thread Maxime Devos
Hi guilers,

Write the following to "crash.scm":

> (call-with-values backtrace list)
> #t

(the trailing #t is important) and run

> # --auto-compile works too, but --no-auto-compile doesn't cause a crash
> guile --fresh-auto-compile -l crash.scm

it will segfault during the printing of the backtrace:

>  Backtrace:
>  In ice-9/boot-9.scm:
>1752:10  8 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
>  In unknown file:
> 7 (apply-smob/0 #)
>  In ice-9/boot-9.scm:
>  724:2  6 (call-with-prompt _ _ # proc)>)
>  In ice-9/eval.scm:
>  619:8  5 (_ #(#(#)))
>  In ice-9/boot-9.scm:
> 2835:4  4 (save-module-excursion _)
>4380:12  3 (_)
>  In [...]/crash.scm:
>   36:0  2 (segfault)
>  In unknown file:
>  Segmentatiefout

Greetings,
Maxime.


signature.asc
Description: This is a digitally signed message part


bug#50127: [PATCH] doc: Fix typos.

2021-08-20 Thread Arun Isaac

> As the author of most of the part with corrections: thank you. I am
> cleaning up the reference implementation as well, so this is very
> welcome!

You're welcome! :-) I find SRFI-171 to be very useful. It has changed
the way I write scheme code.


signature.asc
Description: PGP signature


bug#50127: [PATCH] doc: Fix typos.

2021-08-20 Thread Linus Björnstam
As the author of most of the part with corrections: thank you. I am cleaning up 
the reference implementation as well, so this is very welcome!

-- 
  Linus Björnstam

On Thu, 19 Aug 2021, at 22:18, Arun Isaac wrote:
> * doc/ref/api-foreign.texi, doc/ref/srfi-modules.texi: Fix typos.
> ---
>  doc/ref/api-foreign.texi  |  2 +-
>  doc/ref/srfi-modules.texi | 32 
>  2 files changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi
> index 2bd460a88..a1a1016b0 100644
> --- a/doc/ref/api-foreign.texi
> +++ b/doc/ref/api-foreign.texi
> @@ -606,7 +606,7 @@ Mutating the returned bytevector mutates the memory 
> pointed to by
>  
>  @deffn {Scheme Procedure} bytevector->pointer bv [offset]
>  @deffnx {C Function} scm_bytevector_to_pointer (bv, offset)
> -Return a pointer pointer aliasing the memory pointed to by @var{bv} or
> +Return a pointer aliasing the memory pointed to by @var{bv} or
>  @var{offset} bytes after @var{bv} when @var{offset} is passed.
>  @end deffn
>  
> diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
> index 2e66bafb9..e12ab8d75 100644
> --- a/doc/ref/srfi-modules.texi
> +++ b/doc/ref/srfi-modules.texi
> @@ -5616,7 +5616,7 @@ since combining N of them builds @code{(- N 1)} 
> intermediate lists.
>  
>  Transducers are oblivious to what kind of process they are used in, and
>  are composable without building intermediate collections.  This means we
> -can create a transducer that squares all even numbers:
> +can create a transducer that squares all odd numbers:
>  
>  @example
>  (compose (tfilter odd?) (tmap (lambda (x) (* x x
> @@ -5689,7 +5689,7 @@ reducer with result-so-far and the 
> maybe-transformed input.
>  A simple example is as following:
>  
>  @example
> -(list-transduce (tfilter odd?)+ '(1 2 3 4 5)).
> +(list-transduce (tfilter odd?) + '(1 2 3 4 5)).
>  @end example
>  
>  This first returns a transducer filtering all odd
> @@ -5763,12 +5763,12 @@ and SRFI-158-styled generators respectively.
>  @deffnx {Scheme Procedure} port-transduce xform f reader port
>  @deffnx {Scheme Procedure} port-transduce xform f identity reader port
>  
> -Same as @code{list-reduce} but for ports.  Called without a port, it
> -reduces over the results of applying @var{reader} until the
> -EOF-object is returned, presumably to read from
> -@code{current-input-port}.  With a port @var{reader} is applied to
> -@var{port} instead of without any arguments.  If @var{identity} is
> -provided, that is used as the initial identity in the reduction.
> +Same as @code{list-transduce} but for ports.  Called without a port, it
> +reduces over the results of applying @var{reader} until the EOF-object
> +is returned, presumably to read from @code{current-input-port}.  With a
> +port @var{reader} is applied to @var{port} instead of without any
> +arguments.  If @var{identity} is provided, that is used as the initial
> +identity in the reduction.
>  @end deffn
>  
>  
> @@ -5844,7 +5844,7 @@ transduction.
>  Returns a transducer that applies @var{proc} to all values.  Stateless.
>  @end deffn
>  
> -@deffn tfilter pred?
> +@deffn {Scheme Procedure} tfilter pred?
>  Returns a transducer that removes values for which @var{pred?} returns #f.
>  
>  Stateless.
> @@ -5889,7 +5889,7 @@ Stateful.
>  
>  
>  @deffn {Scheme Procedure} tdrop-while pred?
> -Returns a transducer that discards the the first values for which
> +Returns a transducer that discards the first values for which
>  @var{pred?} returns true.
>  
>  Stateful.
> @@ -5949,9 +5949,9 @@ Stateful.
>  @end deffn
>  
>  @deffn {Scheme Procedure} tsegment n
> -Returns a transducer that groups @var{n} inputs in lists of @var{n}
> -elements.  When the transduction stops, it flushes any remaining
> -collection, even if it contains fewer than @var{n} elements.
> +Returns a transducer that groups inputs into lists of @var{n} elements.
> +When the transduction stops, it flushes any remaining collection, even
> +if it contains fewer than @var{n} elements.
>  
>  Stateful.
>  @end deffn
> @@ -6080,13 +6080,13 @@ The bytevector-u8 version of list-reduce.
>  @end deffn
>  
>  @deffn {Scheme Procedure} port-reduce f identity reader port
> -The port version of list-reducer.  It reduces over port using reader
> +The port version of list-reduce.  It reduces over port using reader
>  until reader returns the EOF object.
>  @end deffn
>  
>  @deffn {Scheme Procedure} generator-reduce f identity gen
> -The port version of list-reduce.  It reduces over @code{gen} until it
> -returns the EOF object
> +The generator version of list-reduce.  It reduces over @code{gen} until
> +it returns the EOF object
>  @end deffn
>  
>  @c srfi-modules.texi ends here
> -- 
> 2.32.0
> 
> 
> 
> 
> 





bug#50127: [PATCH] doc: Fix typos.

2021-08-19 Thread Arun Isaac
* doc/ref/api-foreign.texi, doc/ref/srfi-modules.texi: Fix typos.
---
 doc/ref/api-foreign.texi  |  2 +-
 doc/ref/srfi-modules.texi | 32 
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi
index 2bd460a88..a1a1016b0 100644
--- a/doc/ref/api-foreign.texi
+++ b/doc/ref/api-foreign.texi
@@ -606,7 +606,7 @@ Mutating the returned bytevector mutates the memory pointed 
to by
 
 @deffn {Scheme Procedure} bytevector->pointer bv [offset]
 @deffnx {C Function} scm_bytevector_to_pointer (bv, offset)
-Return a pointer pointer aliasing the memory pointed to by @var{bv} or
+Return a pointer aliasing the memory pointed to by @var{bv} or
 @var{offset} bytes after @var{bv} when @var{offset} is passed.
 @end deffn
 
diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
index 2e66bafb9..e12ab8d75 100644
--- a/doc/ref/srfi-modules.texi
+++ b/doc/ref/srfi-modules.texi
@@ -5616,7 +5616,7 @@ since combining N of them builds @code{(- N 1)} 
intermediate lists.
 
 Transducers are oblivious to what kind of process they are used in, and
 are composable without building intermediate collections.  This means we
-can create a transducer that squares all even numbers:
+can create a transducer that squares all odd numbers:
 
 @example
 (compose (tfilter odd?) (tmap (lambda (x) (* x x
@@ -5689,7 +5689,7 @@ reducer with result-so-far and the maybe-transformed 
input.
 A simple example is as following:
 
 @example
-(list-transduce (tfilter odd?)+ '(1 2 3 4 5)).
+(list-transduce (tfilter odd?) + '(1 2 3 4 5)).
 @end example
 
 This first returns a transducer filtering all odd
@@ -5763,12 +5763,12 @@ and SRFI-158-styled generators respectively.
 @deffnx {Scheme Procedure} port-transduce xform f reader port
 @deffnx {Scheme Procedure} port-transduce xform f identity reader port
 
-Same as @code{list-reduce} but for ports.  Called without a port, it
-reduces over the results of applying @var{reader} until the
-EOF-object is returned, presumably to read from
-@code{current-input-port}.  With a port @var{reader} is applied to
-@var{port} instead of without any arguments.  If @var{identity} is
-provided, that is used as the initial identity in the reduction.
+Same as @code{list-transduce} but for ports.  Called without a port, it
+reduces over the results of applying @var{reader} until the EOF-object
+is returned, presumably to read from @code{current-input-port}.  With a
+port @var{reader} is applied to @var{port} instead of without any
+arguments.  If @var{identity} is provided, that is used as the initial
+identity in the reduction.
 @end deffn
 
 
@@ -5844,7 +5844,7 @@ transduction.
 Returns a transducer that applies @var{proc} to all values.  Stateless.
 @end deffn
 
-@deffn tfilter pred?
+@deffn {Scheme Procedure} tfilter pred?
 Returns a transducer that removes values for which @var{pred?} returns #f.
 
 Stateless.
@@ -5889,7 +5889,7 @@ Stateful.
 
 
 @deffn {Scheme Procedure} tdrop-while pred?
-Returns a transducer that discards the the first values for which
+Returns a transducer that discards the first values for which
 @var{pred?} returns true.
 
 Stateful.
@@ -5949,9 +5949,9 @@ Stateful.
 @end deffn
 
 @deffn {Scheme Procedure} tsegment n
-Returns a transducer that groups @var{n} inputs in lists of @var{n}
-elements.  When the transduction stops, it flushes any remaining
-collection, even if it contains fewer than @var{n} elements.
+Returns a transducer that groups inputs into lists of @var{n} elements.
+When the transduction stops, it flushes any remaining collection, even
+if it contains fewer than @var{n} elements.
 
 Stateful.
 @end deffn
@@ -6080,13 +6080,13 @@ The bytevector-u8 version of list-reduce.
 @end deffn
 
 @deffn {Scheme Procedure} port-reduce f identity reader port
-The port version of list-reducer.  It reduces over port using reader
+The port version of list-reduce.  It reduces over port using reader
 until reader returns the EOF object.
 @end deffn
 
 @deffn {Scheme Procedure} generator-reduce f identity gen
-The port version of list-reduce.  It reduces over @code{gen} until it
-returns the EOF object
+The generator version of list-reduce.  It reduces over @code{gen} until
+it returns the EOF object
 @end deffn
 
 @c srfi-modules.texi ends here
-- 
2.32.0






bug#49930: glibc-2.34 build failure in gnulib (needs a sync)

2021-08-16 Thread Sergei Trofimovich
On Mon, 16 Aug 2021 19:41:36 +0200
lloda  wrote:

> Hi,
> 
> I have updated gnulib in 
> http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commitdiff;h=b4a80f4239b19fea4d2cc3e9d197f24b809f0624
>  
> .
>  Please let me know if this solves the issue – I am unable to test with the 
> newer glibc versions. 

The change fixes build for me and passes all except one test:
test-suite/standalone/test-out-of-memory
which is unrelated to glibc-2.34.

Definitely an improvement.

Thank you!

-- 

  Sergei


pgpgi52Rk6as8.pgp
Description: Цифровая подпись OpenPGP


bug#49930: glibc-2.34 build failure in gnulib (needs a sync)

2021-08-16 Thread lloda

Hi,

I have updated gnulib in 
http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commitdiff;h=b4a80f4239b19fea4d2cc3e9d197f24b809f0624
 
.
 Please let me know if this solves the issue – I am unable to test with the 
newer glibc versions. 

Thanks

Daniel

bug#50068: Curried definitions lose docstrings

2021-08-15 Thread Jean Abou Samra

When a docstring is used in the body of a curried definition,
it ends up on the result of the application of the resulting
curried function, not on the function itself. Example:

(use-modules (ice-9 curried-definitions))

(define ((curried a) b)
  "Docstring of curried"
  'whatever)

(procedure-documentation curried)
=> #f

(procedure-documentation (curried 'whatnot))
=> "Docstring of curried"


This is apparently because Guile translates

(define ((curried a) b)
  ...)

to

(define (curried a)
  (lambda (b)
    ...))

which puts the docstring in the body
of lambda.

Tested with Guile 2.2 and 3.0.5.





bug#50060: The REPL does not honor --no-auto-compile

2021-08-14 Thread Jean Abou Samra

Even when guile is run with --no-auto-compile, the
REPL still seems to be compiling the source.

$ guile --no-auto-compile
GNU Guile 3.0.5.130-5a1e7
[Legalese…]
scheme@(guile-user)> unbound-variable
;;; :1:0: warning: possibly unbound variable `unbound-variable'
[Backtrace…]

This "possibly unbound variable" warning comes from
compilation (which can be seen by putting the same
code in a script and running with or without auto-compilation).

This is annoying, because in the REPL the code
is run immediately and we don't need the warning
about a "possibly unbound variable" just before
the actual error. In fact, it would seem desirable
to make "no auto-compilation" the default for the
REPL. Code run there is typically not
performance-sensitive.

(Originally reported at 
https://lists.gnu.org/archive/html/guile-user/2021-06/msg00065.html.)






bug#50059: (ice-9 format) undesirably loaded when compiling

2021-08-14 Thread Jean Abou Samra

Hello,

Please have a look at the following session:

$ cat bug.scm
(format #t "~f\n" 42)
$ guile --no-auto-compile bug.scm
Backtrace:
   1 (primitive-load "/home/jean/repos/guile/bug.scm")
   0 (simple-format #t "~f\n" 42)

ERROR: In procedure simple-format:
In procedure simple-format: FORMAT: Unsupported format option ~f - use 
(ice-9 format) instead

$ guile bug.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;   or pass the --no-auto-compile argument to disable.
;;; compiling /home/jean/repos/guile/bug.scm
;;; compiled 
/home/jean/.cache/guile/ccache/3.0-LE-8-4.4/home/jean/repos/guile/bug.scm.go

42.0
$ guile bug.scm
Backtrace:
In ice-9/boot-9.scm:
  1752:10  6 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
   5 (apply-smob/0 #)
In ice-9/boot-9.scm:
    724:2  4 (call-with-prompt ("prompt") # …)
In ice-9/eval.scm:
    619:8  3 (_ #(#(#)))
In ice-9/boot-9.scm:
   2835:4  2 (save-module-excursion #)
  4380:12  1 (_)
In unknown file:
   0 (simple-format #t "~f\n" 42)

ERROR: In procedure simple-format:
In procedure simple-format: FORMAT: Unsupported format option ~f - use 
(ice-9 format) instead



As you can see, during the run where compilation
is performed, (ice-9 format) is loaded in the
main environment without being asked for, making
the program execution different, which is somewhat
confusing and error-prone as a program that has been
tested once will no longer work the next time
(thus possibly escaping an automated testing
system).

This is with Guile 3.0.5.130-5a1e7.

Thanks for your attention,
Jean Abou Samra





bug#49686: Confusing presence of #f in error message

2021-08-14 Thread Jean Abou Samra

Note that this does not happens with Guile 2.2





bug#49941: [PATCH] module/system/base/target.scm: support riscv32

2021-08-08 Thread Fabrice Fontaine
Fix the following build failure on riscv32:

system/base/target.scm:132:16: In procedure triplet-pointer-size:
unknown CPU word size "riscv32"

Fixes:
 - 
http://autobuild.buildroot.org/results/6705630c1484239ec8b73d57ebc2e2570fbfc8f8

Signed-off-by: Fabrice Fontaine 
---
 module/system/base/target.scm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/module/system/base/target.scm b/module/system/base/target.scm
index 2088cd866..dba46664d 100644
--- a/module/system/base/target.scm
+++ b/module/system/base/target.scm
@@ -116,6 +116,7 @@
 
   ((string-match "^x86_64-.*-gnux32" triplet) 4)  ; x32
 
+  ((string-match "32$" cpu) 4)
   ((string-match "64$" cpu) 8)
   ((string-match "64_?[lbe][lbe]$" cpu) 8)
   ((member cpu '("sparc" "powerpc" "mips" "mipsel" "nios2" "m68k" 
"sh3" "sh4")) 4)
-- 
2.30.2






bug#49930: glibc-2.34 build failure in gnulib (needs a sync)

2021-08-07 Thread Sergei Trofimovich
Hi bug-guile!

Recent glibc-2.34 released changed attribute macros slightly
which broke older gnulib macros. Fixed in gnulib upstream as:

https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=0c907f7da13232908f05c415b8cec56024071906

guile.git now fails to build on x86_64-linux as:

```
  CC   regex.lo
In file included from regexec.c:1368,
 from regex.c:74:
./malloc/dynarray-skeleton.c:195:24: error: expected declaration specifiers or 
'...' before '(' token
  195 | __attribute_nonnull__ ((1))
  |^
./malloc/dynarray-skeleton.c:205:51: error: expected declaration specifiers or 
'...' before '(' token
  205 | __attribute_maybe_unused__ __attribute_nonnull__ ((1))
  |   ^
./malloc/dynarray-skeleton.c:216:24: error: expected declaration specifiers or 
'...' before '(' token
  216 | __attribute_nonnull__ ((1))
  |^
./malloc/dynarray-skeleton.c:225:24: error: expected declaration specifiers or 
'...' before '(' token
  225 | __attribute_nonnull__ ((1))
  |^
./malloc/dynarray-skeleton.c:239:24: error: expected declaration specifiers or 
'...' before '(' token
  239 | __attribute_nonnull__ ((1))
  |^
./malloc/dynarray-skeleton.c:248:24: error: expected declaration specifiers or 
'...' before '(' token
  248 | __attribute_nonnull__ ((1))
  |^
./malloc/dynarray-skeleton.c:260:24: error: expected declaration specifiers or 
'...' before '(' token
  260 | __attribute_nonnull__ ((1))
  |^
./malloc/dynarray-skeleton.c:270:24: error: expected declaration specifiers or 
'...' before '(' token
  270 | __attribute_nonnull__ ((1))
  |^
./malloc/dynarray-skeleton.c: In func
```

Would it be reasonable to sync gnulib and cut a guile point release
compatible with it?

Thank you!

-- 

  Sergei





bug#49911: [PATCH] api-control: Fix misprint in code example.

2021-08-06 Thread Alexandr Vityazev
* doc/ref/api-control.texi (Simple Conditional Evaluation):
Correct the typo in the example unless form.

Delete trailing whitespaces.
---
 doc/ref/api-control.texi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/ref/api-control.texi b/doc/ref/api-control.texi
index 5df5344c5..6c87811d0 100644
--- a/doc/ref/api-control.texi
+++ b/doc/ref/api-control.texi
@@ -154,7 +154,7 @@ documentation:
 (define-syntax-rule (when test stmt stmt* ...)
   (if test (begin stmt stmt* ...)))
 
-(define-syntax-rule (unless condition stmt stmt* ...)
+(define-syntax-rule (unless test stmt stmt* ...)
   (if (not test) (begin stmt stmt* ...)))
 @end example
 
@@ -1657,12 +1657,12 @@ scm_foo (SCM s1, SCM s2)
 
   c_s1 = scm_to_locale_string (s1);
 
-  /* Call 'free (c_s1)' when the dynwind context is left. 
+  /* Call 'free (c_s1)' when the dynwind context is left.
   */
   scm_dynwind_unwind_handler (free, c_s1, SCM_F_WIND_EXPLICITLY);
 
   c_s2 = scm_to_locale_string (s2);
-  
+
   /* Same as above, but more concisely.
   */
   scm_dynwind_free (c_s2);
@@ -2312,7 +2312,7 @@ causing a segmentation fault.  Guile provides some macros 
to make this
 easier.
 
 @deftypefn Macro void SCM_ASSERT (int @var{test}, SCM @var{obj}, unsigned int 
@var{position}, const char *@var{subr})
-@deftypefnx Macro void SCM_ASSERT_TYPE (int @var{test}, SCM @var{obj}, 
unsigned int @var{position}, const char *@var{subr}, const char 
*@var{expected}) 
+@deftypefnx Macro void SCM_ASSERT_TYPE (int @var{test}, SCM @var{obj}, 
unsigned int @var{position}, const char *@var{subr}, const char *@var{expected})
 If @var{test} is zero, signal a ``wrong type argument'' error,
 attributed to the subroutine named @var{subr}, operating on the value
 @var{obj}, which is the @var{position}'th argument of @var{subr}.
-- 
2.32.0



-- 

Alexandr Vityazev





bug#49623: [PATCH v2] Parse #{{}}# properly.

2021-08-02 Thread lloda

Applied in c78c130b1ddef6d6c290533f74ce1fbd51a4b19d. Thank you!


> On 20 Jul 2021, at 12:54, Maxime Devos  wrote:
> 
> Maxime Devos schreef op zo 18-07-2021 om 21:47 [+0200]:
>> It turns out that the test fails when the patch
>> is applies to guile@3.0.7.  I'll rebase and try
>> to figure things out.
> 
> With the revised patch, tests succeed and the Guile
> library now compiles successfully.
> 
> Greetings,
> Maxime.
From 40b0b29c05d521cd8901988fa2bc71547f917f48 Mon Sep 17 00:00:00 2001
From: Maxime Devos 
Date: Sun, 18 Jul 2021 19:59:32 +0200
Subject: [PATCH] ice-9/read: Parse #{}}# properly.

This is a regression since Guile 3.0.2 and breaks compilation
of a Guile library.

* module/ice-9/read.scm
  (%read)[read-parenthesized]: When SAW-BRACE? is #t but CH isn't
  #\#, don't eat CH.
* test-suite/tests/reader.test
  ("#{}#): Add four test cases.
---
 module/ice-9/read.scm| 7 +--
 test-suite/tests/reader.test | 5 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/module/ice-9/read.scm b/module/ice-9/read.scm
index ac407739f..283933064 100644
--- a/module/ice-9/read.scm
+++ b/module/ice-9/read.scm
@@ -556,12 +556,15 @@
 (string->symbol
  (list->string
   (let lp ((saw-brace? #f))
-(let ((ch (next-not-eof)))
+(let lp/inner ((ch (next-not-eof))
+   (saw-brace? saw-brace?))
   (cond
(saw-brace?
 (if (eqv? ch #\#)
 '()
-(cons #\} (lp #f
+;; Don't eat CH, see
+;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49623>.
+(cons #\} (lp/inner ch #f
((eqv? ch #\})
 (lp #t))
((eqv? ch #\\)
diff --git a/test-suite/tests/reader.test b/test-suite/tests/reader.test
index 1481a0a5d..ad7c6d575 100644
--- a/test-suite/tests/reader.test
+++ b/test-suite/tests/reader.test
@@ -536,6 +536,11 @@
 
 (with-test-prefix "#{}#"
   (pass-if (equal? (read-string "#{}#") '#{}#))
+  ;; See <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49623>
+  (pass-if (equal? (read-string "#{}}#") (string->symbol "}")))
+  (pass-if (equal? (read-string "#{}}}#") (string->symbol "}}")))
+  (pass-if (equal? (read-string "#{{}}#") (string->symbol "{}")))
+  (pass-if (equal? (read-string "#{{}b}#") (string->symbol "{}b")))
   (pass-if (not (equal? (read-string "(a #{.}# b)") '(a . b
   (pass-if (equal? (read-string "#{a}#") 'a))
   (pass-if (equal? (read-string "#{a b}#") '#{a b}#))
-- 
2.32.0




bug#40744: guile-2.2.4 (integer-length 0) erroneously returns 0, not 1

2021-07-24 Thread Bengt Richter
Oops, forgot to reply-all -- sorry about the dup, Rob ;/

On +2021-07-15 22:01:32 -0500, Rob Browning wrote:
> 
> Hmm, the zero result appears to be intentional, i.e. it's mentioned in
> the examples here:
> 
>   https://www.gnu.org/software/guile/manual/guile.html#Arithmetic
> 
> and is also specified by Chez Scheme and SRFI-60:
> 
>   https://www.scheme.com/csug8/numeric.html
>   https://srfi.schemers.org/srfi-60/srfi-60.html
> 
> -- 
> Rob Browning
> rlb @defaultvalue.org and @debian.org
> GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
> GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4

I tried to make a pitch for (integer-length 0) =-> 1 in
[1]https://lists.gnu.org/archive/html/bug-guile/2020-04/msg00027.html
though I now think integer-length is a useful measure of mathematical
integervalues that can be generalized to any rational numbers and
complex numbers with rational real and imaginary parts.

Also their printed representations can have any rational radix other
than 1 and negative generalized integer-lengths can be meaningful for
length of 1/x vs x (which brings in the zero issue).

For the "integer-length" I compute in [1], I would now suggest an alternate
name: integer-digits -- the number of concrete digit-value representations
it take to represent the polynomial coefficient values in the mathematical
polynomial series.

I should update [1] to reflect what I am saying here to remove complaints
about integer-length 0 etc and talk about integer-digits (or maybe
rational-digits or even numeric-digits?)

I think scheme's integer-length basically solves for minimum L in
in a mapping of rational numbers (limited to integers in its case)
for + and minus like
[0..2**L) for positive and [-2**L..0) for negative.

Those half-open sets correspond, so we can just use the absolute value
like abslen here:
--8<---cut here---start->8---
#!/usr/bin/env -S guile --no-auto-compile -e main -s
!#
(use-modules (ice-9 format))

(define (abslen absint)
  (begin
(let*((absval absint)
  (lm (lambda (aval)
(begin
  (let inner ((n 0) (av aval))
(begin
  (if
   (< (integer-expt 2 n) av) 
   (inner (+ 1 n) av)
   n)))
(lm absval

(define (main args)
  (begin
(or
 (false-if-exception 
  (begin
(display (abslen (abs (string->number (cadr args)
(newline)))
 (begin
   (format #t "\nUsage: ~a NUM -- where NUM is [+ - ] POSITIVE_INTEGER\n" 
(car args)))
 (newline
--8<---cut here---end--->8---

You might want to call the above something other than integer-length,
but it should compute the same result (modulo very limited testing :).

As mentioned in Tom's reply to [1], zero makes for a special problem
in the general mathematical case, where I think you have to special-case
which set of points it should belong to.

In the general case numbers map into half-open annuli in the complex plane,
where inside and outside the unit circle corresponds to x and 1/x, and 1/0
has to be special-cased. The annulus edge circles are at powers of a rational
base, 2 in the binary case, but 4/3 can work. Just not irrationals.
(Maybe as named unit values though?)

Conventional signed number mappings split an annulus in two to map them,
with positives < the splitting circle and negatives >=

Something analogous to abslen can be done to find the power of the base
that will be the diameter of a circle containing (> not >=) both parts
of the split annulus. I haven't done it yet :)

Complex numbers have both cartesian and polar representations, so that
brings in interesting stuff too. The negative of a complex number as
a point in the complex plane is diametrically opposite the origin, but
zero has no direction to an opposite of itself :)
Defining -0 to be 0 has consequences. (Note that fp hardware does
represent -0 :)

You might find it amusing to play with the scheme program
included in [1] (after you inspect it -- no warranties :).

-- 
Regards,
Bengt Richter
PS. Shouldn't euclidean-quotient always produce an exact integer?
(Inexactness if any can be carried by the remainder)





<    3   4   5   6   7   8   9   10   11   12   >