From: adirtymindisajoyforever on
hi,

in an attempt to reduce the number of probes I tried
the following test program:

/* single_thread.c */

#include <stdio.h>
#include <pthread.h>


pthread_mutex_t mutex1;

main()
{
pthread_mutex_lock(&mutex1);
pthread_mutex_unlock(&mutex1);
}

/* dtracetest.d */

dtrace:::BEGIN {
}


pid$pid::*mutex_lock:entry
{
}

pid$pid::*mutex_lock:return
{
}

pid$pid::*mutex_unlock:entry
{
}

proc:::exit
/pid == $pid/
{
exit(0);
}


# dtrace -s dtracetest.d -c ./single_thread

dtrace: script 'dtracetest.d' matched 23 probes
CPU ID FUNCTION:NAME
2 1 :BEGIN
2 41174 rt_mutex_lock:entry
2 41176 _lwp_mutex_lock:entry
2 41182 _lwp_mutex_lock:return
2 41180 rt_mutex_lock:return
2 41186 rt_mutex_unlock:entry
2 41189 _lwp_mutex_unlock:entry
2 41178 mutex_lock:entry
2 41184 mutex_lock:return
2 41190 mutex_unlock:entry
2 41174 rt_mutex_lock:entry
2 41176 _lwp_mutex_lock:entry
2 41182 _lwp_mutex_lock:return
2 41180 rt_mutex_lock:return
2 41186 rt_mutex_unlock:entry
2 41189 _lwp_mutex_unlock:entry
2 41174 rt_mutex_lock:entry
2 41176 _lwp_mutex_lock:entry
2 41182 _lwp_mutex_lock:return
2 41180 rt_mutex_lock:return
2 41186 rt_mutex_unlock:entry
2 41189 _lwp_mutex_unlock:entry
2 41174 rt_mutex_lock:entry
2 41176 _lwp_mutex_lock:entry
2 41182 _lwp_mutex_lock:return
2 41180 rt_mutex_lock:return
2 41186 rt_mutex_unlock:entry
2 41189 _lwp_mutex_unlock:entry
2 41179 lmutex_lock:entry
2 41185 lmutex_lock:return
2 41191 lmutex_unlock:entry
2 41179 lmutex_lock:entry
2 41185 lmutex_lock:return
2 41191 lmutex_unlock:entry
2 41179 lmutex_lock:entry
Segmentation Fault(coredump)

# pstack /var/core/core_localhost_dtrace_0_0_1252062179_17932

core '/var/core/core_localhost_dtrace_0_0_1252062179_17932' of
17932: dtrace -s dtracetest.d -c ./single_thread
----------------- lwp# 1 / thread# 1 --------------------
fffffd7fff1fe5cf abstime_to_reltime () + 1f
fffffd7fff209ff4 pthread_mutex_timedlock () + 24
fffffd7fff1f5cba _flockget () + 1a
fffffd7fff1ec475 vfprintf () + e5
0000000000403374 oprintf () + b4
0000000000405107 chew () + 147
fffffd7fff335e7b dt_consume_cpu () + 19b
fffffd7fff336962 dt_consume_begin () + 92
fffffd7fff336d54 dtrace_consume () + 114
fffffd7fff35db9a dtrace_work () + aa
0000000000405f92 main () + 902
0000000000402d7c _start () + 6c
----------------- lwp# 2 / thread# 2 --------------------
fffffd7fff21467a _write () + a
fffffd7fff2c24bf execute_bkpt () + 17f
fffffd7fff2c256f Pxecbkpt () + 5f
fffffd7fff3577fd dt_proc_bpmatch () + dd
fffffd7fff358569 dt_proc_control () + 4b9
fffffd7fff210edb _thr_setup () + 5b
fffffd7fff211110 _lwp_start ()

putting "#pragma D option quiet"
in the dtrace script makes it indeed quit, no core.