`MOZ_KNOWN_LIVE` does not work as expected with `RefPtr` member etc
Categories
(Developer Infrastructure :: Source Code Analysis, enhancement)
Tracking
(firefox98 fixed)
Tracking | Status | |
---|---|---|
firefox98 | --- | fixed |
People
(Reporter: masayuki, Assigned: masayuki)
References
Details
Attachments
(1 file)
If there is a stack class
struct MOZ_STACK_CLASS Foo final {
MOZ_KNOWN_LIVE RefPtr<Bar> mBar;
};
and calling a method marked as MOZ_CAN_RUN_SCRIPT
with it,
Foo foo{bar};
MayRunScript(foo.mBar);
and
Foo foo{bar};
MayRunScript(*foo.mBar);
becomes compile error. They require MOZ_KnownLive()
.
Assignee | ||
Comment 1•3 years ago
|
||
MOZ_KNOWN_LIVE RefPtr<Foo> mFoo
is not treated as safe because its raw pointer
is referred with operators but they are not checked at handling MOZ_KNOWN_LIVE
annotation.
Additionally, when members marked as MOZ_KNOWN_LIVE
are in the stack, they
are also not treated as safe, but they should be safe in most cases.
With these changes, HTMLTableEditor.cpp
can get rid of a lot of
MOZ_KnownLive
method calls.
Updated•3 years ago
|
Comment 4•3 years ago
|
||
bugherder |
Comment 5•3 years ago
|
||
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #0)
If there is a stack class
struct MOZ_STACK_CLASS Foo final { MOZ_KNOWN_LIVE RefPtr<Bar> mBar; };
Fwiw this could've been fixed by marking the pointer as const (so const RefPtr...
), but I guess that doesn't work for all your use cases?
Assignee | ||
Comment 6•3 years ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #5)
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #0)
If there is a stack class
struct MOZ_STACK_CLASS Foo final { MOZ_KNOWN_LIVE RefPtr<Bar> mBar; };
Fwiw this could've been fixed by marking the pointer as const (so
const RefPtr...
), but I guess that doesn't work for all your use cases?
Yeah, if it requires complicated computation or delay for initializing the member, const
is not useful (of course, can use const_cast
though).
Updated•2 years ago
|
Description
•