Potential crash due to pthread_setaffinity_np() and cpuset #695

Closed
moreati opened this Issue Jun 18, 2015 · 3 comments

Comments

Projects
None yet
2 participants
Contributor

moreati commented Jun 18, 2015

I run a weird mashup of Ubuntu 15.04 and Linux kernel 4.1.0-040100rc1-generic. As a result if I search with ag the following happens:

alex@martha:~$ /usr/local/bin/ag foo
ERR: error in pthread_setaffinity_np(): Invalid argument

This doesn't occur on a vanilla 15.04 installation, as far as I know only I'm affected. I'm only reporting this bug for reference, feel free to close it as WONTFIX

It's fine if I disable affinity

(v)alex@martha:~$ /usr/local/bin/ag --noaffinity foo
go/src/llvm.org/llvm/Makefile.rules
2116:check-footprint:
...

I believe this is due to cpuset being somehow enabled, and having a policy restricting processes to the 0th core:

alex@martha:~$ mount | grep cpuset
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset,clone_children)
alex@martha:~$ grep Cpus /proc/self/status
Cpus_allowed:   01
Cpus_allowed_list:  0

The relevant documentation is http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html#ERRORS:

  EINVAL (pthread_setaffinity_np()) The affinity bit mask mask contains
         no processors that are currently physically on the system and
         permitted to the thread according to any restrictions that may
         be imposed by the "cpuset" mechanism described in cpuset(7).
Owner

ggreer commented Jun 18, 2015

Maybe ag could just warn or print an error instead of dying. Would that be better for you?

Contributor

moreati commented Jun 18, 2015

That would be fine, but as I said this is not a priority by any means. alias ag=ag --noaffinity is a very satisfactory workaround.

@ggreer ggreer closed this in 0b89394 Jun 18, 2015

Owner

ggreer commented Jun 18, 2015

Alright. It's fixed in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment