-
Notifications
You must be signed in to change notification settings - Fork 77
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
Don't leak implementation into headers. #75
base: main
Are you sure you want to change the base?
Conversation
Previously, both: embedding C/C++ application and the library had to be built using the same DEBUG define, because vec<type>::make_data() and vec<type>::free_data() were declared in the implementation when built with DEBUG defined, and in the headers otherwise. As a result, linking C/C++ application against library built with different DEBUG define resulted in either: failed build or broken make/free accounting and the library aborting at runtime. Signed-off-by: Piotr Sikora <[email protected]>
I see the problem, but it is a bit unfortunate that every vec allocation & deallocation now involves another function call. My understanding is that inline functions have static linkage, so wouldn't it be enough to merely do the changes to the cc file? Then the functions always exist when you try to link against them with a DEBUG-mode client, but a non-DEBUG client can still omit the calls. |
@rossberg in theory, that would work for an APIs used only by the application, but in practice, the DEBUG library uses This means that when ownership is passed between the two, either:
|
I see, good point. In that case, can we somehow make linking between client and lib with different DEBUG settings fail in all cases, such that users are forced to use it consistently? Either way, we should probably use a more specific macro name to avoid collision with other uses of DEBUG in clients. |
My vote is to drop To me, it doesn't feel like such internal debugging helpers belong in the production version of the API. Any solution that involves forcing the same build flags for client and library makes it difficult to distribute binary versions of the library. As a variant of this, I can imagine embedders wanting to compile their own code in Debug mode while linking against the Release version of whichever library implementation they are using. |
@rossberg sorry, this slipped my mind. I cannot think of an easy way to enforce this at build-time. We could possibly do this at run-time by passing I personally spent way more time chasing false positives, which resulted from On a side note, Xcode and Bazel (fastbuild) pass |
Yes, but imposes much stricter requirements on the overall program, I think. In particular, will it work when linking the lib against an app that is not (yet?) LSan-ready? |
I don't see the use case for that? When debugging the library for memory leaks, you can (and probably also want to) link it against a simple and correct embedder. When debugging an embedder, you can assume that the library is leak free. When you're not sure where the leak is, you want both/all components instrumented, and want to fix all reports anywhere. Why would you want to taint the public header with explicit support for partially-leak-free library/embedder combinations? |
@jakobkummerow, the use case would be embedding V8 with foreign language bindings where the host language runtime may not be LSan-ready, but the user (of the language) has no control over it, but still is in dire need of checking the correct use of the Wasm interface -- which is hairy to get right and debug when all you have is the C interface. Assuming we rename the flag, is there still a problem? If you are not interested in accounting, why would you set it in the first place? If you are, well, deal with possible mismatches. Having the option still seems better than having no option. Or am I missing something? |
My reasons for preferring to drop
That said, renaming the flag to something that's specific enough to be unlikely to collide (WASM_VEC_ACCOUNTING?) should make it possible to pretty much ignore it, so I could live with that. |
Previously, both: embedding C/C++ application and the library had to
be built using the same DEBUG define, because vec::make_data()
and vec::free_data() were declared in the implementation when
built with DEBUG defined, and in the headers otherwise.
As a result, linking C/C++ application against library built with
different DEBUG define resulted in either: failed build or broken
make/free accounting and the library aborting at runtime.
Signed-off-by: Piotr Sikora [email protected]