]> git.ipfire.org Git - thirdparty/pdns.git/commit
dnsdist: Better handling of exceptions raised during YAML parsing 15355/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 24 Mar 2025 15:29:45 +0000 (16:29 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 24 Mar 2025 15:34:43 +0000 (16:34 +0100)
commit741abe6c9b656c1940f30639e22829c825815f33
tree9da0f02016381e7751aee03bda07140daf5f2d23
parentb86d69e8213f00b0f028b531b86cb485a292b4fd
dnsdist: Better handling of exceptions raised during YAML parsing

This commit changes the way exceptions raised during the YAML configuration
parsing are handled. I previously overlooked the way `cxx` handles exceptions
raised from a C++ code called from Rust:
```
If an exception is thrown from an extern "C++" function that is not declared
by the CXX bridge to return Result, the program calls C++'s std::terminate.
The behavior is equivalent to the same exception being thrown through a
noexcept C++ function.
```

Calling `std::terminate` is obviously not what we want, so this commit
declares that all C++ functions callable by Rust can raise exceptions,
and adds the required code to properly process these exceptions on the
Rust side of things.
pdns/dnsdistdist/dnsdist-configuration-yaml.cc
pdns/dnsdistdist/dnsdist-rust-lib/dnsdist-settings-generator.py
pdns/dnsdistdist/dnsdist-rust-lib/rust-post-in.rs
pdns/dnsdistdist/dnsdist-rust-lib/rust/src/lib.rs