Skip to content

Address safer CPP warnings in NetworkSessionCocoa #47231

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

Conversation

csaavedra
Copy link
Member

@csaavedra csaavedra commented Jun 26, 2025

200dfcc

Address safer CPP warnings in NetworkSessionCocoa
https://bugs.webkit.org/show_bug.cgi?id=295023

Reviewed by Chris Dumez.

WebSocketTaskCocoa needs to inherit from thread-safe checked pointer class
for it to safely be able to use CheckedPtr, so do that as well.

* Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
(processServerTrustEvaluation):
(-[WKNetworkSessionDelegate sessionFromTask:]):
(NetworkSessionCocoa::setClientAuditToken):
(-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
(-[WKNetworkSessionDelegate URLSession:task:didCompleteWithError:]):
(-[WKNetworkSessionDelegate URLSession:downloadTask:didFinishDownloadingToURL:]):
(-[WKNetworkSessionDelegate URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:]):
(-[WKNetworkSessionDelegate URLSession:webSocketTask:didOpenWithProtocol:]):
(-[WKNetworkSessionDelegate URLSession:webSocketTask:didCloseWithCode:reason:]):
(WebKit::proxyDictionary):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
(WebKit::SessionSet::isolatedSession):
(WebKit::NetworkSessionCocoa::continueDidReceiveChallenge):
(WebKit::NetworkSessionCocoa::createWebSocketTask):
(WebKit::NetworkSessionCocoa::forEachSessionWrapper):
* Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.h:
* Source/WebKit/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations:
* Source/WebKit/SaferCPPExpectations/UncheckedLocalVarsCheckerExpectations:
* Source/WebKit/SaferCPPExpectations/UnretainedCallArgsCheckerExpectations:

Canonical link: https://commits.webkit.org/296794@main

a2b4861

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@csaavedra csaavedra requested a review from cdumez as a code owner June 26, 2025 11:45
@csaavedra csaavedra self-assigned this Jun 26, 2025
@csaavedra csaavedra added the WebKit Misc. For miscellaneous bugs in the WebKit framework (and not JavaScriptCore or WebCore). label Jun 26, 2025
@csaavedra csaavedra requested a review from rniwa June 26, 2025 11:46
Comment on lines 1482 to 1481
configuration.get().connectionProxyDictionary = (NSDictionary *)parameters.proxyConfiguration.get() ?: proxyDictionary(parameters.httpProxy, parameters.httpsProxy).get();
configuration.get().connectionProxyDictionary = RetainPtr<NSDictionary> { (NSDictionary*)parameters.proxyConfiguration.get() }.get() ?: proxyDictionary(parameters.httpProxy, parameters.httpsProxy).get();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would specially appreciate comments on this one, I am not sure this is the best approach or if it will suffice to address the warning.

@csaavedra csaavedra force-pushed the eng/Address-safer-CPP-warnings-in-NetworkSessionCocoa branch from 86069d2 to 4278a1b Compare June 26, 2025 12:41
@webkit-ews-buildbot
Copy link
Collaborator

Safer C++ Build #41671 (4278a1b)

❌ Found 1 failing file with 3 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@csaavedra csaavedra force-pushed the eng/Address-safer-CPP-warnings-in-NetworkSessionCocoa branch from 4278a1b to e636cba Compare June 26, 2025 14:32
@webkit-ews-buildbot
Copy link
Collaborator

Safer C++ Build #41678 (e636cba)

❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@csaavedra
Copy link
Member Author

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 26, 2025
@rniwa
Copy link
Member

rniwa commented Jun 27, 2025

Safer C++ Build #41678 (e636cba)

❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. (cc @rniwa)

@rniwa there was a way to suppress these, right? https://ews-build.s3-us-west-2.amazonaws.com/macOS-Safer-CPP-Checks-EWS/e636cba0-41678/scan-build-output/StaticAnalyzerRegressions/WebKitLegacy/StaticAnalyzerReports/report-NetworkSessionCocoa.mm-createWebSocketTask-17-bad1e3.html#EndPath

Oh weird. I thought added the support for recognizing those constants.

Anyhow, you can suppress it with SUPPRESS_UNRETAINED_ARG.

@csaavedra csaavedra removed the merging-blocked Applied to prevent a change from being merged label Jun 27, 2025
@csaavedra csaavedra force-pushed the eng/Address-safer-CPP-warnings-in-NetworkSessionCocoa branch from e636cba to a2b4861 Compare June 27, 2025 09:26
@csaavedra
Copy link
Member Author

Ping reviewers.

@csaavedra csaavedra added the safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks label Jun 30, 2025
@webkit-ews-buildbot webkit-ews-buildbot added merge-queue Applied to send a pull request to merge-queue and removed safe-merge-queue Applied to automatically send a pull-request to merge-queue after passing EWS checks labels Jun 30, 2025
@webkit-ews-buildbot
Copy link
Collaborator

Safe-Merge-Queue: Build #61859.

https://bugs.webkit.org/show_bug.cgi?id=295023

Reviewed by Chris Dumez.

WebSocketTaskCocoa needs to inherit from thread-safe checked pointer class
for it to safely be able to use CheckedPtr, so do that as well.

* Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
(processServerTrustEvaluation):
(-[WKNetworkSessionDelegate sessionFromTask:]):
(NetworkSessionCocoa::setClientAuditToken):
(-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
(-[WKNetworkSessionDelegate URLSession:task:didCompleteWithError:]):
(-[WKNetworkSessionDelegate URLSession:downloadTask:didFinishDownloadingToURL:]):
(-[WKNetworkSessionDelegate URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:]):
(-[WKNetworkSessionDelegate URLSession:webSocketTask:didOpenWithProtocol:]):
(-[WKNetworkSessionDelegate URLSession:webSocketTask:didCloseWithCode:reason:]):
(WebKit::proxyDictionary):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
(WebKit::SessionSet::isolatedSession):
(WebKit::NetworkSessionCocoa::continueDidReceiveChallenge):
(WebKit::NetworkSessionCocoa::createWebSocketTask):
(WebKit::NetworkSessionCocoa::forEachSessionWrapper):
* Source/WebKit/NetworkProcess/cocoa/WebSocketTaskCocoa.h:
* Source/WebKit/SaferCPPExpectations/UncheckedCallArgsCheckerExpectations:
* Source/WebKit/SaferCPPExpectations/UncheckedLocalVarsCheckerExpectations:
* Source/WebKit/SaferCPPExpectations/UnretainedCallArgsCheckerExpectations:

Canonical link: https://commits.webkit.org/296794@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Address-safer-CPP-warnings-in-NetworkSessionCocoa branch from a2b4861 to 200dfcc Compare June 30, 2025 14:56
@webkit-commit-queue
Copy link
Collaborator

Committed 296794@main (200dfcc): https://commits.webkit.org/296794@main

Reviewed commits have been landed. Closing PR #47231 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 200dfcc into WebKit:main Jun 30, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit Misc. For miscellaneous bugs in the WebKit framework (and not JavaScriptCore or WebCore).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants