Author: David Spickett Date: 2025-06-13T14:26:06Z New Revision: 82911f188be7ce7cb0a04b7fd648ea8b4aad2e59
URL: https://github.com/llvm/llvm-project/commit/82911f188be7ce7cb0a04b7fd648ea8b4aad2e59 DIFF: https://github.com/llvm/llvm-project/commit/82911f188be7ce7cb0a04b7fd648ea8b4aad2e59.diff LOG: [lldb][test] Skip ReadAfterClose JSON Transport tests on Windows These were failing on our Windows on Arm bot, or more precisely, not even completing. This is because Microsoft's C runtime does extra parameter validation. So when we called _read with an invalid fd, it called an invalid parameter handler instead of returning an error. https://learn.microsoft.com/en-us/%20cpp/c-runtime-library/reference/read?view=msvc-170 https://learn.microsoft.com/en-us/%20cpp/c-runtime-library/parameter-validation?view=msvc-170 (lldb) run Process 8440 launched: 'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\unittests\Host\HostTests.exe' (aarch64) Process 8440 stopped * thread #1, stop reason = Exception 0xc0000409 encountered at address 0x7ffb7453564c frame #0: 0x00007ffb7453564c ucrtbase.dll`_get_thread_local_invalid_parameter_handler + 652 ucrtbase.dll`_get_thread_local_invalid_parameter_handler: -> 0x7ffb7453564c <+652>: brk #0xf003 ucrtbase.dll`_invalid_parameter_noinfo: 0x7ffb74535650 <+0>: b 0x7ffb745354d8 ; _get_thread_local_invalid_parameter_handler + 280 0x7ffb74535654 <+4>: nop 0x7ffb74535658 <+8>: nop You can override this handler but I'm assuming that this reading after close isn't a crucial feature, so disabling the tests seems like the way to go. If it is crucial, we can check the fd before we use it. Tests added by https://github.com/llvm/llvm-project/pull/143946. Added: Modified: lldb/unittests/Host/JSONTransportTest.cpp Removed: ################################################################################ diff --git a/lldb/unittests/Host/JSONTransportTest.cpp b/lldb/unittests/Host/JSONTransportTest.cpp index f1ec5e03bbeca..4621869887ac8 100644 --- a/lldb/unittests/Host/JSONTransportTest.cpp +++ b/lldb/unittests/Host/JSONTransportTest.cpp @@ -84,12 +84,6 @@ TEST_F(HTTPDelimitedJSONTransportTest, ReadWithEOF) { Failed<TransportEOFError>()); } -TEST_F(HTTPDelimitedJSONTransportTest, ReadAfterClosed) { - input.CloseReadFileDescriptor(); - ASSERT_THAT_EXPECTED( - transport->Read<JSONTestType>(std::chrono::milliseconds(1)), - llvm::Failed()); -} TEST_F(HTTPDelimitedJSONTransportTest, InvalidTransport) { transport = std::make_unique<HTTPDelimitedJSONTransport>(nullptr, nullptr); @@ -136,13 +130,6 @@ TEST_F(JSONRPCTransportTest, ReadWithEOF) { Failed<TransportEOFError>()); } -TEST_F(JSONRPCTransportTest, ReadAfterClosed) { - input.CloseReadFileDescriptor(); - ASSERT_THAT_EXPECTED( - transport->Read<JSONTestType>(std::chrono::milliseconds(1)), - llvm::Failed()); -} - TEST_F(JSONRPCTransportTest, Write) { ASSERT_THAT_ERROR(transport->Write(JSONTestType{"foo"}), Succeeded()); output.CloseWriteFileDescriptor(); @@ -173,4 +160,22 @@ TEST_F(JSONRPCTransportTest, ReadWithTimeout) { transport->Read<JSONTestType>(std::chrono::milliseconds(1)), Failed<TransportTimeoutError>()); } + +// Windows CRT _read checks that the file descriptor is valid and calls a +// handler if not. This handler is normally a breakpoint, which looks like a +// crash when not handled by a debugger. +// https://learn.microsoft.com/en-us/%20cpp/c-runtime-library/reference/read?view=msvc-170 +TEST_F(HTTPDelimitedJSONTransportTest, ReadAfterClosed) { + input.CloseReadFileDescriptor(); + ASSERT_THAT_EXPECTED( + transport->Read<JSONTestType>(std::chrono::milliseconds(1)), + llvm::Failed()); +} + +TEST_F(JSONRPCTransportTest, ReadAfterClosed) { + input.CloseReadFileDescriptor(); + ASSERT_THAT_EXPECTED( + transport->Read<JSONTestType>(std::chrono::milliseconds(1)), + llvm::Failed()); +} #endif _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits