* bug#43831: Only when compiled: Wrong number of arguments
@ 2020-10-06 16:39 Jan Nieuwenhuizen
2020-10-07 8:30 ` Jan Nieuwenhuizen
0 siblings, 1 reply; 2+ messages in thread
From: Jan Nieuwenhuizen @ 2020-10-06 16:39 UTC (permalink / raw)
To: 43831
Hi!
Running mescc with compiled guile-3.0.4 (guile-3.0-latest on guix
master) code gives
Wrong number of arguments to #<procedure expr->register (o info)>
Using guile-2.2, or running without compiling is fine.
To reproduce, do
--8<---------------cut here---------------start------------->8---
git clone --branch=wip-guile3 https://git.savannah.gnu.org/git/mes.git
guix environment -l guix.scm
./configure
SCHEME=guile ./pre-inst-env mescc -c scaffold/hello.c
make all-go
SCHEME=guile ./pre-inst-env mescc -c scaffold/hello.c
--8<---------------cut here---------------end--------------->8---
Note that the first run, before `make all-go' runs fine (see hello.s,
hello.o). The second run, running with compiled .go files, gives
--8<---------------cut here---------------start------------->8---
Backtrace:
In ice-9/boot-9.scm:
1736:10 16 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
In unknown file:
15 (apply-smob/0 #<thunk 7ff3356402a0>)
In ice-9/boot-9.scm:
718:2 14 (call-with-prompt _ _ #<procedure default-prompt-handler (k proc)>)
In ice-9/eval.scm:
619:8 13 (_ #(#(#<directory (guile-user) 7ff335261f00>)))
In mescc/mescc.scm:
120:16 12 (mescc:assemble ((numbered-arch? . #f) (kernel . "linux") (arch . "x86_64") (libdir . "/home/?") ?))
In srfi/srfi-1.scm:
586:17 11 (map1 ("scaffold/hello.c"))
In ice-9/ports.scm:
445:17 10 (call-with-input-file _ _ #:binary _ #:encoding _ #:guess-encoding _)
470:4 9 (_ _)
In mescc/compile.scm:
61:14 8 (c99-ast->info _ _ #:verbose? _)
In srfi/srfi-1.scm:
460:18 7 (fold #<procedure ast->info (o info)> _ _)
In mescc/compile.scm:
2652:17 6 (fctn-defn->info _ #<<info> types: (("wchar_t" . #<<type> type: signed size: 4 description: #f>) ?>)
1901:2 5 (ast->info _ #<<info> types: (("wchar_t" . #<<type> type: signed size: 4 description: #f>) ("uid_?>)
In srfi/srfi-1.scm:
460:18 4 (fold #<procedure ast->info (o info)> #<<info> types: (("wchar_t" . #<<type> type: signed size: ?> ?)
In mescc/compile.scm:
1719:24 3 (ast->info _ #<<info> types: (("wchar_t" . #<<type> type: signed size: 4 description: #f>) ("uid_?>)
1020:30 2 (expr->register _ _)
In srfi/srfi-1.scm:
501:18 1 (fold-right #<procedure expr->register (o info)> _ _ . _)
In mescc/compile.scm:
882:0 0 (expr->register _ _)
mescc/compile.scm:882:0: In procedure expr->register:
Wrong number of arguments to #<procedure expr->register (o info)>
--8<---------------cut here---------------end--------------->8---
I'm aware that this isn't exactly a "minimal reprocucing
example"...however I've no idea to get there.
I tried this patch:
--8<---------------cut here---------------start------------->8---
diff --git a/module/mescc/compile.scm b/module/mescc/compile.scm
index 579de2ceb..213909552 100644
--- a/module/mescc/compile.scm
+++ b/module/mescc/compile.scm
@@ -879,7 +879,14 @@
((4) 'r-long-mem-add)) n))))))
(free-register info))))
-(define (expr->register o info)
+(define (expr->register o . rest)
+ (when (null? rest)
+ (throw 'expr-register "rest is null for" o))
+ (when (> (length rest) 1)
+ (throw 'expr-register "rest length for:" o (length rest)))
+ (expr->register- o (car rest)))
+
+(define (expr->register- o info)
(let* ((locals (.locals info))
(text (.text info))
(globals (.globals info))
--8<---------------cut here---------------end--------------->8---
to armor expr->register calls and flag an error, which gives a very
similar, and thus even more puzzling backtrace:
--8<---------------cut here---------------start------------->8---
[..]
In mescc/compile.scm:
887:2 3 (ast->info _ _)
1027:30 2 (expr->register- _ _)
In srfi/srfi-1.scm:
501:18 1 (fold-right #<procedure expr->register- (o info)> _ _ . _)
In mescc/compile.scm:
889:0 0 (expr->register- _ _)
--8<---------------cut here---------------end--------------->8---
because, the new expr->register- has only one call location which is
fine. Ideas?
Greetings,
Janneke
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#43831: Only when compiled: Wrong number of arguments
2020-10-06 16:39 bug#43831: Only when compiled: Wrong number of arguments Jan Nieuwenhuizen
@ 2020-10-07 8:30 ` Jan Nieuwenhuizen
0 siblings, 0 replies; 2+ messages in thread
From: Jan Nieuwenhuizen @ 2020-10-07 8:30 UTC (permalink / raw)
To: 43831
[-- Attachment #1: Type: text/plain, Size: 2484 bytes --]
Jan Nieuwenhuizen writes:
Hello again,
> Running mescc with compiled guile-3.0.4 (guile-3.0-latest on guix
> master) code gives
>
> Wrong number of arguments to #<procedure expr->register (o info)>
>
> Using guile-2.2, or running without compiling is fine.
>
> To reproduce, do
[..]
> I'm aware that this isn't exactly a "minimal reprocucing
> example"...however I've no idea to get there.
I found a way to bisect it into something much smaller; see attached.
To reproduce, do:
--8<---------------cut here---------------start------------->8---
$ guix environment --ad-hoc guile@3.0.4
10:27:13 janneke@dundal:~/tmp/bug [env]
$ guile --no-auto-compile -C . -e '(wrong-number-of-arguments)' wrong-number-of-arguments.scm
Hello MesCC
10:27:18 janneke@dundal:~/tmp/bug [env]
$ guild compile -o wrong-number-of-arguments.go wrong-number-of-arguments.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /gnu/store/yxwq48xmimjsy2b6s6ga8mcfs47af936-profile/bin/guild
;;; compiled /home/janneke/.cache/guile/ccache/3.0-LE-8-4.3/gnu/store/ah16zr8mmfkqy23rr7jy5a842ca1q9h1-guile-3.0.4/bin/guild.go
wrote `wrong-number-of-arguments.go'
10:27:28 janneke@dundal:~/tmp/bug [env]
$ guile -C . -e '(wrong-number-of-arguments)' wrong-number-of-arguments.scm
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/janneke/tmp/bug/wrong-number-of-arguments.scm
;;; compiled /home/janneke/.cache/guile/ccache/3.0-LE-8-4.3/home/janneke/tmp/bug/wrong-number-of-arguments.scm.go
Hello MesCC
Backtrace:
In ice-9/boot-9.scm:
1736:10 5 (with-exception-handler _ _ #:unwind? _ #:unwind-for-type _)
In unknown file:
4 (apply-smob/0 #<thunk 7ffb62d6b4a0>)
In ice-9/boot-9.scm:
718:2 3 (call-with-prompt _ _ #<procedure default-prompt-handler (k proc)>)
In ice-9/eval.scm:
619:8 2 (_ #(#(#<directory (guile-user) 7ffb629a6f00>)))
In srfi/srfi-1.scm:
501:18 1 (fold-right #<procedure expr->register (o info)> _ _ . _)
In /home/janneke/tmp/bug/wrong-number-of-arguments.scm:
24:0 0 (expr->register _ _)
/home/janneke/tmp/bug/wrong-number-of-arguments.scm:24:0: In procedure expr->register:
Wrong number of arguments to #<procedure expr->register (o info)>
[1]10:27:41 janneke@dundal:~/tmp/bug [env]
$
--8<---------------cut here---------------end--------------->8---
Greetings,
Janneke
[-- Attachment #2: wrong-number-of-arguments.scm --]
[-- Type: application/octet-stream, Size: 914 bytes --]
(define-module (wrong-number-of-arguments)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-9 gnu)
#:use-module (system base pmatch)
#:export (main))
(define-immutable-record-type <info>
(make-<info> types)
info?
(types .types))
(define (expr->arg o i info)
(pmatch o
(_
(expr->register0 o info))))
;; repeating the expr->arg definition makes the bug go away:
;; (define (expr->arg o i info)
;; (pmatch o
;; (_
;; (expr->register0 o info))))
(define (expr->register o info)
(pmatch o
((expr-list . ,expr-list)
(fold-right expr->arg info expr-list (reverse (iota (length expr-list)))))))
(define (expr->register0 o info)
(expr->register o info))
(define hello-expr-list
'(expr-list (p-expr (string "Hello, Mescc!\n"))))
(define (main . args)
(format #t "Hello MesCC\n")
(expr->register hello-expr-list (make-<info> '())))
[-- Attachment #3: Type: text/plain, Size: 152 bytes --]
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-07 8:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-06 16:39 bug#43831: Only when compiled: Wrong number of arguments Jan Nieuwenhuizen
2020-10-07 8:30 ` Jan Nieuwenhuizen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).