Address TSAN error between dns_rbt_findnode() and subtractrdataset().

Having dns_rbt_findnode() in previous_closest_nsec() check of
node->data is a optimisation that triggers a TSAN error with
subtractrdataset().  find_closest_nsec() still needs to check if
the NSEC record are active or not and look for a earlier NSEC records
if it isn't.  Set DNS_RBTFIND_EMPTYDATA so node->data isn't referenced
without the node lock being held.

    WARNING: ThreadSanitizer: data race
    Read of size 8 at 0x000000000001 by thread T1 (mutexes: read M1, read M2):
    #0 dns_rbt_findnode lib/dns/rbt.c:1708
    #1 previous_closest_nsec lib/dns/rbtdb.c:3760
    #2 find_closest_nsec lib/dns/rbtdb.c:3942
    #3 zone_find lib/dns/rbtdb.c:4091
    #4 dns_db_findext lib/dns/db.c:536
    #5 query_lookup lib/ns/query.c:5582
    #6 ns__query_start lib/ns/query.c:5505
    #7 query_setup lib/ns/query.c:5229
    #8 ns_query_start lib/ns/query.c:11380
    #9 ns__client_request lib/ns/client.c:2166
    #10 processbuffer netmgr/tcpdns.c:230
    #11 dnslisten_readcb netmgr/tcpdns.c:309
    #12 read_cb netmgr/tcp.c:832
    #13 <null> <null>
    #14 <null> <null>

    Previous write of size 8 at 0x000000000001 by thread T2 (mutexes: write M3):
    #0 subtractrdataset lib/dns/rbtdb.c:7133
    #1 dns_db_subtractrdataset lib/dns/db.c:742
    #2 diff_apply lib/dns/diff.c:368
    #3 dns_diff_apply lib/dns/diff.c:459
    #4 do_one_tuple lib/dns/update.c:247
    #5 update_one_rr lib/dns/update.c:275
    #6 delete_if_action lib/dns/update.c:689
    #7 foreach_rr lib/dns/update.c:471
    #8 delete_if lib/dns/update.c:716
    #9 dns_update_signaturesinc lib/dns/update.c:1948
    #10 receive_secure_serial lib/dns/zone.c:15637
    #11 dispatch lib/isc/task.c:1152
    #12 run lib/isc/task.c:1344
    #13 <null> <null>

    Location is heap block of size 130 at 0x000000000028 allocated by thread T3:
    #0 malloc <null>
    #1 default_memalloc lib/isc/mem.c:713
    #2 mem_get lib/isc/mem.c:622
    #3 mem_allocateunlocked lib/isc/mem.c:1268
    #4 isc___mem_allocate lib/isc/mem.c:1288
    #5 isc__mem_allocate lib/isc/mem.c:2453
    #6 isc___mem_get lib/isc/mem.c:1037
    #7 isc__mem_get lib/isc/mem.c:2432
    #8 create_node lib/dns/rbt.c:2239
    #9 dns_rbt_addnode lib/dns/rbt.c:1202
    #10 dns_rbtdb_create lib/dns/rbtdb.c:8668
    #11 dns_db_create lib/dns/db.c:118
    #12 receive_secure_db lib/dns/zone.c:16154
    #13 dispatch lib/isc/task.c:1152
    #14 run lib/isc/task.c:1344
    #15 <null> <null>

    Mutex M1 (0x000000000040) created at:
    #0 pthread_rwlock_init <null>
    #1 isc_rwlock_init lib/isc/rwlock.c:39
    #2 dns_rbtdb_create lib/dns/rbtdb.c:8527
    #3 dns_db_create lib/dns/db.c:118
    #4 receive_secure_db lib/dns/zone.c:16154
    #5 dispatch lib/isc/task.c:1152
    #6 run lib/isc/task.c:1344
    #7 <null> <null>

    Mutex M2 (0x000000000044) created at:
    #0 pthread_rwlock_init <null>
    #1 isc_rwlock_init lib/isc/rwlock.c:39
    #2 dns_rbtdb_create lib/dns/rbtdb.c:8600
    #3 dns_db_create lib/dns/db.c:118
    #4 receive_secure_db lib/dns/zone.c:16154
    #5 dispatch lib/isc/task.c:1152
    #6 run lib/isc/task.c:1344
    #7 <null> <null>

    Mutex M3 (0x000000000046) created at:
    #0 pthread_rwlock_init <null>
    #1 isc_rwlock_init lib/isc/rwlock.c:39
    #2 dns_rbtdb_create lib/dns/rbtdb.c:8600
    #3 dns_db_create lib/dns/db.c:118
    #4 receive_secure_db lib/dns/zone.c:16154
    #5 dispatch lib/isc/task.c:1152
    #6 run lib/isc/task.c:1344
    #7 <null> <null>

    Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create pthreads/thread.c:73
    #2 isc_nm_start netmgr/netmgr.c:232
    #3 create_managers bin/named/main.c:909
    #4 setup bin/named/main.c:1223
    #5 main bin/named/main.c:1523

    Thread T2 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create pthreads/thread.c:73
    #2 isc_taskmgr_create lib/isc/task.c:1434
    #3 create_managers bin/named/main.c:915
    #4 setup bin/named/main.c:1223
    #5 main bin/named/main.c:1523

    Thread T3 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create pthreads/thread.c:73
    #2 isc_taskmgr_create lib/isc/task.c:1434
    #3 create_managers bin/named/main.c:915
    #4 setup bin/named/main.c:1223
    #5 main bin/named/main.c:1523

    SUMMARY: ThreadSanitizer: data race lib/dns/rbt.c:1708 in dns_rbt_findnode
