glibc error: "free(): invalid next size" - embedded-linux

I have a program with an error, when I execute strace -e open myprogram
I have the following message:
open("/etc/ld.so.cache", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/libgnutls.so.28", O_RDONLY) = 3
open("/lib/librt.so.1", O_RDONLY) = 3
open("/usr/lib/libz.so.1", O_RDONLY) = 3
open("/usr/lib/libz.so.1", O_RDONLY) = 3
open("/usr/lib/libp11-kit.so.0", O_RDONLY) = 3
open("/usr/lib/libffi.so.6", O_RDONLY) = 3
open("/lib/libdl.so.2", O_RDONLY) = 3
open("/usr/lib/libtasn1.so.6", O_RDONLY) = 3
open("/usr/lib/libnettle.so.4", O_RDONLY) = 3
open("/usr/lib/libhogweed.so.2", O_RDONLY) = 3
open("/usr/lib/libgmp.so.10", O_RDONLY) = 3
open("/lib/libpthread.so.0", O_RDONLY) = 3
open("/lib/libc.so.6", O_RDONLY) = 3
open("/lib/libgcc_s.so.1", O_RDONLY) = 3
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=509, si_status=0, si_utime=0, si_stime=3} ---
before tls_server_init
gnutls_check_version 30105
before gnutls_global_init
open("/dev/tty", O_RDWR|O_NOCTTY|O_NONBLOCK) = 3
*** glibc detected *** /home/myprogram: free(): invalid next size (fast
): 0x01b53200 ***
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=508, si_uid=0} ---
+++ killed by SIGABRT +++
Aborted
Any ideas what the problem is?

Related

Why are there open syscalls with empty file names?

