Skip to content

Commit 0742ed6

Browse files
a-sivacommit-bot@chromium.org
authored andcommitted
[VM/Tests] - Fix new abstract_socket_test.
- Skip in configurations that do not build the abstract_socket_test executable - Fix MemorySanitizer: use-of-uninitialized-value error TEST=existing test - unix-socket-test Change-Id: Ie9bf6dc1cd6bea98cd7859584473154f6ac49eee Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201722 Reviewed-by: Siva Annamalai <[email protected]> Commit-Queue: Siva Annamalai <[email protected]>
1 parent d05093e commit 0742ed6

File tree

7 files changed

+21
-6
lines changed

7 files changed

+21
-6
lines changed

runtime/bin/socket_base.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ int SocketAddress::GetType() {
3434
}
3535
}
3636

37-
intptr_t SocketAddress::GetAddrLength(const RawAddr& addr) {
37+
intptr_t SocketAddress::GetAddrLength(const RawAddr& addr,
38+
bool unnamed_unix_socket) {
3839
ASSERT((addr.ss.ss_family == AF_INET) || (addr.ss.ss_family == AF_INET6) ||
3940
(addr.ss.ss_family == AF_UNIX));
4041
switch (addr.ss.ss_family) {
@@ -53,7 +54,7 @@ intptr_t SocketAddress::GetAddrLength(const RawAddr& addr) {
5354
// trailing null bytes on purpose.
5455
// https://github.com/dart-lang/sdk/issues/46158
5556
intptr_t nulls = 0;
56-
if (addr.un.sun_path[0] == '\0') {
57+
if (!unnamed_unix_socket && addr.un.sun_path[0] == '\0') {
5758
intptr_t i = sizeof(addr.un.sun_path) - 1;
5859
while (addr.un.sun_path[i] == '\0') {
5960
nulls++;

runtime/bin/socket_base.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class SocketAddress {
6969
const char* as_string() const { return as_string_; }
7070
const RawAddr& addr() const { return addr_; }
7171

72-
static intptr_t GetAddrLength(const RawAddr& addr);
72+
static intptr_t GetAddrLength(const RawAddr& addr,
73+
bool unnamed_unix_socket = false);
7374
static intptr_t GetInAddrLength(const RawAddr& addr);
7475
static bool AreAddressesEqual(const RawAddr& a, const RawAddr& b);
7576
static void GetSockAddr(Dart_Handle obj, RawAddr* addr);

runtime/bin/socket_base_android.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ SocketAddress::SocketAddress(struct sockaddr* sa, bool unnamed_unix_socket) {
4040
as_string_[0] = 0;
4141
}
4242
}
43-
socklen_t salen = GetAddrLength(*reinterpret_cast<RawAddr*>(sa));
43+
socklen_t salen =
44+
GetAddrLength(*reinterpret_cast<RawAddr*>(sa), unnamed_unix_socket);
4445
memmove(reinterpret_cast<void*>(&addr_), sa, salen);
4546
}
4647

runtime/bin/socket_base_linux.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ SocketAddress::SocketAddress(struct sockaddr* sa, bool unnamed_unix_socket) {
4040
as_string_[0] = 0;
4141
}
4242
}
43-
socklen_t salen = GetAddrLength(*reinterpret_cast<RawAddr*>(sa));
43+
socklen_t salen =
44+
GetAddrLength(*reinterpret_cast<RawAddr*>(sa), unnamed_unix_socket);
4445
memmove(reinterpret_cast<void*>(&addr_), sa, salen);
4546
}
4647

runtime/bin/socket_base_macos.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ SocketAddress::SocketAddress(struct sockaddr* sa, bool unnamed_unix_socket) {
3939
as_string_[0] = 0;
4040
}
4141
}
42-
socklen_t salen = GetAddrLength(*reinterpret_cast<RawAddr*>(sa));
42+
socklen_t salen =
43+
GetAddrLength(*reinterpret_cast<RawAddr*>(sa), unnamed_unix_socket);
4344
memmove(reinterpret_cast<void*>(&addr_), sa, salen);
4445
}
4546

tests/standalone/io/unix_socket_test.dart

+5
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ Future testShortAbstractAddress() async {
179179
try {
180180
var socketAddress = '@hidden';
181181
var abstractSocketServer = getAbstractSocketTestFileName();
182+
// check if the executable exists, some build configurations do not
183+
// build it (e.g: precompiled simarm/simarm64)
184+
if (!File(abstractSocketServer).existsSync()) {
185+
return;
186+
}
182187
process = await Process.start(abstractSocketServer, [socketAddress]);
183188
var serverAddress =
184189
InternetAddress(socketAddress, type: InternetAddressType.unix);

tests/standalone_2/io/unix_socket_test.dart

+5
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ Future testShortAbstractAddress() async {
181181
try {
182182
var socketAddress = '@hidden';
183183
var abstractSocketServer = getAbstractSocketTestFileName();
184+
// check if the executable exists, some build configurations do not
185+
// build it (e.g: precompiled simarm/simarm64)
186+
if (!File(abstractSocketServer).existsSync()) {
187+
return;
188+
}
184189
process = await Process.start(abstractSocketServer, [socketAddress]);
185190
var serverAddress =
186191
InternetAddress(socketAddress, type: InternetAddressType.unix);

0 commit comments

Comments
 (0)