76 jobs for !4259 with 2211-tsan-error-previous_closest_nsec-dns_rbt_findnode-vs-subtractrdataset in 17 minutes and 1 second (queued for 8 seconds)
detached
Status Job ID Name Coverage
  Autoconf
passed #1289213
amd64 linux
autoreconf

00:00:18

 
  Precheck
passed #1289215
amd64 linux
clang-format

00:00:17

passed #1289216
amd64 linux
coccinelle

00:03:38

passed #1289217
amd64 linux
danger

00:00:14

passed #1289214
amd64 linux
misc

00:00:16

passed #1289218
amd64 linux
tarball-create

00:01:36

 
  Build
passed #1289231
amd64 linux
clang:asan

00:01:54

passed #1289235
amd64 linux
clang:buster:amd64

00:01:08

passed #1289238
amd64 libvirt
clang:freebsd11:amd64

00:01:11

passed #1289239
amd64 libvirt
clang:freebsd12:amd64

00:01:08

passed #1289240
amd64 libvirt
clang:openbsd:amd64

00:02:54

passed #1289233
amd64 linux
clang:tsan

00:01:13

passed #1289219
amd64 linux
gcc:alpine3.12:amd64

00:01:01

passed #1289230
amd64 linux
gcc:asan

00:01:42

passed #1289223
amd64 linux
gcc:buster:amd64

00:00:59

passed #1289220
amd64 linux
gcc:centos7:amd64

00:00:55

passed #1289221
amd64 linux
gcc:centos8:amd64

00:00:58

passed #1289229
amd64 linux
gcc:focal:amd64

00:00:53

passed #1289234
amd64 linux
gcc:mutexatomics

00:01:05

passed #1289225
amd64 linux
gcc:out-of-tree

00:01:04

passed #1289224
amd64 linux
gcc:sid:amd64

00:01:10

passed #1289226
i386 linux
gcc:sid:i386

00:00:48

passed #1289236
amd64 linux
gcc:softhsm2.4

00:00:49

passed #1289237
amd64 linux
gcc:softhsm2.6

00:00:48

passed #1289222
amd64 linux
gcc:stretch:amd64

00:00:58

passed #1289232
amd64 linux
gcc:tsan

00:01:01

passed #1289227
amd64 linux
gcc:tumbleweed:amd64

00:00:53

passed #1289228
amd64 linux
gcc:xenial:amd64

00:01:05

failed #1289241
amd64 windows
msvc:windows:amd64

00:00:22

 
  Unit
passed #1289253
amd64 linux
unit:clang:asan

00:01:16

passed #1289257
amd64 linux
unit:clang:buster:amd64

00:01:02

passed #1289260
amd64 libvirt
unit:clang:freebsd11:amd64

00:01:32

passed #1289261
amd64 libvirt
unit:clang:freebsd12:amd64

00:01:21

passed #1289262
amd64 libvirt
unit:clang:openbsd:amd64

00:02:34

passed #1289255
amd64 linux
unit:clang:tsan

00:03:13

passed #1289242
amd64 linux
unit:gcc:alpine3.12:amd64

00:01:00

