Commit graph

30021 commits

Author SHA1 Message Date
Ondřej Surý
879c0f4cf6 Merge branch 'ondrej/fix-coccinelle-detected-issues' into 'master'
Various little fixes found by coccinelle

See merge request isc-projects/bind9!2325
2019-10-01 11:17:45 -04:00
Ondřej Surý
288f5a4b52 Various little fixes found by coccinelle
The coccinellery repository provides many little semantic patches to fix common
problems in the code.  The number of semantic patches in the coccinellery
repository is high and most of the semantic patches apply only for Linux, so it
doesn't make sense to run them on regular basis as the processing takes a lot of
time.

The list of issue found in BIND 9, by no means complete, includes:

- double assignment to a variable
- `continue` at the end of the loop
- double checks for `NULL`
- useless checks for `NULL` (cannot be `NULL`, because of earlier return)
- using `0` instead of `NULL`
- useless extra condition (`if (foo) return; if (!foo) { ...; }`)
- removing & in front of static functions passed as arguments
2019-10-01 16:48:55 +02:00
Ondřej Surý
c2e8a111f5 Merge branch 'ondrej/fix-gitlab-ci-for-master-branch-v2' into 'master'
Fix the triggering rule for autoreconf job (take 2)

See merge request isc-projects/bind9!2424
2019-10-01 10:43:56 -04:00
Ondřej Surý
afa6d88e21 Fix the triggering rule for autoreconf job (take 2) 2019-10-01 16:42:33 +02:00
Ondřej Surý
7b33f048b0 Merge branch 'ondrej/fix-gitlab-ci-for-master-branch' into 'master'
Fix docs -> autoreconf dependencies in the .gitlab-ci.yml

See merge request isc-projects/bind9!2423
2019-10-01 10:32:27 -04:00
Ondřej Surý
978476934c Fix docs -> autoreconf dependencies in the .gitlab-ci.yml 2019-10-01 16:29:33 +02:00
Ondřej Surý
7b554b0e46 Merge branch 'ondrej/use-%zu-for-sizeof-formatting' into 'master'
lib/dns/ssu_external.c: Use %zu for formatting sizeof() output

See merge request isc-projects/bind9!2415
2019-10-01 10:25:22 -04:00
Ondřej Surý
395741f9ad lib/dns/ssu_external.c: Use %zu for formatting sizeof() output 2019-10-01 16:24:29 +02:00
Mark Andrews
e7f0a252a1 Merge branch 'marka-placeholder' into 'master'
placeholder

See merge request isc-projects/bind9!2422
2019-10-01 09:12:09 -04:00
Mark Andrews
738e4cb0fe placeholder 2019-10-01 22:56:53 +10:00
Mark Andrews
cca33260f2 Merge branch 'marka-remove-unused-variable' into 'master'
remove unused variable

See merge request isc-projects/bind9!2418
2019-09-30 23:11:52 -04:00
Mark Andrews
dfcc9e18cb remove unused variable 2019-10-01 12:47:26 +10:00
Mark Andrews
066e860f8f Merge branch 'marka-missing-runtime-check' into 'master'
missing RUNTIME_CHECK

