Add a lint to avoid passing types with destructors through the FFI boundaries.
Categories
(Developer Infrastructure :: Source Code Analysis, task)
Tracking
(firefox75 fixed)
Tracking | Status | |
---|---|---|
firefox75 | --- | fixed |
People
(Reporter: emilio, Assigned: emilio)
References
Details
Attachments
(3 files)
Comment 1•4 years ago
|
||
Passing these types behind a pointer or reference type should be OK, but passing them by-value may act poorly, due to differences in destructor semantics between C++ and Rust around function boundaries. The behaviour of this lint would want to be similar to the non_param
annotation, but probably only impacting methods with an extern "C"
linkage.
It's unclear whether we can make this completely implicit, based on linkage and trivial destructors, or whether we'd need to annotate cross-language methods or cross-language types due to false-positives.
Assignee | ||
Comment 2•4 years ago
|
||
yeah, I'll try to give a shot to something like this, implicit first and then we'll see.
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 3•4 years ago
|
||
Otherwise it'd error, which is not great. We could add a custom attribute in
there if needed or something, or fix cbindgen to generate these for us as
described in the issue linked from the comments.
Do this in ServoStyleConstsInlines as that's where we have the guarantee that
the templates have been defined, and that the file is included every time
ServoStyleConsts is included.
Assignee | ||
Comment 4•4 years ago
|
||
This ensures that we don't pass non-trivially-copiable types through the FFI
boundary.
Depends on D61625
Assignee | ||
Comment 5•4 years ago
|
||
JSAPI functions are not extern "C" anymore. This warning has a couple false
positives due to template specialization (see first patch of this bug), but we
were already working around them, because apparently some mingw builds use it.
Once I fix cbindgen to generate the specializations as needed we can remove
those workarounds, but this is green in the meantime and doesn't hurt.
Depends on D61626
Assignee | ||
Updated•4 years ago
|
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/879a5784bc60 Enable -Wreturn-type-c-linkage. r=froydnj
Comment 7•4 years ago
|
||
bugherder |
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5f9ed835ff4b Prove to the incoming clang plugin that our templates are indeed trivially copiable. r=boris
Comment 9•4 years ago
|
||
bugherder |
Updated•4 years ago
|
Comment 10•4 years ago
|
||
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/80d4c3f20004 Introduce NonTrivialTypeInFfiChecker. r=andi
Assignee | ||
Updated•4 years ago
|
Comment 11•4 years ago
|
||
bugherder |
Updated•2 years ago
|
Description
•