From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29011 invoked by alias); 6 Apr 2011 06:05:36 -0000 Received: (qmail 29000 invoked by uid 22791); 6 Apr 2011 06:05:34 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO sourceware.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Apr 2011 06:05:30 +0000 From: "raysonlogin at gmail dot com" To: systemtap@sourceware.org Subject: [Bug runtime/12642] New: utrace: taskfinder misses events when main thread does not go through at least one quiesce X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: systemtap X-Bugzilla-Component: runtime X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: raysonlogin at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: systemtap at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 06 Apr 2011 06:05:00 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2011-q2/txt/msg00052.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=12642 Summary: utrace: taskfinder misses events when main thread does not go through at least one quiesce Product: systemtap Version: unspecified Status: NEW Severity: normal Priority: P2 Component: runtime AssignedTo: systemtap@sourceware.org ReportedBy: raysonlogin@gmail.com If a multi-threaded program with the main thread not going through at least one quiesce after systemtap/uprobes tracing starts, then Systemtap is not able to detect the events. Example: #include #include void spool_write_script(int jobid) __attribute__ ((noinline)); void spool_write_script(int jobid) { printf("sleeping... %d sec\n", 1 + jobid % 2); sleep(2 + jobid % 2); } mythread() { int i; for (i=0;i<30;i++) spool_write_script(i); } int main() { pthread_t tid; printf("pid = %d\n", getpid()); #ifdef MAINWAITS getchar(); #endif pthread_create(&tid, NULL, mythread, NULL); pthread_join(tid, NULL); } Reproduce with: stap hangs when the process is traced with: # stap -e 'probe process("./a.out").function("spool_write_script") {printf("called")}' -x However, when the testcase is compiled with -DMAINWAITS, and when stap is started before inputing a key (getchar()), then stap is able to get the events. (Also, starting the program with -c would make it work.) Analysis: In the systemtap runtime, __stp_utrace_task_finder_target_quiesce() checks if it is encountering the main thread: /* Call the callbacks. Assume that if the thread is a * thread group leader, it is a process. */ __stp_call_callbacks(tgt, tsk, 1, (tsk->pid == tsk->tgid)); For slave threads, tsk->pid == tsk->tgid is false, and the callback function in uprobes only handles the main thread, as the address space is shared by all the threads. In stap_uprobe_process_found(): if (! process_p) return 0; /* ignore threads */ And thus stap_uprobe_change_plus() is not called for the threads. (As a hack) Simply passing 1 instead of (tsk->pid == tsk->tgid) would make it work for the testcase above. Severity: Normal - The testcase is from a real application (daemon) that creates slave threads, and the main thread waits until clean-up time (ie. daemon restart, exit, etc...). A workaround is to force the main thread to quiesce after stap runs, e.g. by attaching gdb. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.