Open
Description
Previous ID | SR-16036 |
Radar | None |
Original Reporter | Valérian (JIRA User) |
Type | Bug |
Attachment: Download
Environment
docker run --rm --privileged --interactive --tty \
--volume "$(pwd):/app" \
--workdir "/app" \
swift:latest
Additional Detail from JIRA
Votes | 0 |
Component/s | Foundation |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: b2f32a2c7a5cb919c6e8d5d26153f2d6
Issue Description:
It seems that a FileHandle passed to standardOutput of a Process is never closed on Linux.
root@8594866e314d:/app# swiftc -g process.swift
root@8594866e314d:/app# ./process &
[2] 190
root@8594866e314d:/app# Success launching process
TerminationHandler called
Writing to test.txt
root@8594866e314d:/app# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 18520 3380 pts/0 Ss 12:20 0:00 bash
root 190 0.3 0.8 376788 16360 pts/0 Sl 12:47 0:00 ./process
root 197 0.0 0.1 34416 2888 pts/0 R+ 12:48 0:00 ps aux
root@8594866e314d:/app# ls -l /proc/190/fd
total 0
lrwx------ 1 root root 64 Mar 22 12:47 0 -> /dev/pts/0
lrwx------ 1 root root 64 Mar 22 12:47 1 -> /dev/pts/0
lrwx------ 1 root root 64 Mar 22 12:47 10 -> 'anon_inode:[eventpoll]'
lrwx------ 1 root root 64 Mar 22 12:47 11 -> 'anon_inode:[eventfd]'
lrwx------ 1 root root 64 Mar 22 12:47 12 -> 'socket:[20040]'
lrwx------ 1 root root 64 Mar 22 12:47 13 -> 'socket:[20041]'
lrwx------ 1 root root 64 Mar 22 12:47 14 -> 'anon_inode:[eventfd]'
lrwx------ 1 root root 64 Mar 22 12:48 15 -> 'anon_inode:[signalfd]'
lrwx------ 1 root root 64 Mar 22 12:48 16 -> 'anon_inode:[timerfd]'
lrwx------ 1 root root 64 Mar 22 12:47 2 -> /dev/pts/0
l-wx------ 1 root root 64 Mar 22 12:47 3 -> /tmp/process.log
lrwx------ 1 root root 64 Mar 22 12:47 4 -> 'anon_inode:[eventfd]'
lrwx------ 1 root root 64 Mar 22 12:47 5 -> 'anon_inode:[eventpoll]'
lrwx------ 1 root root 64 Mar 22 12:47 6 -> 'anon_inode:[timerfd]'
lrwx------ 1 root root 64 Mar 22 12:47 7 -> 'anon_inode:[eventfd]'
lrwx------ 1 root root 64 Mar 22 12:47 8 -> 'anon_inode:[eventpoll]'
lrwx------ 1 root root 64 Mar 22 12:47 9 -> 'anon_inode:[timerfd]'
On macOS, if inside an autoreleasepool then the file descriptor gets closed.
When using the FileHandle outside of a Process then its file descriptor correctly gets closed. Maybe the FileHandle is leaked under Linux ? Building with `–sanitize=address` indicates a direct leak.