Skip to content

"Could not copy" (Operation not permitted) when compiling in a docker container #51266

Closed
@mattgodbolt

Description

@mattgodbolt

I'm the maintainer of Compiler Explorer, and recently (in the last 2-3 days) the nightly build of Rust has started reporting an error when I try and compile using it from within a Docker container:

root@c45dac5bb5c7:/tmp# cat > test.rs
pub fn square(num: i32) -> i32 {
    num * num
}
root@c45dac5bb5c7:/tmp# strace -f -o/tmp/moo /opt/compiler-explorer/rust-nightly/bin/rustc -C debuginfo=1 -o /tmp/moose.s --emit asm test.rs --crate-type rlib                                                     
error: could not copy "/tmp/moose.test0.rcgu.s" to "/tmp/moose.s": Operation not permitted (os error 1)

error: aborting due to previous error

The same compile works just fine outside of a container. The strace call yields the problem call:

4809  stat("/tmp/moose.test0.rcgu.s", {st_mode=S_IFREG|0644, st_size=3360, ...}) = 0
4809  open("/tmp/moose.test0.rcgu.s", O_RDONLY|O_CLOEXEC) = 5
4809  open("/tmp/moose.s", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 6
4809  fstat(5, {st_mode=S_IFREG|0644, st_size=3360, ...}) = 0
4809  syscall_18446744073709551615(0x5, 0, 0x6, 0, 0xd20, 0x7f3200000000) = -1 (errno 1)
4809  close(6)                          = 0
4809  close(5)                          = 0
4809  write(2, "\33[0m\33[1m\33[38;5;9merror\33[0m\33[0m\33["..., 137) = 137
4809  write(2, "\n", 1)                 = 1
4809  unlink("/tmp/moose.test0.rcgu.s") = 0

It seems whatever "syscall_18446744073709551615" is, it's getting EPERM.

Cross checking from outside a docker container:

6206  open("/tmp/moose.s", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 6
6206  fstat(5, {st_mode=S_IFREG|0664, st_size=3360, ...}) = 0
6206  syscall_326(0x5, 0, 0x6, 0, 0xd20, 0x7f3f00000000) = -1 (errno 38)
6206  read(5, "\t.text\n\t.file\t\"test0-8787f43e282"..., 8192) = 3360
6206  write(6, "\t.text\n\t.file\t\"test0-8787f43e282"..., 3360) = 3360
6206  read(5, "", 8192)                 = 0
6206  chmod("/tmp/moose.s", 0100664)    = 0
6206  close(6)                          = 0
6206  close(5)                          = 0
6206  unlink("/tmp/moose.test0.rcgu.s") = 0

in this case things succeed (although the syscall_326, whatever that is still fails, but with ENOSYS).

Can anyone shed any light on this as this is outside of my experience! As I say, it only happens on the nightly build, and it has started happening in the last day or two (e.g. sometime around 29th May 2018).

I wonder if some new (unsupported on Ubuntu 16) libc function is being called, and in the docker environment EPERM is returned instead of ENOSYS, which confuses some bailout code in rustc?

Thanks in advance, Matt

(See also compiler-explorer/compiler-explorer#942 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions