#584 closed defect (fixed)
Unused arguments in callback wrappers are incorrectly optimized away
| Reported by: | sjamaan | Owned by: | felix winkelmann |
|---|---|---|---|
| Priority: | critical | Milestone: | 4.9.0 |
| Component: | compiler | Version: | 4.6.x |
| Keywords: | optimizations, define-external, ffi | Cc: | |
| Estimated difficulty: |
Description
(module bla (foo) (import chicken scheme foreign) (define-external (blabla (int a) (c-string b) (int c) (int d) (c-string e) (int f)) void (print "HELLO")) (define (foo) ((foreign-safe-lambda* void () "blabla(1, \"2\", 3, 4, \"5\", 6);"))) ) (import bla) (foo)
This gives an error:
Error: bad argument count - received 6 but expected 2: #<procedure>
Call history:
test.scm:14: bla#foo
##sys#gc
g2728 <--
This is caused by the fact that callback-names contains the unqualified procedure name (not prefixed with a module name).
Attached is a patch that seems to fix this (but I'm not 100% sure if it's the Right Way(TM) of fixing this).
I think there may be other bugs like this where the raw symbol is inserted into some database while it should be using the qualified name, so it's probably a good idea to review other parts of the optimizer.
PS: The milestone 4.7.0 was reached, it should be closed in Trac and the Version dropdown should be changed to include 4.7.0
Attachments (1)
Change History (5)
by , 15 years ago
| Attachment: | define-external-no-optimization.patch added |
|---|
comment:1 by , 15 years ago
The patch is basically correct, but will break (location <callbackname>). I will figure something out. Thanks, Peter.
comment:2 by , 15 years ago
Oh, that's unfortunate.
If anyone else is having this problem, just sticking a (list a b c d ...) call somewhere (including all (unused) arguments to the procedure) in the procedure is a good workaround.
comment:3 by , 14 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Fixed in "experimental". The raw symbol and the aliased name are now saved in callback-names, to make location work.

Insert module-qualified names into callback-names db