passed #1289252
amd64 linux
unit:gcc:asan

00:01:22

passed #1289246
amd64 linux
unit:gcc:buster:amd64

00:02:04

passed #1289243
amd64 linux
unit:gcc:centos7:amd64

00:01:02

passed #1289244
amd64 linux
unit:gcc:centos8:amd64

00:01:00

passed #1289251
amd64 linux
unit:gcc:focal:amd64

00:01:03

passed #1289256
amd64 linux
unit:gcc:mutexatomics

00:01:00

passed #1289247
amd64 linux
unit:gcc:sid:amd64

00:01:02

passed #1289248
i386 linux
unit:gcc:sid:i386

00:01:05

passed #1289258
amd64 linux
unit:gcc:softhsm2.4

00:01:05

passed #1289259
amd64 linux
unit:gcc:softhsm2.6

00:01:01

passed #1289245
amd64 linux
unit:gcc:stretch:amd64

00:01:01

passed #1289254
amd64 linux
unit:gcc:tsan

00:03:47

passed #1289249
amd64 linux
unit:gcc:tumbleweed:amd64

00:01:01

passed #1289250
amd64 linux
unit:gcc:xenial:amd64

00:01:03

 
  System
passed #1289274
amd64 linux
system:clang:asan

00:12:48

passed #1289278
amd64 linux
system:clang:buster:amd64

00:11:40

passed #1289281
amd64 libvirt
system:clang:freebsd11:amd64

00:11:05

passed #1289282
amd64 libvirt
system:clang:freebsd12:amd64

00:10:49

passed #1289276
amd64 linux
system:clang:tsan

00:14:36

passed #1289263
amd64 linux
system:gcc:alpine3.12:amd64

00:12:21

passed #1289273
amd64 linux
system:gcc:asan

00:13:05

passed #1289267
amd64 linux
system:gcc:buster:amd64

00:12:40

passed #1289264
amd64 linux
system:gcc:centos7:amd64

00:11:30

passed #1289265
amd64 linux
system:gcc:centos8:amd64

00:11:57

passed #1289272
amd64 linux
system:gcc:focal:amd64

00:12:00

failed #1289277
amd64 linux
system:gcc:mutexatomics

00:11:14

passed #1289268
amd64 linux
system:gcc:sid:amd64

00:10:57

passed #1289269
i386 linux
system:gcc:sid:i386

00:12:02

passed #1289279
amd64 linux
system:gcc:softhsm2.4

00:11:45

passed #1289280
amd64 linux
system:gcc:softhsm2.6

00:11:34

passed #1289266
amd64 linux
system:gcc:stretch:amd64

00:11:20

passed #1289275
amd64 linux
system:gcc:tsan

00:15:03

passed #1289270
amd64 linux
system:gcc:tumbleweed:amd64

00:11:57

passed #1289271
amd64 linux
system:gcc:xenial:amd64

00:10:20

 
  Docs
passed #1289283
amd64 linux
docs

00:00:48

 
  Postcheck
passed #1289287
amd64 linux
cppcheck

00:00:43

passed #1289284
amd64 linux
flake8

00:00:21

passed #1289288
amd64 linux
gcov

00:00:33

77.0%
passed #1289285
amd64 linux
pylint

00:00:24

passed #1289286
amd64 linux
scan-build

00:04:03

 
Name Stage Failure
failed
system:gcc:mutexatomics System
FAIL kasp (exit status: 1)

$ test -n "${OUT_OF_TREE_WORKSPACE}" && mv "${OUT_OF_TREE_WORKSPACE}" "${CI_PROJECT_DIR}"
Uploading artifacts for failed job
Uploading artifacts...
untracked: found 4504 files

Uploading artifacts as "archive" to coordinator... ok
id=1289277 responseStatus=201 Created token=CryW8-r5
Cleaning up file based variables
ERROR: Job failed: exit code 1
failed
msvc:windows:amd64 Build
OS/Arch:      windows/amd64
Uploading artifacts...
Runtime platform
arch=amd64 os=windows pid=17136 revision=ece86343 version=13.5.0
untracked: found 97 files

WARNING: Failed to load system CertPool: crypto/x509: system root pool is not available on Windows
Uploading artifacts as "archive" to coordinator... ok
id=1289241 responseStatus=201 Created token=cC8sC_Bg
Cleaning up file based variables
Unsupported run stage "cleanup_file_variables"
ERROR: Job failed: exit status 1