See merge request isc-projects/bind9!2265
2019-09-30 21:10:28 -04:00
Mark Andrews
346624fe38 add CHANGES 2019-10-01 10:44:06 +10:00
Ondřej Surý
69ecc711ac Move the failure handling block closer to the only place where it could fail 2019-10-01 10:43:26 +10:00
Ondřej Surý
c2dad0dcb2 Replace RUNTIME_CHECK(dns_name_copy(..., NULL)) with dns_name_copynf()
Use the semantic patch from the previous commit to replace all the calls to
dns_name_copy() with NULL as third argument with dns_name_copynf().
2019-10-01 10:43:26 +10:00
Ondřej Surý
ac26ecf540 Add semantic patch to replace RUNTIME_CHECK(dns_name_copy(..., NULL)) with dns_name_copynf 2019-10-01 10:43:26 +10:00
Ondřej Surý
f7aef3738a Split dns_name_copy() into dns_name_copy() and dns_name_copynf()
The dns_name_copy() function followed two different semanitcs that was driven
whether the last argument was or wasn't NULL.  This commit splits the function
in two where now third argument to dns_name_copy() can't be NULL and
dns_name_copynf() doesn't have third argument.
2019-10-01 10:43:26 +10:00
Ondřej Surý
5efa29e03a The final round of adding RUNTIME_CHECK() around dns_name_copy() calls
This commit was done by hand to add the RUNTIME_CHECK() around stray
dns_name_copy() calls with NULL as third argument.  This covers the edge cases
that doesn't make sense to write a semantic patch since the usage pattern was
unique or almost unique.
2019-10-01 10:43:26 +10:00
Ondřej Surý
89b269b0d2 Add RUNTIME_CHECK() around result = dns_name_copy(..., NULL) calls
This second commit uses second semantic patch to replace the calls to
dns_name_copy() with NULL as third argument where the result was stored in a
isc_result_t variable.  As the dns_name_copy(..., NULL) cannot fail gracefully
when the third argument is NULL, it was just a bunch of dead code.

Couple of manual tweaks (removing dead labels and unused variables) were
manually applied on top of the semantic patch.
2019-10-01 10:43:26 +10:00
Ondřej Surý
35bd7e4da0 Add RUNTIME_CHECK() around plain dns_name_copy(..., NULL) calls using spatch
This commit add RUNTIME_CHECK() around all simple dns_name_copy() calls where
the third argument is NULL using the semantic patch from the previous commit.
2019-10-01 10:43:26 +10:00
Ondřej Surý
406eba0c41 Add semantic patches to correctly check dns_name_copy(..., NULL) return code
The dns_name_copy() function cannot fail gracefully when the last argument
(target) is NULL.  Add RUNTIME_CHECK()s around such calls.

The first semantic patch adds RUNTIME_CHECK() around any call that ignores the
return value and is very safe to apply.

The second semantic patch attempts to properly add RUNTIME_CHECK() to places
where the return value from `dns_name_copy()` is recorded into `result`
variable.  The result of this semantic patch needs to be reviewed by hand.

Both patches misses couple places where the code surrounding the
`dns_name_copy(..., NULL)` usage is more complicated and is better suited to be
fixed by a human being that understands the surrounding code.
2019-10-01 10:43:26 +10:00
Ondřej Surý
98886bab43 Merge branch '846-dig-idn-alabel-fallback' into 'master'
Resolve "dig cannot display ACE query if locale is not unicode"

Closes #846

See merge request isc-projects/bind9!1418
2019-09-30 05:49:01 -04:00
Ondřej Surý
dccec984c0 Add CHANGES for GL #846 2019-09-30 11:47:39 +02:00
Ondřej Surý
c42e3583f9 Test of valid A-label in locale that cannot display it only with non-broken idn2
The libidn2 library on Ubuntu Bionic is broken and idn2_to_unicode_8zlz() does't
fail when it should.  This commit ensures that we don't run the system test for
valid A-label in locale that cannot display with the buggy libidn2 as it would
break the tests.
2019-09-30 11:47:39 +02:00
Petr Menšík
21371abd72 Emit warning on IDN output failure
Warning is emitted before any dig headers.
2019-09-30 08:52:13 +02:00
Petr Menšík
ac0cf85f09 Modify idna test to fallback to ACE
Test valid A-label on input would be displayed as A-label on output if
locale does not allow U-label.
2019-09-30 08:52:13 +02:00
Petr Menšík
c8a871e908 Fallback to ASCII on output IDN conversion error
It is possible dig used ACE encoded name in locale, which does not
support converting it to unicode. Instead of fatal error, fallback to
ACE name on output.
2019-09-30 08:52:13 +02:00
Mark Andrews
06b1af798f Merge branch 'marka-correct-list' into 'master'
use correct list

