Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ffi :variadic? true generated function do not use all arguments supplied #449

Open
mpenet opened this issue Nov 15, 2015 · 2 comments
Open
Labels

Comments

@mpenet
Copy link
Contributor

mpenet commented Nov 15, 2015

I get unexpected results when using it.

As an example here is what it outputs from "printf" (defined in stdlib as (def printf (ffi-fn libc "printf" [CCharP] CInt :variadic? true))):

user => (printf "a" "b" "c")
a

It seems everything after the 1st argument is ignored.

@heyLu
Copy link
Member

heyLu commented Nov 15, 2015

Yes, #420 was about the same problem. As I said there, I'm not sure if our FFI can handle the full signature of printf. It seems to support multiple arguments to printf and passes them, but I don't know what happens after that.

I went looking in pixie/vm/libs/ffi.py, and looked for variadic? there. I think it doesn't actually convert the additional arguments to printf, even though it allocates space for them, it does not convert the additional arguments. (The problem seems to be that _arg_types is used to convert the arguments, but that's just the [CCharP] from the signature, and doesn't include the (unknown) types for the optional arguments.)

@mpenet
Copy link
Contributor Author

mpenet commented Nov 15, 2015

There is a missing piece yes. I tried briefly to follow what's happening in ffi.py as well but that's still a bit vague to me. I guess that's something @halgari could look into when he gets some time.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants