strace -f -c segfaults if I pthread_create and fcntl(F_GETFL)

D Wang dwang at janestreet.com
Thu Jul 17 23:11:09 UTC 2014


(Please copy dwang at janestreet.com on reply, as I am not subscribed to the list.)

I'd like to strace a multi-threaded program which calls fcntl
sometimes, but the combination of threads and fcntl causes strace to
segfault.

Here's a small reproduction:

    cd /tmp
    cat > foo.c <<'EOF'
    #include <fcntl.h>
    #include <unistd.h>
    #include <pthread.h>

    void * thread_start(void * unused) {
      sleep(1);
    }

    int main (int argc, char **argv) {
      pthread_t thread;

      /* ordering of these two lines does not matter */
      fcntl(1, F_GETFD, 0);
      pthread_create(&thread, NULL, thread_start, NULL);

      return 0;
    }
    EOF
    gcc -l pthread foo.c
    strace -f -c ./a.out

Looks like omitting any one of -f, or -c, or the pthread_create, or
the fcntl is enough to avoid the segfault, but unfortunately I need
all four of them.

What's going wrong?  Is there any workaround?  If not, is this
something you would fix?  (No urgency on my end, but I think this is a
reasonable thing to support eventually.)

Thanks for writing strace.

Wang

Random system info, not sure what would be helpful to you:

$ strace -V
strace -- version 4.5.19
$ uname -a
Linux tot-qws-u12112a 2.6.32-431.1.2.0.1.el6.x86_64 #1 SMP Fri Dec 13
13:06:13 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
$ rpm -q --whatprovides /usr/lib64/libpthread.so
glibc-devel-2.12-1.132.el6.x86_64
$ rpm -q --whatprovides /usr/include/fcntl.h
glibc-headers-2.12-1.132.el6.x86_64




More information about the Strace-devel mailing list