See merge request isc-projects/bind9!2410
2019-09-28 20:50:55 -04:00
Mark Andrews
9cd308ac5e Address cut-and-paste error where list name was not changed in one instance for change 5292. 2019-09-29 10:48:59 +10:00
Michał Kępień
c8925fe4d6 Merge branch '147-add-windows-to-gitlab-ci' into 'master'
Add Windows to GitLab CI

Closes #327 and #147

See merge request isc-projects/bind9!2383
2019-09-27 06:59:49 -04:00
Michał Kępień
646fcb733e Update Windows-specific documentation
Bring the files describing Windows-specific aspects of building and
installing BIND up to date.  Remove the parts which are either outdated
(e.g. 32-bit build instructions), already included elsewhere (e.g. the
list of Windows systems BIND is known to run on), or inconvenient to
keep up to date in the long run (e.g. ARM chapter numbers).
2019-09-26 15:11:15 +02:00
Michał Kępień
ca36405a3d Add Windows to GitLab CI
Ensure BIND can be tested on Windows in GitLab to more quickly catch
build and test errors on that operating system.

Some notes:

  - While build jobs are triggered for all pipelines, system test jobs
    are not - due to the time it takes to run the complete system test
    suite on Windows (about 20 minutes), the latter are only run for
    pipelines created through GitLab's web interface and for pipelines
    created for Git tags.

  - Only the "Release" build configuration is currently used.  Adding
    "Debug" builds is a matter of extending .gitlab-ci.yml, but it was
    not done for the time being due to questionable usefulness of
    performing such builds in GitLab CI.

  - Only a 64-bit build is performed.  Adding support for 32-bit builds
    is not planned to be implemented.

  - Unit tests are still not run on Windows, but adding support for that
    is on the roadmap.

  - All Windows GitLab CI jobs are run inside Windows Server containers,
    using the Custom executor feature of GitLab Runner as Windows Server
    2016 is not supported by GitLab Runner's native Docker on Windows
    executor and Windows Server 2019 is not yet widely available from
    hosting providers.

  - The Windows Docker image used by GitLab CI is not stored in the
    GitLab Container Registry as it is over 27 GB in size and thus
    passing it between GitLab and its runners is impractical.

  - There is no vcvarsall.bat variant written in PowerShell and batch
    scripts are no longer supported by GitLab Runner Custom executor, so
    the environment variables set by vcvarsall.bat are injected back
    into the PowerShell environment by processing the output of "set".

  - Visual Studio parallel builds are a bit different than "make -jX"
    builds as parallelization happens in two tiers: project parallelism
    (controlled by the "/maxCpuCount" msbuild.exe switch) and compiler
    parallelism (controlled by the "/MP" cl.exe switch).  To limit the
    total number of compiler processes spawned concurrently to a value
    similar to the one used for Unix builds, msbuild.exe is allowed to
    build at most 2 projects at once, each of which can spawn up to half
    of BUILD_PARALLEL_JOBS worth of compiler processes.  Using such
    parameters is a fairly arbitrary decision taken to solve the
    trade-off between compilation speed and runner load.

  - Configuring network addresses in Windows Server containers is
    tricky.  Adding 10.53.0.1/24 and similar addresses to the vEthernet
    interface created by Docker never causes ifconfig.bat to fail, but
    in fact only one container can have any given IP address configured
    at any given time (the request to add the same address in another
    container is silently ignored).  Thus, in order to allow multiple
    system test jobs to be run in parallel, the addresses used in system
    tests are configured on the loopback interfaces.  Interestingly
    enough, the addresses set on the loopback interfaces... persist
    between containers.  Fortunately, this is acceptable for the time
    being and only requires ifconfig.bat failures to be ignored (as
    ifconfig.bat will fail if it attempts to configure an already
    existing address on an interface).  We also need to wait for a brief
    moment after calling ifconfig.bat as the addresses the latter
    attempts to configure may not be immediately available after it
    returns (and that causes runall.sh to error out).  Finally, for some
    reason we also need to signal that the DNS servers on each loopback
    interface are to be configured using DHCP or else ifconfig.bat will
    fail to add the requested addresses.

  - Since named.pid files created by named instances used in system
    tests contain Windows PIDs instead of Cygwin PIDs and various
    versions of Cygwin "kill" react differently when passed Windows PIDs
    without the -W switch, all "kill" invocations in GitLab CI need to
    use that switch (otherwise they would print error messages which
    would cause stop.pl to assume the process being killed died
    prematurely).  However, to preserve compatibility with older Cygwin
    versions used in our other Windows test environments, we alter the
    relevant scripts "on the fly" rather than in the Git repository.

  - In the containers used for running system tests, Windows Error
    Reporting is configured to automatically create crash dumps in
    C:\CrashDumps.  This directory is examined after the test suite is
    run to ensure no crashes went under stop.pl's radar.
