Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

rewriter: struct __va_list_tag * used instead of va_list #429

Open
kkysen opened this issue Oct 7, 2024 · 2 comments
Open

rewriter: struct __va_list_tag * used instead of va_list #429

kkysen opened this issue Oct 7, 2024 · 2 comments

Comments

@kkysen
Copy link
Contributor

kkysen commented Oct 7, 2024

When the IA2_TYPE_* for a variadic function is generated, struct __va_list_tag * is used. However, this type is, IIUC, supposed to be private, resulting in errors like this:

/home/kkysen/work/rust/dav1d-ia2/callgate_wrapper.h:31:86: warning: ‘struct __va_list_tag’ declared inside parameter list will not be visible outside of this definition or declaration
   31 | #define IA2_TYPE__ZTSPFvPvPKcP13__va_list_tagE void (*)(void *, const char *, struct __va_list_tag *)
      |                                                                                      ^~~~~~~~~~~~~
../../ia2/runtime/libia2/include/ia2_internal.h:42:6: note: in expansion of macro ‘IA2_TYPE__ZTSPFvPvPKcP13__va_list_tagE’
   42 |     (IA2_TYPE_##id) & __ia2_indirect_callgate_##id##_pkey_##pkey;              \
      |      ^~~~~~~~~
../../ia2/runtime/libia2/include/ia2_internal.h:44:37: note: in expansion of macro ‘__IA2_CALL’
   44 | #define _IA2_CALL(opaque, id, pkey) __IA2_CALL(opaque, id, pkey)
      |                                     ^~~~~~~~~~
../../ia2/runtime/libia2/include/ia2.h:136:30: note: in expansion of macro ‘_IA2_CALL’
  136 | #define IA2_CALL(opaque, id) _IA2_CALL(opaque, id, PKEY)
      |                              ^~~~~~~~~
../src/log.c:54:5: note: in expansion of macro ‘IA2_CALL’
   54 |     IA2_CALL(c->logger.callback, _ZTSPFvPvPKcP13__va_list_tagE)(c->logger.cookie, format, ap);
      |     ^~~~~~~~
../src/log.c:54:91: error: passing argument 3 of ‘(({...}))’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   54 |     IA2_CALL(c->logger.callback, _ZTSPFvPvPKcP13__va_list_tagE)(c->logger.cookie, format, ap);
      |                                                                                           ^~
      |                                                                                           |
      |                                                                                           __va_list_tag *
../src/log.c:54:91: note: expected ‘struct __va_list_tag *’ but argument is of type ‘__va_list_tag *

That is, the struct __va_list_tag * creates some new anonymous struct __va_list_tag type that's different from the private struct __va_list_tag type from stdarg.h, which publically exposes it through va_list, which is typedef'd/macro'd to struct __va_list_tag *. Thus, I'm pretty sure that we should be using va_list here instead, and changing the code in callgate_wrapper.h to use va_list instead fixes this error.

@ayrtonm
Copy link
Contributor

ayrtonm commented Oct 7, 2024

We can't have variadic functions at compartment boundaries. Is it possible to move the boundary up or down one function in the call stack?

@kkysen
Copy link
Contributor Author

kkysen commented Oct 7, 2024

We can't have variadic functions at compartment boundaries. Is it possible to move the boundary up or down one function in the call stack?

I thought @rinon said this is okay, just that it'll just run the fn ptr in compartment 0 instead, which should be fine for just logging things (hopefully).

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

No branches or pull requests

2 participants