2 # This file and its contents are supplied under the terms of the
3 # Common Development and Distribution License ("CDDL"), version 1.0.
4 # You may only use this file in accordance with the terms of version
7 # A full copy of the text of the CDDL should have accompanied this
8 # source. A copy of the CDDL is also available via the Internet at
9 # http://www.illumos.org/license/CDDL.
13 # Copyright (c) 2017, Joyent, Inc. All rights reserved.
17 # This test attempts to reproduce a three-way deadlock between mod_lock,
18 # dtrace_lock and P_PR_LOCK that is induced by shmsys having to go through
22 echo expected one argument
: '<'dtrace-path
'>'
40 print
-u2 "failed to generate header file"
47 #include <sys/types.h>
65 shmid = shmget(IPC_PRIVATE, sizeof (int), IPC_CREAT | 0666);
72 if ((addr = shmat(shmid, NULL, 0)) == (void *)-1) {
88 print
-u2 "failed to compile test.c"
92 $dtrace -G -32 -s prov.d
test.o
95 print
-u2 "failed to create DOF"
99 gcc
-m32 -o test test.o prov.o
101 if [ $?
-ne 0 ]; then
102 print
-u2 "failed to link final executable"
107 # Kick off the victim program.
114 # Kick off a shell that will do nothing but read our victim's /proc map
116 ( while true
; do read foo
< /proc
/$victim/map
; done ) &
120 # Kick off a shell that will do nothing but instrument (and de-instrument)
124 $dtrace -q -P test_prov
$victim -n BEGIN
'{exit(0)}' > /dev
/null
; done ) &
128 # Finally, kick off a shell that will cause lots of provider registration and
129 # (importantly) de-registration
131 ( while true
; do .
/test foo
; done) &
151 # If we're deadlocked, this DTrace enabling won't work (if we even make it this
152 # far, which seems unlikely). In the spirit of the deadlock, we denote our
153 # success by emiting a classic Faulknerism.
155 raf
="Maybe you're not so worthless!"
156 dtrace
-qn BEGIN
"{printf(\"$raf\"); exit(0)}"