[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-janitors] #850: dbus: Scheme closure passed where function poin
From: |
Chicken Trac |
Subject: |
[Chicken-janitors] #850: dbus: Scheme closure passed where function pointer is expected and triple compilation |
Date: |
Thu, 17 May 2012 18:23:33 -0000 |
#850: dbus: Scheme closure passed where function pointer is expected and triple
compilation
------------------------+---------------------------------------------------
Reporter: sjamaan | Owner: ecloud
Type: defect | Status: new
Priority: major | Milestone:
Component: extensions | Version: 4.7.x
Keywords: |
------------------------+---------------------------------------------------
Recently we ran Salmonella with the option {{{-specialize}}}, to find
problems with the scrutinizer (flow analysis) and bugs in eggs, and it
found a problem with dbus:
http://parenteses.org/mario/misc/specialize-report/install/dbus.html
Due to the fact that dbus builds with -O3 you can also see this in action
in the latest salmonella run based on the git master branch of Chicken:
http://tests.call-cc.org/master/linux/x86/2012/05/17/salmonella-
report/install/dbus.html
The warning is due to the fact that the {{{vtable-message_function}}} is
declared as type {{{c-pointer}}}, but a plain Scheme closure object is set
to that pointer. This is not correct, and should usually cause a segfault
since Scheme objects are not generally usable as pointers. In this case it
happens to extract a pointer to the procedure correctly because closures
are represented similarly to pointer objects, but Scheme closures expect
an argument count and a continuation as the first two parameters.
If you want to pass a C function pointer correctly, I think you'll need to
declare a function in C (or use {{{define-external}}} or something
similar) and use {{{foreign-value}}} with type {{{c-pointer}}} to reify it
as a pointer.
Finally, it looks like the egg's Make recipe in the .setup-file is all
wrong; the same file gets compiled up to three times!
This is due to the fact that the rule for {{{dbus.so}}} doesn't use
{{{dbus.c}}} but {{{dbus.scm}}}, making the step to generate the
{{{.c}}}-file unneccessary. Actually, this file even gets '''deleted'''
after this is compiled. That causes the {{{dbus.import.scm}}} line to
trigger compilation of {{{dbus.c}}} via that line yet again, even though
the import file already exists.
Here's a patch to do it more or less correctly, if you really need to
split up compilation into two stages (which is completely unneccessary):
{{{
Index: dbus.setup
===================================================================
--- dbus.setup (revision 26708)
+++ dbus.setup (working copy)
@@ -1,14 +1,14 @@
;;;; dbus.setup -*- Scheme -*-
-(use files utils)
-
(make (
- ("dbus.import.so" ("dbus.c")
+ ("dbus.import.so" ("dbus.import.scm")
(compile -s -O3 -d0 dbus.import.scm))
("dbus.so" ("dbus.c")
- (compile -s -O3 -d1 dbus.scm -C "`pkg-config
--cflags dbus-1`" -L "`pkg-config --libs dbus-1`"))
+ (compile -s -O3 -d1 dbus.c -C "`pkg-config
--cflags dbus-1`" -L "`pkg-config --libs dbus-1`"))
+ ("dbus.import.scm" ("dbus.scm")
+ (compile -A dbus.scm -X easyffi -j dbus))
("dbus.c" ("dbus.scm")
- (compile -t dbus.scm -O3 -d1 -X easyffi -C -g -j
dbus)))
+ (compile -t dbus.scm -O3 -d1 -X easyffi)))
'("dbus.so" "dbus.import.so"))
(install-extension 'dbus
}}}
I've removed the "(use files utils)" line since it isn't using anything
from there.
Notice the fact that to do this, we still need to run the csc command
twice on dbus.scm, because when you want the output {{{dbus.c}}} normally
a side-effect of running the command is that {{{dbus.import.scm}}} is
emitted (via the {{{-j}}} switch). If you want to split it up like this,
you need to run the compilation twice. This means the compiler gets
invoked twice and has to do all that work again.
Normally you use "make" to avoid building things more than once or over
and over again, but the irony is that this setup-file is actually causing
it to do exactly that!
You don't need the "make" form at all (which, by the way, is deprecated
and [http://wiki.call-cc.org/eggref/4/make moved into an egg] now).
You can simplify {{{dbus.setup}}} into this (that's the entire file):
{{{
;;;; dbus.setup -*- Scheme -*-
(compile -s -O3 -d1 dbus.scm -C "`pkg-config --cflags dbus-1`" -L "`pkg-
config --libs dbus-1`" -j dbus))
(compile -s -O3 -d1 dbus.import.scm))
(install-extension 'dbus
`("dbus.so" "dbus.import.so")
`((version "0.91")))
}}}
--
Ticket URL: <http://bugs.call-cc.org/ticket/850>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Chicken-janitors] #850: dbus: Scheme closure passed where function pointer is expected and triple compilation,
Chicken Trac <=