2019-09-26 15:11:15 +02:00
Michał Kępień
4deb2a48d9 Fix the "statschannel" system test on Windows
The SYSTEMTESTTOP variable is set by bin/tests/system/run.sh.  When
system tests are run on Windows, that variable will contain an absolute
Cygwin path.  In the case of the "statschannel" system test, using the
unmodified SYSTEMTESTTOP variable in tests.sh causes the RNDCCMD
variable to contain an invocation of a native Windows application with
an absolute Cygwin path passed as a parameter, which prevents rndc from
working in that system test.  Until we have a cleaner solution, override
SYSTEMTESTTOP with a relative path to work around the issue and thus fix
the "statschannel" system test on Windows.
2019-09-26 15:11:15 +02:00
Michał Kępień
fed397c04b Fix system test error reporting on Windows
Make sure the CYGWIN environment variable is set whenever system tests
are run on Windows to prevent stop.pl from making incorrect assumptions
about the environment it is running in, which triggers e.g. false
reports about named instances crashing on shutdown when system tests are
run on Windows.  This issue has not been caught earlier because the
CYGWIN environment variable was incidentally being set on a higher level
in our Windows test environments.

Error reporting for parallel system tests on Windows has been broken all
along: since all parallel.mk targets generated by parallel.sh pipe their
output through "tee", the return code from run.sh is lost and thus
running "make -f parallel.mk check" will not yield a non-zero return
code if some system tests fail.  The same applies to runsequential.sh.
Yet, runall.sh on Windows only sets its return code to a non-zero value
if either "make -f parallel.mk check" or runsequential.sh returns a
non-zero return code.  Fix by making runall.sh yield a non-zero return
code when testsummary.sh fails, which is the same approach as the one
used in the "test" target in bin/tests/system/Makefile.
2019-09-26 15:11:15 +02:00
Michał Kępień
0476e8f1ac Make VS solution upgrading unnecessary
Until now, the build process for BIND on Windows involved upgrading the
solution file to the version of Visual Studio used on the build host.
Unfortunately, the executable used for that (devenv.exe) is not part of
Visual Studio Build Tools and thus there is no clean way to make that
executable part of a Windows Server container.

Luckily, the solution upgrade process boils down to just adding XML tags
to Visual Studio project files and modifying certain XML attributes - in
files which we pregenerate anyway using win32utils/Configure.  Thus,
extend win32utils/Configure with three new command line parameters that
enable it to mimic what "devenv.exe bind9.sln /upgrade" does.  This
makes the devenv.exe build step redundant and thus facilitates building
BIND in Windows Server containers.
2019-09-26 15:11:15 +02:00
Michał Kępień
1d5259b0a0 Enable building dnssec-cds.exe
Build configuration for the dnssec-cds Visual Studio project is absent
from the solution file template, which means the solution needs to be
upgraded using "devenv bind9.sln /upgrade" in order for the dnssec-cds
project to be built.  Add the build configuration for dnssec-cds to the
solution file template so that upgrading the solution is not necessary
for building that project.
2019-09-26 15:11:15 +02:00
Michał Kępień
918ebd9830 Drop named-checkzone dependency on libbind9
named-checkzone does not use libbind9.  Update the Visual Studio project
file template for named-checkzone to reflect that, thus preventing
compilation issues during parallel builds.
2019-09-26 15:11:15 +02:00
Michał Kępień
de1859422e Add missing nsupdate dependency on libirs
When commit 8eb88aafee removed liblwres,
it also modified nsupdate to use libirs instead of liblwres, but the
Visual Studio project files were not updated to reflect that change.
Make sure the nsupdate Visual Studio project depends on the libirs
project to prevent compilation issues during parallel builds.
2019-09-26 15:11:15 +02:00
Ondřej Surý
22e487a584 Merge branch 'ondrej/fix-clang-10-error' into 'master'
Silence false positive warning from Clang 10 in random_test.c

