runner: explicitly signal error from handshaker. When the handshaker fails to parse a config it currently exits. This causes the two pipes to signal EOF to the shim, but the control channel is a datagram socket in order to be atomic, thus doesn't signal an error. In the shim, EOF on the wfd pipe causes a short loop and thus a hang forever. Catching the EOF and returning an error doesn't work because some tests will close the pipe but still return information over the control channel. We can start a timeout once wfd is closed, but that seems like it might be flakey. Thus this change makes the handshaker send an explicit error over the control channel. It doesn't catch crashes, but it will catch config errors, which are much more common in cross-version tests. Change-Id: I4b1afed17694c57e4713d1b0fa4e9ecb12f09ec5 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/43865 Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/ssl/test/handshaker.cc b/ssl/test/handshaker.cc index a6bf643..72d6b2f 100644 --- a/ssl/test/handshaker.cc +++ b/ssl/test/handshaker.cc
@@ -127,13 +127,21 @@ return ret; } +int SignalError() { + const char msg = kControlMsgError; + if (write_eintr(kFdControl, &msg, 1) != 1) { + return 2; + } + return 1; +} + } // namespace int main(int argc, char **argv) { TestConfig initial_config, resume_config, retry_config; if (!ParseConfig(argc - 1, argv + 1, &initial_config, &resume_config, &retry_config)) { - return 2; + return SignalError(); } const TestConfig *config = initial_config.handshaker_resume ? &resume_config : &initial_config; @@ -160,11 +168,7 @@ Span<uint8_t> handoff(buf.get(), len); if (!Handshaker(config, kFdProxyToHandshaker, kFdHandshakerToProxy, handoff, kFdControl)) { - char msg = kControlMsgError; - if (write_eintr(kFdControl, &msg, 1) != 1) { - return 3; - } - return 1; + return SignalError(); } return 0; }