diff --git a/contrib/Makefile b/contrib/Makefile index b3d563e1a..a96c78cd5 100644 --- a/contrib/Makefile +++ b/contrib/Makefile @@ -95,6 +95,8 @@ build/pcre2/libpcre2-posix.a build/pcre2/libpcre2-8.a: @$(RM) -r build/pcre2 @mkdir build/pcre2 cd build/pcre2 && cmake ../../pcre2 && $(MAKE) +# the pcre2 cmake constants (eg. PCRE2_...) are defined in CMakeLists.txt +# cd build/pcre2 && cmake -DPCRE2_MATCH_LIMIT=500000 -DPCRE2_HEAP_LIMIT=500 -DPCRE2_MATCH_LIMIT_DEPTH=10000 -DPCRE2GREP_SUPPORT_JIT=OFF ../../pcre2 && $(MAKE) objcopy --redefine-syms redefine_syms.lst build/pcre2/libpcre2-posix.a objcopy --redefine-syms redefine_syms.lst build/pcre2/libpcre2-8.a @[ -z "$(CI)" ] || echo "::endgroup::" diff --git a/src/com.c b/src/com.c index df7c5ad44..0d4ca6602 100644 --- a/src/com.c +++ b/src/com.c @@ -334,9 +334,9 @@ get_stack(void) // We got a spot, but our malloc failed. Put the spot back // into the unused pool. Stop looping if this happens. - // grab_unused() guarantees that only one thread at a time - // can get here; so this doen't need to ba an atomic operation. - entry->used = FALSE; + if (!atomicCasU64(&entry->used, (uint64_t)TRUE, (uint64_t)FALSE)) { + scopeLogError("get_stack failed to set used to FALSE"); + } break; } } @@ -357,9 +357,10 @@ free_stack(char *addr) if (entry->addr == addr) { // Addr is in the pool. Don't free addr, but set used to false - // to allow reuse. Only one thread can use a stack entry at a - // time so an atomic operation is unnecessary here. - entry->used = FALSE; + // to allow reuse. + if (!atomicCasU64(&entry->used, (uint64_t)TRUE, (uint64_t)FALSE)) { + scopeLogError("free_stack failed to set used to FALSE"); + } return; } } diff --git a/test/integration/go/signals/signalHandler.go b/test/integration/go/signals/signalHandler.go index 1e1468829..ca4aaacca 100644 --- a/test/integration/go/signals/signalHandler.go +++ b/test/integration/go/signals/signalHandler.go @@ -27,6 +27,15 @@ func genOpenCloseLoop(f_name string) { } } +func genConsoleOutput() { + for i :=1; i < LoopLimit; i++ { + fmt.Printf(" %d ", i) + if i % 6 == 0 { + fmt.Println("") + } + } +} + func main() { sig_channel := make(chan os.Signal, 1) @@ -64,6 +73,10 @@ func main() { genOpenCloseLoop(tmpfile.Name()) }() + go func() { + genConsoleOutput(); + }() + <-quit_channel fmt.Println("Exiting") } diff --git a/test/integration/go/test_go.sh b/test/integration/go/test_go.sh index 3e06bdcc2..7845c2c2e 100755 --- a/test/integration/go/test_go.sh +++ b/test/integration/go/test_go.sh @@ -815,12 +815,13 @@ endtest # starttest signalHandlerStatic cd /go/signals -scope -z ./signalHandlerStatic 2>${ERR_FILE}& +scope -z ./signalHandlerStatic &>${ERR_FILE}& SCOPE_PID=$! ERR+=$? +sleep 0.1 -sleep 1 kill -SIGCHLD ${SCOPE_PID} +sleep 1 # verify that process still exists if ! ps -p ${SCOPE_PID}; then @@ -828,14 +829,22 @@ if ! ps -p ${SCOPE_PID}; then ERR+=1 fi +count=$(grep 'bad g' $ERR_FILE | wc -l) +if [ $count -ne 0 ] ; then + echo "$SCOPE_PID bad g seen in $ERR_FILE before sigkill" + cat $ERR_FILE + ERR+=1 +fi + while kill -0 ${SCOPE_PID}; do + echo "sending SIGKILL" kill -SIGKILL ${SCOPE_PID} sleep 1 done count=$(grep 'bad g' $ERR_FILE | wc -l) if [ $count -ne 0 ] ; then - echo "$SCOPE_PID bad g seen in $ERR_FILE" + echo "$SCOPE_PID bad g seen in $ERR_FILE after sigkill" cat $ERR_FILE ERR+=1 fi @@ -847,12 +856,13 @@ endtest # starttest signalHandlerStaticStripped cd /go/signals -scope -z ./signalHandlerStatic 2>${ERR_FILE}& +scope -z ./signalHandlerStaticStripped &>${ERR_FILE}& SCOPE_PID=$! ERR+=$? +sleep 0.1 -sleep 1 kill -SIGCHLD ${SCOPE_PID} +sleep 1 # verify that process still exists if ! ps -p ${SCOPE_PID}; then @@ -860,14 +870,22 @@ if ! ps -p ${SCOPE_PID}; then ERR+=1 fi +count=$(grep 'bad g' $ERR_FILE | wc -l) +if [ $count -ne 0 ] ; then + echo "$SCOPE_PID bad g seen in $ERR_FILE before sigkill" + cat $ERR_FILE + ERR+=1 +fi + while kill -0 ${SCOPE_PID}; do + echo "sending SIGKILL" kill -SIGKILL ${SCOPE_PID} sleep 1 done count=$(grep 'bad g' $ERR_FILE | wc -l) if [ $count -ne 0 ] ; then - echo "$SCOPE_PID bad g seen in $ERR_FILE" + echo "$SCOPE_PID bad g seen in $ERR_FILE after sigkill" cat $ERR_FILE ERR+=1 fi