summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/socket.cc
diff options
context:
space:
mode:
authorJamie Liu <jamieliu@google.com>2021-07-08 12:23:43 -0700
committergVisor bot <gvisor-bot@google.com>2021-07-08 12:26:56 -0700
commitfbd4ccf33339a261812521fbc54554850a70676c (patch)
tree560430011fa0d2829ebd535760e075b50a0ca0de /test/syscalls/linux/socket.cc
parent07f2c8b56b5948759b3df6587a8fcea13fbcc82b (diff)
Fix async-signal-unsafety in socket test.
PiperOrigin-RevId: 383689096
Diffstat (limited to 'test/syscalls/linux/socket.cc')
-rw-r--r--test/syscalls/linux/socket.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/test/syscalls/linux/socket.cc b/test/syscalls/linux/socket.cc
index 7b966484d..2742d19be 100644
--- a/test/syscalls/linux/socket.cc
+++ b/test/syscalls/linux/socket.cc
@@ -119,6 +119,9 @@ TEST(SocketTest, UnixSCMRightsOnlyPassedOnce) {
// Send more than what will fit inside the send/receive buffers, so that it is
// split into multiple messages.
constexpr int kBufSize = 0x100000;
+ // Heap allocation is async-signal-unsafe and thus cannot occur between fork()
+ // and execve().
+ std::vector<char> buf(kBufSize);
pid_t pid = fork();
if (pid == 0) {
@@ -127,7 +130,6 @@ TEST(SocketTest, UnixSCMRightsOnlyPassedOnce) {
// Construct a message with some control message.
struct msghdr msg = {};
char control[CMSG_SPACE(sizeof(int))] = {};
- std::vector<char> buf(kBufSize);
struct iovec iov = {};
msg.msg_control = control;
msg.msg_controllen = sizeof(control);
@@ -154,7 +156,6 @@ TEST(SocketTest, UnixSCMRightsOnlyPassedOnce) {
struct msghdr msg = {};
char control[CMSG_SPACE(sizeof(int))] = {};
- std::vector<char> buf(kBufSize);
struct iovec iov = {};
msg.msg_control = &control;
msg.msg_controllen = sizeof(control);