See merge request isc-projects/bind9!2404
2019-09-26 09:06:14 -04:00
Ondřej Surý
9ff02c8170 Silence false positive warning from Clang 10 in random_test.c 2019-09-26 14:58:18 +02:00
Michał Kępień
c313c9f33b Merge branch 'michal/prevent-unbuffered-stderr-io-on-windows' into 'master'
Prevent unbuffered stderr I/O on Windows

See merge request isc-projects/bind9!2398
2019-09-26 08:00:51 -04:00
Michał Kępień
c72da3497d Prevent unbuffered stderr I/O on Windows
Make stderr fully buffered on Windows to improve named performance when
it is logging to stderr, which happens e.g. in system tests.  Note that:

  - line buffering (_IOLBF) is unavailable on Windows,

  - fflush() is called anyway after each log message gets written to the
    default stderr logging channels created by libisc.
2019-09-26 13:53:03 +02:00
Ondřej Surý
27cd2c7c23 Merge branch '1246-tsan-add-atomic_fetch_and+or_to_isc/stdatomic.h' into 'master'
Add atomic_fetch_add and atomic_fetch_or convenience macros and unix and win32 shims

Closes #1246

See merge request isc-projects/bind9!2397
2019-09-26 06:59:54 -04:00
Ondřej Surý
5a788adb1c Add ATOMIC_VAR_INIT initializer to mutexatomics.h 2019-09-26 11:37:35 +02:00
Ondřej Surý
728fc0ca25 Add atomic_fetch_add and atomic_fetch_or convenience macros and unix and win32 shims 2019-09-26 11:37:35 +02:00
Ondřej Surý
52064809b4 Fix the wrong function for the atomic_fetch_add_explicit64 shim on non-WIN64 build 2019-09-26 11:36:48 +02:00
Michał Kępień
6b3cf36032 Merge branch 'michal/prevent-cygwin-from-concealing-non-abort-crashes' into 'master'
Prevent Cygwin from concealing non-abort() crashes

See merge request isc-projects/bind9!2387
2019-09-26 04:38:04 -04:00
Michał Kępień
3d4b17806f Prevent Cygwin from concealing non-abort() crashes
BIND system tests are run in a Cygwin environment.  Apparently Cygwin
shell sets the SEM_NOGPFAULTERRORBOX bit in its process error mode which
is then inherited by all spawned child processes.  This bit prevents the
Windows Error Reporting dialog from being displayed, which I assume is
part of an effort to contain memory handling errors triggered by Cygwin
binaries in the Cygwin environment.  Unfortunately, this also prevents
automatic crash dump creation by Windows Error Reporting and Cygwin
itself does not handle memory errors in native Windows processes spawned
from a Cygwin shell.

Fix by clearing the SEM_NOGPFAULTERRORBOX bit inside named if it is
started in a Cygwin environment, thus overriding the Cygwin-set process
error mode in order to enable Windows Error Reporting to handle all
named crashes.
2019-09-26 10:34:01 +02:00
Michał Kępień
5a55e95b05 Merge branch '1245-properly-initialize-libxml2' into 'master'
Properly initialize libxml2

Closes #1245

See merge request isc-projects/bind9!2391
2019-09-26 04:31:48 -04:00