-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Reduce unsafeness in WebGPU module #47342
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
base: main
Are you sure you want to change the base?
Conversation
EWS run on previous version of this PR (hash aca9e84) |
Safer C++ Build #41981 (aca9e84)
|
@@ -90,7 +90,7 @@ class GPUBuffer : public RefCountedAndCanMakeWeakPtr<GPUBuffer> { | |||
const GPUBufferUsageFlags m_usage { 0 }; | |||
GPUBufferMapState m_mapState { GPUBufferMapState::Unmapped }; | |||
std::optional<MapAsyncPromise> m_pendingMapPromise; | |||
WeakPtr<GPUDevice, WeakPtrImplWithEventTargetData> m_device; | |||
const WeakPtr<GPUDevice, WeakPtrImplWithEventTargetData> m_device; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not protect anything since the type is WeakPtr and WeakPtr does not keep the object alive. This should not help for the purpose of static analysis and if it does, I believe it would likely be a bug in the static analyzer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but I saw people adding these in other PRs so I figured I'd do it as drive-by as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what's the purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I misunderstood. I'll revert that change and those like it.
aca9e84
to
38ac9df
Compare
EWS run on previous version of this PR (hash 38ac9df) |
RefPtr currentTexture = m_currentTexture; | ||
if ((!currentTexture || currentTexture->isDestroyed()) && m_device.get()) { | ||
if (auto backingCurrentTexture = m_backing->getCurrentTexture(index)) { | ||
currentTexture = GPUTexture::create(*backingCurrentTexture, m_textureDescriptor, *m_device.get()).ptr(); | ||
m_currentTexture = currentTexture.copyRef(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could just inline isDestroyed()
and avoid doing all of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out, I'll make that change!
if (!nativeImage) | ||
return callback({ }, 0, 0); | ||
RetainPtr platformImage = nativeImage->platformImage(); | ||
if (!platformImage) | ||
return callback({ }, 0, 0); | ||
RetainPtr pixelDataCfData = adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(platformImage.get()))); | ||
RetainPtr pixelDataCfData = adoptCF(CGDataProviderCopyData(RetainPtr { CGImageGetDataProvider(platformImage.get()) }.get())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does RetainPtr
here extend the lifetime of the result returned from GImageGetDataProvider(platformImage.get())
? Wouldn't RetainPtr::~RetainPtr
run prior to the invocation of CGDataProviderCopyData
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does
RetainPtr
here extend the lifetime of the result returned fromGImageGetDataProvider(platformImage.get())
?
Yes.
Wouldn't
RetainPtr::~RetainPtr
run prior to the invocation ofCGDataProviderCopyData
?
I do not think so?
38ac9df
to
e1f5964
Compare
EWS run on previous version of this PR (hash e1f5964) |
https://bugs.webkit.org/show_bug.cgi?id=295160 Reviewed by NOBODY (OOPS!). Apply https://github.com/WebKit/WebKit/wiki/Safer-CPP-Guidelines
e1f5964
to
a854904
Compare
EWS run on current version of this PR (hash a854904) |
a854904
a854904