When I use opensnoop to watch file access I see a lot of open syscalls with empty file name. For example, strace cat foobar consistently produces one syscall with empty filename,
$ sudo python3 opensnoop.py
PID COMM FD ERR PATH
3819 upowerd 10 0 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/present
3819 upowerd 10 0 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/energy_now
3819 upowerd -1 2 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/voltage_max_design
3819 upowerd 10 0 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/voltage_min_design
3819 upowerd 10 0 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/status
3819 upowerd 10 0 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/power_now
3819 upowerd -1 2 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/charge_full
3819 upowerd -1 2 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/charge_full_design
3819 upowerd -1 2 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/current_now
3819 upowerd 10 0 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/voltage_now
3819 upowerd 10 0 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/capacity
3819 upowerd -1 2 /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/PNP0C0A:00/power_supply/BAT0/temp
137272 strace 3 0 /etc/ld.so.cache
137272 strace 3 0 /lib/x86_64-linux-gnu/librt.so.1
137272 strace 3 0 /lib/x86_64-linux-gnu/libunwind-ptrace.so.0
137272 strace 3 0 /lib/x86_64-linux-gnu/libunwind-x86_64.so.8
137272 strace 3 0
137272 strace 3 0 /lib/x86_64-linux-gnu/libpthread.so.0
137272 strace 3 0 /lib/x86_64-linux-gnu/liblzma.so.5
137272 strace 3 0 /lib/x86_64-linux-gnu/libunwind.so.8
137272 strace 3 0 /usr/lib/locale/locale-archive
137272 strace 3 0 /usr/share/locale/locale.alias
137272 strace -1 2 /usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo
137272 strace -1 2 /usr/share/locale/en_US/LC_MESSAGES/libc.mo
137272 strace -1 2 /usr/share/locale/en.utf8/LC_MESSAGES/libc.mo
137272 strace -1 2 /usr/share/locale/en/LC_MESSAGES/libc.mo
137272 strace -1 2 /usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/libc.mo
137272 strace -1 2 /usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo
137272 strace -1 2 /usr/share/locale-langpack/en.utf8/LC_MESSAGES/libc.mo
137272 strace -1 2 /usr/share/locale-langpack/en/LC_MESSAGES/libc.mo
137275 cat 3 0 /etc/ld.so.cache
137275 cat 3 0 /lib/x86_64-linux-gnu/libc.so.6
137275 cat 3 0 /usr/lib/locale/locale-archive
137275 cat -1 2 foobar
137275 cat 3 0 /usr/share/locale/locale.alias
137275 cat -1 2 /usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo
137275 cat -1 2 /usr/share/locale/en_US/LC_MESSAGES/libc.mo
137275 cat -1 2 /usr/share/locale/en.utf8/LC_MESSAGES/libc.mo
137275 cat -1 2 /usr/share/locale/en/LC_MESSAGES/libc.mo
137275 cat -1 2 /usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/libc.mo
137275 cat -1 2 /usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo
137275 cat -1 2 /usr/share/locale-langpack/en.utf8/LC_MESSAGES/libc.mo
137275 cat -1 2 /usr/share/locale-langpack/en/LC_MESSAGES/libc.mo
Is there a reason for such behaviour? If I want to trace file accesses do I have to treat empty file names differently? Would I miss anything by filtering them out?
I actually tried opening empty filename, but that gives an error:
// example.c
// https://stackoverflow.com/q/54793898/1374078
#define _GNU_SOURCE
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
int main(void) {
int fd1 = open(".", O_PATH);
if (fd1 == -1) {
perror("open");
return 1;
}
int fd2 = openat(fd1, "", O_RDONLY);
if (fd2 == -1) {
perror("openat");
close(fd1);
return 1;
}
close(fd1);
puts("");
return 0;
}
$ gcc -ox example.c && ./x
openat: No such file or directory
So how do empty file names get to syscalls?
UPDATE
Here is output of strace
$ strace strace cat foobar 2>&1 | grep open
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libunwind-ptrace.so.0", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libunwind-x86_64.so.8", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/liblzma.so.5", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libunwind.so.8", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "openat(AT_FDCWD, \"/etc/ld.so.cac"..., 55openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 55
write(2, "openat(AT_FDCWD, \"/lib/x86_64-li"..., 70openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 70
write(2, "openat(AT_FDCWD, \"/usr/lib/local"..., 69openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 69
write(2, "openat(AT_FDCWD, \"foobar\", O_RDO"..., 35openat(AT_FDCWD, "foobar", O_RDONLY) = 35
write(2, "openat(AT_FDCWD, \"/usr/share/loc"..., 69openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 69
write(2, "openat(AT_FDCWD, \"/usr/share/loc"..., 77openat(AT_FDCWD, "/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = 77
write(2, "openat(AT_FDCWD, \"/usr/share/loc"..., 72openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = 72
write(2, "openat(AT_FDCWD, \"/usr/share/loc"..., 74openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = 74
write(2, "openat(AT_FDCWD, \"/usr/share/loc"..., 69openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = 69
write(2, "openat(AT_FDCWD, \"/usr/share/loc"..., 86openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = 86
write(2, "openat(AT_FDCWD, \"/usr/share/loc"..., 81openat(AT_FDCWD, "/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = 81
write(2, "openat(AT_FDCWD, \"/usr/share/loc"..., 83openat(AT_FDCWD, "/usr/share/locale-langpack/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = 83
write(2, "openat(AT_FDCWD, \"/usr/share/loc"..., 78openat(AT_FDCWD, "/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = 78

In the adb shell, executing the exit command will kill the background script in android Q system

I run a adb shell script in background,for example:
sh /data/test.sh &. the thread pid is 2442
After that, I run the exit command. The background script thread will be killed.
I don't know how to fix the problem.
shell background thread should ignore the SIGHUP signal.
more info:
ps -A | grep -E "2442|1007|978"
root 978 1 134760 4860 poll_schedule_timeout 0 S adbd
root 1007 978 33492 2916 sigsuspend 0 S sh
root 2442 1007 33492 3168 0 0 R sh
I fetch signal:
# strace -p 2442
strace: Process 2442 attached
--- SIGHUP {si_signo=SIGHUP, si_code=SI_USER, si_pid=1007, si_uid=0} ---
rt_sigreturn({mask=[RTMIN]}) = 264
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], [CHLD RTMIN], 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
madvise(0x74a7648000, 4096, MADV_DONTNEED) = 0
madvise(0x74a7624000, 4096, MADV_DONTNEED) = 0
fcntl(3, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(4, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(5, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(6, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(29, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(30, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(31, F_GETFD) = -1 EBADF (Bad file descriptor)
close(2) = 0
close(1) = 0
close(0) = 0
mprotect(0x74a8298000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x74a8298000, 4096, PROT_READ) = 0
mprotect(0x74a8298000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x74a8298000, 4096, PROT_READ) = 0
munmap(0x74a8298000, 4096) = 0
exit_group(129) = ?
+++ exited with 129 +++
and parent signal info:
strace -p 1007
strace: Process 1007 attached
read(0, "\4", 1) = 1
write(2, "^D\r\n", 4) = 4
ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
write(2, "You have running jobs\n", 22) = 22
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], [CHLD RTMIN], 8) = 0
ioctl(10, TIOCGWINSZ, {ws_row=55, ws_col=102, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost -isig -icanon -echo ...}) = 0
read(0, "\n", 1) = 1
write(2, "\r\n", 2) = 2
ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], [CHLD RTMIN], 8) = 0
ioctl(10, TIOCGWINSZ, {ws_row=55, ws_col=102, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost -isig -icanon -echo ...}) = 0
read(0, "\4", 1) = 1
write(2, "^D\r\n", 4) = 4
ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
kill(-2442, SIGHUP) = 0
--- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
rt_sigreturn({mask=[RTMIN]}) = 0
nanosleep({tv_sec=1, tv_nsec=0}, 0x7ff000fe60) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], [CHLD RTMIN], 8) = 0
ioctl(10, TCGETS, {B38400 opost isig icanon echo ...}) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
madvise(0x7ec8048000, 4096, MADV_DONTNEED) = 0
madvise(0x7ec8024000, 4096, MADV_DONTNEED) = 0
fcntl(3, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(4, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(5, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(6, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(7, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(8, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(9, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(10, F_GETFD) = 0x1 (flags FD_CLOEXEC)
close(10) = 0
fcntl(11, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(31, F_GETFD) = -1 EBADF (Bad file descriptor)
close(2) = 0
close(1) = 0
close(0) = 0
mprotect(0x7ec8b48000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x7ec8b48000, 4096, PROT_READ) = 0
mprotect(0x7ec8b48000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x7ec8b48000, 4096, PROT_READ) = 0
munmap(0x7ec8b48000, 4096) = 0
exit_group(0) = ?
+++ exited with 0 +++
Use the nohup command, thus:
nohup command
This tells Android not to kill the process with SIGHUP. Run nohup --help for more information.

How to strace for X11 output "connect /tmp/.X11-unix/X1: No such file or directory"

I want to silently test whether X11 is working, from a script.
I keep getting "connect /tmp/.X11-unix/X1: No such file or directory", even if I redirect stdout and stderr to /dev/null with (for example) xset q > /dev/null 2>&1
I strace'd, and it doesn't appear to be getting written by xset. I also strace'd the relevant sshd and it doesn't seem to be writing it either.
xset, xdpyinfo and the test program at How to check if X server is running? all output this useless error message. In fact, so does vim. But "ls" does not.
I also tried: script -e -c 'xset q' /dev/null > /dev/null 2>&1
...but even that outputs the error message.
What do I need to do to silence this overaggressive error message?
Thanks!
PS: Here's an strace of xset q:
20878 execve("/usr/bin/xset", ["xset", "q"], 0x7ffe3e91cfe0 /* 33 vars */) = 0
20878 brk(NULL) = 0x563d8a664000
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=141841, ...}) = 0
20878 mmap(NULL, 141841, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f19ac118000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXmuu.so.1", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\23\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=14528, ...}) = 0
20878 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac144000
20878 mmap(NULL, 2109592, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19abd10000
20878 mprotect(0x7f19abd13000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19abf12000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f19abf12000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXext.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\2205\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=73640, ...}) = 0
20878 mmap(NULL, 2169496, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19abaf8000
20878 mprotect(0x7f19abb09000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19abd08000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10000) = 0x7f19abd08000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libX11.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\207\1\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=1277384, ...}) = 0
20878 mmap(NULL, 3374392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19ab7c0000
20878 mprotect(0x7f19ab8f3000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19abaf3000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x133000) = 0x7f19abaf3000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\34\2\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
20878 mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19ab3c8000
20878 mprotect(0x7f19ab5af000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19ab7af000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f19ab7af000
20878 mmap(0x7f19ab7b5000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19ab7b5000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libxcb.so.1", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\261\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=162232, ...}) = 0
20878 mmap(NULL, 2257576, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19ab1a0000
20878 mprotect(0x7f19ab1c6000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19ab3c6000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x26000) = 0x7f19ab3c6000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\16\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=14560, ...}) = 0
20878 mmap(NULL, 2109712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aaf98000
20878 mprotect(0x7f19aaf9b000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19ab19a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f19ab19a000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXau.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\16\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=14456, ...}) = 0
20878 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac142000
20878 mmap(NULL, 2109720, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aad90000
20878 mprotect(0x7f19aad92000, 2097152, PROT_NONE) = 0
20878 mmap(0x7f19aaf92000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f19aaf92000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libXdmcp.so.6", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\21\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=22616, ...}) = 0
20878 mmap(NULL, 2117760, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aab88000
20878 mprotect(0x7f19aab8d000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aad8c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7f19aad8c000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libbsd.so.0", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P4\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=80104, ...}) = 0
20878 mmap(NULL, 2179152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa970000
20878 mprotect(0x7f19aa983000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aab82000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0x7f19aab82000
20878 mmap(0x7f19aab84000, 80, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19aab84000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\"\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=31680, ...}) = 0
20878 mmap(NULL, 2128864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa768000
20878 mprotect(0x7f19aa76f000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aa96e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7f19aa96e000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000b\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0755, st_size=144976, ...}) = 0
20878 mmap(NULL, 2221184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa548000
20878 mprotect(0x7f19aa562000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aa761000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7f19aa761000
20878 mmap(0x7f19aa763000, 13440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19aa763000
20878 close(3) = 0
20878 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac13d000
20878 mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f19ac115000
20878 arch_prctl(ARCH_SET_FS, 0x7f19ac115740) = 0
20878 mprotect(0x7f19ab7af000, 16384, PROT_READ) = 0
20878 mprotect(0x7f19aa761000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aa96e000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aab82000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aad8c000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19aaf92000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19ab19a000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19ab3c6000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19abaf3000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19abd08000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19abf12000, 4096, PROT_READ) = 0
20878 mprotect(0x563d8872f000, 4096, PROT_READ) = 0
20878 mprotect(0x7f19ac13f000, 4096, PROT_READ) = 0
20878 munmap(0x7f19ac118000, 141841) = 0
20878 set_tid_address(0x7f19ac115a10) = 20878
20878 set_robust_list(0x7f19ac115a20, 24) = 0
20878 rt_sigaction(SIGRTMIN, {sa_handler=0x7f19aa54dcb0, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f19aa55a890}, NULL, 8) = 0
20878 rt_sigaction(SIGRT_1, {sa_handler=0x7f19aa54dd50, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f19aa55a890}, NULL, 8) = 0
20878 rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
20878 prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
20878 brk(NULL) = 0x563d8a664000
20878 brk(0x563d8a685000) = 0x563d8a685000
20878 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
20878 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
20878 close(3) = 0
20878 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
20878 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
20878 close(3) = 0
20878 openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=529, ...}) = 0
20878 read(3, "# /etc/nsswitch.conf\n#\n# Example"..., 4096) = 529
20878 read(3, "", 4096) = 0
20878 close(3) = 0
20878 stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=304, ...}) = 0
20878 openat(AT_FDCWD, "/etc/host.conf", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=92, ...}) = 0
20878 read(3, "# The \"order\" line is only used "..., 4096) = 92
20878 read(3, "", 4096) = 0
20878 close(3) = 0
20878 futex(0x7f19ab7b7ba4, FUTEX_WAKE_PRIVATE, 2147483647) = 0
20878 openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=304, ...}) = 0
20878 read(3, "# Dynamic resolv.conf(5) file fo"..., 4096) = 304
20878 read(3, "", 4096) = 0
20878 close(3) = 0
20878 uname({sysname="Linux", nodename="zareason-limbo", ...}) = 0
20878 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=141841, ...}) = 0
20878 mmap(NULL, 141841, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f19ac0f0000
20878 close(3) = 0
20878 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
20878 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
20878 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P#\0\0\0\0\0\0"..., 832) = 832
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=47568, ...}) = 0
20878 mmap(NULL, 2168632, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f19aa330000
20878 mprotect(0x7f19aa33b000, 2093056, PROT_NONE) = 0
20878 mmap(0x7f19aa53a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa000) = 0x7f19aa53a000
20878 mmap(0x7f19aa53c000, 22328, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f19aa53c000
20878 close(3) = 0
20878 mprotect(0x7f19aa53a000, 4096, PROT_READ) = 0
20878 munmap(0x7f19ac0f0000, 141841) = 0
20878 openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
20878 fstat(3, {st_mode=S_IFREG|0644, st_size=403, ...}) = 0
20878 read(3, "127.0.0.1\tlocalhost\n127.0.1.1\tza"..., 4096) = 403
20878 read(3, "", 4096) = 0
20878 close(3) = 0
20878 socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 3
20878 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0
20878 setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
20878 connect(3, {sa_family=AF_INET, sin_port=htons(6013), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
20878 getpeername(3, {sa_family=AF_INET, sin_port=htons(6013), sin_addr=inet_addr("127.0.0.1")}, [124->16]) = 0
20878 uname({sysname="Linux", nodename="zareason-limbo", ...}) = 0
20878 access("/home/dstromberg/.Xauthority", R_OK) = 0
20878 openat(AT_FDCWD, "/home/dstromberg/.Xauthority", O_RDONLY) = 4
20878 fstat(4, {st_mode=S_IFREG|0600, st_size=827, ...}) = 0
20878 read(4, "\1\0\0\16zareason-limbo\0\0010\0\22MIT-MAGIC"..., 4096) = 827
20878 read(4, "", 4096) = 0
20878 close(4) = 0
20878 getsockname(3, {sa_family=AF_INET, sin_port=htons(37214), sin_addr=inet_addr("127.0.0.1")}, [124->16]) = 0
20878 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
20878 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
20878 fcntl(3, F_SETFD, FD_CLOEXEC) = 0
20878 poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
20878 writev(3, [{iov_base="l\0\v\0\0\0\22\0\20\0\0\0", iov_len=12}, {iov_base="", iov_len=0}, {iov_base="MIT-MAGIC-COOKIE-1", iov_len=18}, {iov_base="\0\0", iov_len=2}, {iov_base="\256b\245\317f\262\25\254\27\365!H\212\3316J", iov_len=16}, {iov_base="", iov_len=0}], 6) = 48
20878 recvfrom(3, 0x563d8a6660e0, 8, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
20878 poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN|POLLERR|POLLHUP}])
20878 recvfrom(3, 0x563d8a6660e0, 8, 0, NULL, NULL) = -1 ECONNRESET (Connection reset by peer)
20878 shutdown(3, SHUT_RDWR) = -1 ENOTCONN (Transport endpoint is not connected)
20878 close(3) = 0
20878 write(2, "xset: unable to open display \"l"..., 47) = 47
20878 exit_group(1) = ?
20878 +++ exited with 1 +++
And here's a type -a xset:
$ type -a xset
below cmd output started 2019 Sun Jun 30 07:49:33 AM PDT
xset is /usr/bin/xset
Running without redirection, to show the order of the messages:
$ xset q
below cmd output started 2019 Sun Jun 30 08:03:24 AM PDT
connect /tmp/.X11-unix/X1: No such file or directory
xset: unable to open display "localhost:13.0"
In response to a comment from melpomene, I set up a test account with no startup files at all. I then ssh -Y'd to it, sudo'd, and got the same error message as described above.
I had been testing in gnome-terminal exclusively. I just tried konsole and again got the offending error message.
I just tried strace'ing the openssh client; it produced a single occurrence of the string "connect", which did not look relevant (other than connecting to the ssh server).
I had been testing exclusively on a Linux Mint 19.1 system. I just tried it on a freshly-installed Debian 9.9 system, and got the same result.
Steps to replicate:
ssh -Y remote.host.example.com
sudo bash
xset -q > /dev/null 2>&1
You may see the offending error message after these 3 simple steps.
This is pretty easy to understand and replicate, but there is a number of moving parts.
We ssh to a remote machine with X forwarding. This ssh process must have access to a working X server locally. Here we'll start it up with a joke $DISPLAY:
(local) $ DISPLAY=:87 ssh -Y remote
Warning: No xauth data; using fake authentication data for X11 forwarding
That Warning is an indication that ssh cannot contact a working X server locally.
On remote $DISPLAY is not :87
(remote) $ echo $DISPLAY
(remote) localhost:11.0
This is the magic that ssh's -Y does and how its X11 proxy works.
We run a command on remote that tries to connect to $DISPLAY:
(remote) $ xset -q
connect /tmp/.X11-unix/X99: No such file or directory
xset: unable to open display "localhost:11.0"
And here is your problem:
(remote) $ xset -q >/dev/null 2>&1
connect /tmp/.X11-unix/X99: No such file or directory
The unable error message was being printed by xset,
and has been redirected away.
However the connect error message is coming out of ssh.
Remember that xset runs on remote,
while ssh is running on local.
You need to validate $DISPLAY on local before running ssh.
You can quieten ssh in a number of ways,
but I'm not a fan of throwing away error messages.
One way would be to reduce the error verbosity:
(local) $ DISPLAY=:87 ssh -Y -o LogLevel=FATAL remote 'xset -q &>/dev/null'
See man ssh_config for a list of ssh settings.

Rapidly open 1,-1 data file as image

I'm working on a project that produces data files that are square matrices of numbers, either 1 or -1. I need to visualize this as images, and what I do now is using Matlab to open them, the matlab function imshow automatically draws those kind of matrices as monochrome black and white images.
Using matlab though is very slow and I was wondering if there was some linux program that I can fastly use from the terminal to do so, like an imagemagick oneliner or something similar.
This is an example of file
-1 1 -1 -1 1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 1 1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1
And this would be the image
The actual matrices would be of the order of 128x128.
Thank you!
It is trivial to convert your data to "PBM" format, even with a text editor,as I've done here. Change all of the " 1" to "0", "-1" to "1", and add a one-line header "P1 8 8 1" (substitute the actual width and height for "8 8"). Here's a one-line script matrix2pbm that does that:
echo P1 $2 $3 1; sed -e "s/-1/z/g; s/1/0/g; s/z/1/g" $1
Run it with
./matrix2pbm matrix.txt 8 8 > matrix.pbm
cat matrix.pbm
P1 8 8 1
1 0 1 1 0 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 0 0 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
The PBM format is one of the Netpbm image formats [http://en.wikipedia.org/wiki/Netpbm_format]
If you like, you can then use ImageMagick or some other file converter to convert the result into some other format:
convert matrix.pbm matrix.png
As emcconville commented, you can do both transformations with this one-liner:
./matrix2pbm matrix.txt 8 8 | convert pbm:- matrix.png

cuda-memcheck: Could not start the application (14)

I'm trying to use cuda-memcheck to debug my application. Ubuntu 12.04, GeForce GTX 680 / K20c, CUDA 6.5.
Trivial example, trivial.cu:
#include <stdio.h>
__global__ void foo()
{
}
int main()
{
foo<<<1,1>>>();
printf("CUDA error: %s\n", cudaGetErrorString(cudaGetLastError()));
return 0;
}
I compiled it via nvcc trivial.cu -o trivial.bin. Running ./trivial.bin directly works fine now. It prints the output:
CUDA error: no error
Now I'm calling it via cuda-memcheck ./trivial.bin. COMPUTE_PROFILE, CUDA_PROFILE, CUDA_INJECTION32_DLL and CUDA_INJECTION64_DLL are all unset. I have write access to /tmp. $TMPDIR = /var/tmp/625352.1.16C-32G-GPU-K20, and I can also write to $TMPDIR.
I'm getting this output:
========= CUDA-MEMCHECK
========= Could not start the application (14)
========= No CUDA-MEMCHECK results found
(It might be SGE related. I'm getting this error only in a non-interactive SGE job.)
I can now reproduce the error in an interactive shell via:
mkdir /var/tmp/625352.1.16C-32G-GPU-K20
export TMPDIR=/var/tmp/625352.1.16C-32G-GPU-K20
cuda-memcheck ./trivial.bin
So it somehow gets confused with this $TMPDIR. This seems like an internal bug in cuda-memcheck.
It seems to happen if the length of $TMPDIR is greater or equal than 30 chars.
I have not found a single result on Google about this error, nor in the documentation.
What is the problem? How can I fix the problem? How can I find out what the error means? What does the error code (14) mean? (And where could I ask?)
strace output:
+ strace cuda-memcheck ./trivial.bin
execve("/usr/local/cuda-6.5/bin/cuda-memcheck", ["cuda-memcheck", "./trivial.bin"], [/* 122 vars */]) = 0
brk(0) = 0x1af8000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b430d6f1000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("tls/x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("tls/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/tls/x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/tls/x86_64", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/tls/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/tls", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/x86_64", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
open("/usr/local/cuda-6.0/lib64/tls/x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-6.0/lib64/tls/x86_64", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.0/lib64/tls/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-6.0/lib64/tls", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.0/lib64/x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-6.0/lib64/x86_64", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.0/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-6.0/lib64", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/usr/lib/atlas-base/tls/x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/atlas-base/tls/x86_64", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/lib/atlas-base/tls/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/atlas-base/tls", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/lib/atlas-base/x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/atlas-base/x86_64", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/lib/atlas-base/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/atlas-base", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/usr/local/cuda-6.5/lib64/tls/x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-6.5/lib64/tls/x86_64", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.5/lib64/tls/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-6.5/lib64/tls", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.5/lib64/x86_64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-6.5/lib64/x86_64", 0x7fff1cb31520) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.5/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/cuda-6.5/lib64", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=115443, ...}) = 0
mmap(NULL, 115443, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2b430d720000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\r\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=14768, ...}) = 0
mmap(NULL, 2109704, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b430d920000
mprotect(0x2b430d922000, 2097152, PROT_NONE) = 0
mmap(0x2b430db22000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x2b430db22000
close(3) = 0
open("tls/x86_64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("tls/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("x86_64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.0/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/atlas-base/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.5/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200l\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=135366, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b430d6f3000
mmap(NULL, 2212904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b430db28000
mprotect(0x2b430db40000, 2093056, PROT_NONE) = 0
mmap(0x2b430dd3f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x2b430dd3f000
mmap(0x2b430dd41000, 13352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2b430dd41000
close(3) = 0
open("tls/x86_64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("tls/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("x86_64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.0/lib64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/atlas-base/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.5/lib64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340!\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=31752, ...}) = 0
mmap(NULL, 2128984, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b430dd48000
mprotect(0x2b430dd4f000, 2093056, PROT_NONE) = 0
mmap(0x2b430df4e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x2b430df4e000
close(3) = 0
open("tls/x86_64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("tls/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("x86_64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.0/lib64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/atlas-base/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.5/lib64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\241\5\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=962656, ...}) = 0
mmap(NULL, 3142544, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b430df50000
mprotect(0x2b430e032000, 2093056, PROT_NONE) = 0
mmap(0x2b430e231000, 40960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe1000) = 0x2b430e231000
mmap(0x2b430e23b000, 82832, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2b430e23b000
close(3) = 0
open("tls/x86_64/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("tls/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("x86_64/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.0/lib64/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/atlas-base/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.5/lib64/libm.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0pU\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1030512, ...}) = 0
mmap(NULL, 3125544, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b430e250000
mprotect(0x2b430e34b000, 2093056, PROT_NONE) = 0
mmap(0x2b430e54a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xfa000) = 0x2b430e54a000
close(3) = 0
open("tls/x86_64/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("tls/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("x86_64/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.0/lib64/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/atlas-base/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.5/lib64/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320(\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=88384, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b430d6f4000
mmap(NULL, 2184216, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b430e550000
mprotect(0x2b430e565000, 2093056, PROT_NONE) = 0
mmap(0x2b430e764000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0x2b430e764000
close(3) = 0
open("tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.0/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/atlas-base/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/cuda-6.5/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\30\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1815224, ...}) = 0
mmap(NULL, 3929304, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b430e768000
mprotect(0x2b430e91d000, 2097152, PROT_NONE) = 0
mmap(0x2b430eb1d000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b5000) = 0x2b430eb1d000
mmap(0x2b430eb23000, 17624, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2b430eb23000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b430d6f5000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b430d6f6000
arch_prctl(ARCH_SET_FS, 0x2b430d6f6340) = 0
mprotect(0x2b430eb1d000, 16384, PROT_READ) = 0
mprotect(0x2b430e764000, 4096, PROT_READ) = 0
mprotect(0x2b430e54a000, 4096, PROT_READ) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b430d71a000
mprotect(0x2b430e231000, 32768, PROT_READ) = 0
mprotect(0x2b430dd3f000, 4096, PROT_READ) = 0
mprotect(0x2b430df4e000, 4096, PROT_READ) = 0
mprotect(0x2b430db22000, 4096, PROT_READ) = 0
mprotect(0x2b430d91a000, 4096, PROT_READ) = 0
munmap(0x2b430d720000, 115443) = 0
set_tid_address(0x2b430d6f6610) = 2023
set_robust_list(0x2b430d6f6620, 0x18) = 0
futex(0x7fff1cb31e1c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, 2b430d6f6340) = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGRTMIN, {0x2b430db2e750, [], SA_RESTORER|SA_SIGINFO, 0x2b430db37cb0}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x2b430db2e7e0, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x2b430db37cb0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=RLIM_INFINITY, rlim_max=RLIM_INFINITY}) = 0
futex(0x2b430e23bed0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
brk(0) = 0x1af8000
brk(0x1b19000) = 0x1b19000
fstat(1, {st_mode=S_IFREG|0644, st_size=28120, ...}) = 0
mmap(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b430d71b000
statfs("/dev/shm/", {f_type=0x1021994, f_bsize=4096, f_blocks=4116014, f_bfree=4116014, f_bavail=4116014, f_files=4116014, f_ffree=4116011, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0
futex(0x2b430df4f360, FUTEX_WAKE_PRIVATE, 2147483647) = 0
open("/dev/shm/2023", O_RDWR|O_NOFOLLOW|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/dev/shm/2023", O_RDWR|O_NOFOLLOW|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/dev/shm/2023", O_RDWR|O_CREAT|O_EXCL|O_TRUNC|O_NOFOLLOW|O_CLOEXEC, 0600) = 3
ftruncate(3, 262176) = 0
mmap(NULL, 262176, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x2b430d820000
open("/dev/shm/2023", O_RDWR|O_NOFOLLOW|O_CLOEXEC) = 4
lseek(4, 0, SEEK_END) = 262176
mmap(NULL, 262176, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0) = 0x2b430d868000
write(1, "========= CUDA-MEMCHECK\n========"..., 112========= CUDA-MEMCHECK
========= Could not start the application (14)
========= No CUDA-MEMCHECK results found
) = 112
exit_group(0) = ?
This seems like an internal bug in cuda-memcheck. It seems to happen if the length of $TMPDIR is greater or equal than 30 chars. I guess their internal buffer for storing the temp filename is too short.
As a workaround, I now do:
ln -s $TMPDIR /tmp/cuda-$PPID
export TMPDIR=/tmp/cuda-$PPID

Resources