Skip to content
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

IPC testing API is unable to reply with nullopt optional #29756

Conversation

kkinnunen-apple
Copy link
Contributor

@kkinnunen-apple kkinnunen-apple commented Jun 12, 2024

8ebae84

IPC testing API is unable to reply with nullopt optional
https://bugs.webkit.org/show_bug.cgi?id=275409
rdar://129669346

Reviewed by Cameron McCormack.

Decoding std::optional would return empty JSValue (JSValue()) if the
optional was std::nullopt. This would be interpreted as a decoding
failure.

Fix this by returning the more natural value, jsUndefined value. Fix the
result array construction to not use jsUndefined to signify that the
value should be a array buffer containing the data. Use empty JSValue to
signify this. Use exception scope to detect when JS exception would
cancel the decoding as a decoding failure.

Decoding failures would use the already cleared exception as the result
JS object, causing a crash.

Fix by first constructing the JS value, then clearing the exception from
the scope.

Add decoder for WebCore::ExceptionData, to be used in testing the
message this problem was noted.

* LayoutTests/ipc/async-with-reply-optional.html: Added.
* Source/WebKit/Platform/IPC/JSIPCBinding.cpp:
(IPC::jsValueForDecodedArgumentValue):
(IPC::putJSValueForDecodedArgumentAtIndexOrArrayBufferIfUndefined): Deleted.
* Source/WebKit/Platform/IPC/JSIPCBinding.h:
(IPC::jsValueForDecodedArgumentValue):
(IPC::putJSValueForDecodeArgumentInArray):
* Source/WebKit/Shared/IPCTester.cpp:
(WebKit::IPCTester::asyncOptionalExceptionData):
* Source/WebKit/Shared/IPCTester.h:
* Source/WebKit/Shared/IPCTester.messages.in:
* Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp:
(WebKit::IPCTestingAPI::jsSendWithAsyncReply):

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

7a57230

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2   πŸ§ͺ wincairo-tests
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2   πŸ§ͺ api-mac   πŸ§ͺ api-wpe
  πŸ§ͺ ios-wk2-wpt   πŸ§ͺ mac-wk1 βœ… πŸ›  wpe-cairo
  πŸ§ͺ api-ios   πŸ§ͺ mac-wk2 βœ… πŸ›  gtk
βœ… πŸ›  tv   πŸ§ͺ mac-AS-debug-wk2   πŸ§ͺ gtk-wk2
βœ… πŸ›  tv-sim   πŸ§ͺ mac-wk2-stress   πŸ§ͺ api-gtk
βœ… πŸ›  watch
βœ… πŸ›  πŸ§ͺ unsafe-merge βœ… πŸ›  watch-sim

@kkinnunen-apple kkinnunen-apple self-assigned this Jun 12, 2024
@kkinnunen-apple kkinnunen-apple added the Tools / Tests Tools in the Tools directory, build issues, test infrastructure, and bugs in test cases label Jun 12, 2024
Copy link
Contributor

@heycam heycam left a comment

Choose a reason for hiding this comment

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

In the commit message:

Decoding std::optional would return JSValue if the optional was
std::nullopt.

Is there a word missing?

@kkinnunen-apple kkinnunen-apple force-pushed the ipc-testing-async-reply-optional-1 branch from 8ce77a9 to 7a57230 Compare June 14, 2024 06:11
@kkinnunen-apple kkinnunen-apple added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Jun 14, 2024
https://bugs.webkit.org/show_bug.cgi?id=275409
rdar://129669346

Reviewed by Cameron McCormack.

Decoding std::optional would return empty JSValue (JSValue()) if the
optional was std::nullopt. This would be interpreted as a decoding
failure.

Fix this by returning the more natural value, jsUndefined value. Fix the
result array construction to not use jsUndefined to signify that the
value should be a array buffer containing the data. Use empty JSValue to
signify this. Use exception scope to detect when JS exception would
cancel the decoding as a decoding failure.

Decoding failures would use the already cleared exception as the result
JS object, causing a crash.

Fix by first constructing the JS value, then clearing the exception from
the scope.

Add decoder for WebCore::ExceptionData, to be used in testing the
message this problem was noted.

* LayoutTests/ipc/async-with-reply-optional.html: Added.
* Source/WebKit/Platform/IPC/JSIPCBinding.cpp:
(IPC::jsValueForDecodedArgumentValue):
(IPC::putJSValueForDecodedArgumentAtIndexOrArrayBufferIfUndefined): Deleted.
* Source/WebKit/Platform/IPC/JSIPCBinding.h:
(IPC::jsValueForDecodedArgumentValue):
(IPC::putJSValueForDecodeArgumentInArray):
* Source/WebKit/Shared/IPCTester.cpp:
(WebKit::IPCTester::asyncOptionalExceptionData):
* Source/WebKit/Shared/IPCTester.h:
* Source/WebKit/Shared/IPCTester.messages.in:
* Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp:
(WebKit::IPCTestingAPI::jsSendWithAsyncReply):

Canonical link: https://commits.webkit.org/279999@main
@webkit-commit-queue webkit-commit-queue force-pushed the ipc-testing-async-reply-optional-1 branch from 7a57230 to 8ebae84 Compare June 14, 2024 06:17
@webkit-commit-queue
Copy link
Collaborator

Committed 279999@main (8ebae84): https://commits.webkit.org/279999@main

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

@webkit-commit-queue webkit-commit-queue merged commit 8ebae84 into WebKit:main Jun 14, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools / Tests Tools in the Tools directory, build issues, test infrastructure, and bugs in test cases
Projects
None yet
4 participants