folly::coro::timeoutNoDiscard
[hiphop-php.git] / hphp / hhvm / thread_locals_test.sh
blobf701817036d3a14005b39ad21beaace866a4cdc4
1 #!/bin/bash
3 # Test input arguments:
4 # $1 is path to the HHVM binary.
5 # $2 is the path to thread_locals.txt.
7 # We use `nm` to list symbols, filter to thread locals in the HPHP:: namespace,
8 # use cut to select just the name, then strip trailing whitespace and ABI tags.
9 ALL=$( \
10 nm --demangle --format sysv "$1" \
11 | grep 'HPHP::' \
12 | grep -v 'HPHP::HHBBC::' \
13 | grep '\(\.tbss\|\.tdata\)' \
14 | cut --delimiter '|' --field 1 \
15 | sed -e 's/ *$//' \
16 | sed -e 's/\[abi:[^]]*\]$//' \
19 # Remove bash-style comments from the whitelist file.
20 WHITELIST=$(sed -e 's/ *#.*//' "$2")
22 # comm -23 returns lines in the first input that are not in the second.
23 # We need -u becaues a symbol may appear multiple times with different ABI tags.
24 EXTRA=$(comm -23 <(echo "$ALL" | sort -u) <(echo "$WHITELIST" | sort -u))
26 if [ "$EXTRA" ]; then
27 echo -e "
28 --------------------------------------------------------------------------------
29 \\e[0;31mERROR: New thread locals detected.\\e[0m
30 Per-request memory should be allocated using RDS locals to allow for
31 userland scheduling. New thread locals indicate a potential logic error.
32 If these thread locals are necessary, add them to thread_locals.txt:
34 $EXTRA
35 --------------------------------------------------------------------------------
37 exit 1