<!-- agents: TestFlows, a blog post. Index: https://testflows.com/llms.txt -->

# Making Bombadil Exclaim: libvoidstar dlopen successful!

Published 2026-12-03 by Vitaliy Zakaznikov.

Did you know that [Bombadil](https://github.com/antithesishq/bombadil) tries to reach for the star? Given the mysterious fellow he is, one would expect so. A voidstar, to be exact, and whether he reaches it depends on where he runs. When Bombadil starts, it tries to load a library, `/usr/lib/libvoidstar.so`. If the library is not there, Bombadil runs as it would locally on your laptop and makes every decision itself. If it is there, Bombadil draws its random values from the library, and tells it the moments when the program it tests reaches a new state and the results of the properties it checks. When it finds the library, Bombadil says so on its standard error with one line: `libvoidstar dlopen successful!` In [Why Run Bombadil in a Deterministic Hypervisor?](/blog/why-run-bombadil-in-a-deterministic-hypervisor.md), it never printed that line. In this post, we look at what Bombadil does with the library, and how we got it to exclaim that line inside [TestFlows Machine](/machine.md).<!-- more -->

If you want to jump into the code before reading, see the complete example in our public repository under [examples/compose/bombadil-antithesis](https://github.com/testflows/Machine/tree/main/examples/compose/bombadil-antithesis). Now, let's see what Bombadil has in store for us.

## How Bombadil knows where it is

Bombadil is an open-source project with core development supported by Antithesis, and `libvoidstar.so` is how programs talk to the Antithesis platform and its fuzzer. Inside Antithesis, that path holds the real library. Everywhere else, it usually holds nothing.

Bombadil looks for two things. The first is the environment variable `ANTITHESIS_OUTPUT_DIR`. Its whole check fits in one line of [antithesis.rs](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil/src/antithesis.rs):

```rust
static IS_IN_GUEST: LazyLock<bool> =
    LazyLock::new(|| std::env::var("ANTITHESIS_OUTPUT_DIR").is_ok());
```

The second is the library `/usr/lib/libvoidstar.so`. Bombadil opens it from a small C shim, [libvoidstar_shim.c](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/antithesis-fuzzer/src/libvoidstar_shim.c#L26-L58), which [runs](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/antithesis-fuzzer/src/lib.rs#L14-L22) from `.init_array` before `main` is executed:

```c
libvoidstar_handle = dlopen("/usr/lib/libvoidstar.so", RTLD_NOW);
...
init_coverage_module_real = (init_coverage_module_fn)dlsym(
    libvoidstar_handle, "init_coverage_module");
notify_coverage_real =
    (notify_coverage_fn)dlsym(libvoidstar_handle, "notify_coverage");
fuzz_getchar_real =
    (fuzz_getchar_fn)dlsym(libvoidstar_handle, "fuzz_getchar");
if (!init_coverage_module_real || !notify_coverage_real ||
    !fuzz_getchar_real) {
  debug_out(
      "libvoidstar missing expected symbols; coverage calls will no-op");
  ...
}
libvoidstar_loaded = true;
debug_out("libvoidstar dlopen successful!");
```

The `debug_out` above prints to standard error only when `ANTITHESIS_OUTPUT_DIR` is set, so on your laptop Bombadil stays quiet whether or not it found the library.

> To make it print that line, both have to be there: the variable, and a library at that exact path that exports all three symbols.

However, the shim is not the only one opening the library. Bombadil is also built with the [Antithesis Rust SDK](https://github.com/antithesishq/antithesis-sdk-rust), version 0.2.9, and one of the first things its `main` does is [call `antithesis_init()`](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil-cli/src/main.rs#L14). The SDK [opens `/usr/lib/libvoidstar.so`](https://docs.rs/crate/antithesis_sdk/0.2.9/source/src/internal/voidstar_handler.rs#32-35) on its own and looks for `fuzz_json_data`, `fuzz_get_random` and `fuzz_flush`. If it can't load them, it [falls back](https://docs.rs/crate/antithesis_sdk/0.2.9/source/src/internal/mod.rs#58-66) to writing its messages to the file `ANTITHESIS_SDK_LOCAL_OUTPUT` names, or to nothing.

> So the same library is opened twice in one process, for two different sets of calls.

## The interface to the fuzzer

So what does Bombadil do with the library once it has it? Reading the source, there are four things, and each one goes through a call into `libvoidstar.so`:

{% html div class="styled-table" %}

| What Bombadil does | Call into libvoidstar | Through |
|---|---|---|
| [Draws every random value](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil-cli/src/terminal.rs#L271) | [`fuzz_get_random`](https://docs.rs/crate/antithesis_sdk/0.2.9/source/src/internal/voidstar_handler.rs#57-59) | the SDK's [`AntithesisRng`](https://docs.rs/crate/antithesis_sdk/0.2.9/source/src/random.rs#150-160) |
| [Reports each property as an `Always` assertion](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil/src/runner.rs#L206-L220) | [`fuzz_json_data`, then `fuzz_flush`](https://docs.rs/crate/antithesis_sdk/0.2.9/source/src/internal/voidstar_handler.rs#47-55) | the SDK's [`assert_raw`](https://docs.rs/crate/antithesis_sdk/0.2.9/source/src/assert/mod.rs#347-389) |
| [Marks a state boundary at every change of the screen or page](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil/src/runner.rs#L163-L168) | [`fuzz_getchar`, its result discarded](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/antithesis-fuzzer/src/lib.rs#L43-L49) | the [shim](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/antithesis-fuzzer/src/libvoidstar_shim.c#L77-L83) |
| [Reports new coverage of the web application under test](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil-browser/src/driver.rs#L130-L143) | [`init_coverage_module`](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil-browser/src/driver.rs#L58-L61), [`notify_coverage`](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil-browser/src/driver.rs#L141-L143) | the [shim](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/antithesis-fuzzer/src/libvoidstar_shim.c#L63-L75) |

{% endhtml %}

### Random values

The random values are the obvious part. In a terminal test, `AntithesisRng` picks the next action from the specification's action tree, and then the action's own values: the text to type, the rows and columns of a resize, the row and column of a click. Every one of them is a call to `fuzz_get_random`. The Antithesis [documentation](https://antithesis.com/docs/reference/sdk/generate_randomness/) explains that the SDK's randomness lets the platform learn the input space, which is why you should never seed your own generator from it. And Bombadil doesn't.

### Properties

The properties are reported at every step. After each new state, Bombadil evaluates its properties and [calls `assert_raw`](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil/src/runner.rs#L188-L221) for each one, as an `Always` assertion that must be hit. A property that holds, or is not decided yet, is reported with its condition true. A violated one is reported with its condition false and the violation in its details. The SDK [passes on only the first of each](https://docs.rs/crate/antithesis_sdk/0.2.9/source/src/assert/mod.rs#195-219): a property's first pass and its first violation reach the library, and the rest are counted and dropped.

> The checks stay Bombadil's own: Bombadil decides whether a property holds before it makes the call, and the assertion only reports that result. Bombadil reports its violations and exits with its own code, as it does locally.

### State boundary

The state boundary is the interesting part. This is the comment above the call in [runner.rs](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil/src/runner.rs#L163-L168):

```rust
if antithesis::is_in_guest() {
    // This lets the Antithesis fuzzer know of a new state in
    // our loop, so that it can fork and change the entropy to
    // explore the SUT.
    antithesis_fuzzer::mark_state_boundary();
}
```

And [`mark_state_boundary`](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/antithesis-fuzzer/src/lib.rs#L43-L49) is just this:

```rust
pub fn mark_state_boundary() {
    // We call this as a way of telling the Antithesis
    // fuzzer that this is the boundary of a state,
    // from where it may fork off and try other entropy
    // input.
    let _ = unsafe { antithesis_fuzz_getchar() };
}
```

A call that reads a character, whose character nobody reads. Its only purpose is to tell the fuzzer: here is a good place to fork. Every new screen nano draws is a point from which the fuzzer may try other random values.

### Coverage

Coverage is reported only by the browser driver, for the JavaScript of the page under test, and only for edges that are new to Bombadil's own map. The terminal examples report no coverage.

One thing we noticed while reading the shim: `init_coverage_module` returns the offset of the module in the coverage map. Bombadil's Rust code [declares it as returning a `usize`](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/antithesis-fuzzer/src/lib.rs#L6-L9). The browser driver [keeps it](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil-browser/src/driver.rs#L58-L61) as `coverage_map_offset` and [adds it to every edge](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil-browser/src/driver.rs#L141-L143) it reports. But the shim's [typedef](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/antithesis-fuzzer/src/libvoidstar_shim.c#L11-L12) for the real function and its own [wrapper](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/antithesis-fuzzer/src/libvoidstar_shim.c#L63-L69) both return `void`:

```c
typedef void (*init_coverage_module_fn)(size_t edge_count,
                                        const char *symbol_file_name);
...
void antithesis_init_coverage_module(size_t edge_count,
                                     const char *symbol_file_name) {
  libvoidstar_ensure_loaded();
  if (libvoidstar_loaded) {
    init_coverage_module_real(edge_count, symbol_file_name);
  }
}
```

So, by the C source, the offset Rust reads is whatever is left in the return register. In the binary we ran, the compiler turned that call into a tail jump, so with the library loaded, Rust reads exactly the value the library returned. Without the library, the wrapper returns without setting the register, and the offset is whatever was left there. Only the browser driver uses the offset, so the terminal examples never meet it.

### Everything else

Everything else stays the same. Even inside Antithesis, Bombadil picks actions with the same weights and writes the same trace as it does locally. Earlier versions did not: they ignored the action weights and wrote no trace inside Antithesis, until [#402](https://github.com/antithesishq/bombadil/pull/402) removed both differences. The one thing it does refuse is its own `fuzz` mode, [with](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/bombadil-cli/src/terminal.rs#L377-L382) `` bombadil fuzzing mode is not available in antithesis; use `test` or `test-external` ``. That makes sense. When the platform does the fuzzing, Bombadil's own fuzzer would only get in the way.

## The public stub is not enough

Antithesis publishes a stub of the `libvoidstar` library, [antithesis_stub](https://github.com/antithesishq/antithesis_stub), MIT-licensed. Outside Antithesis, the stub answers `fuzz_get_random` from `getrandom`, and every output and coverage call does nothing. It is what an SDK is meant to find outside Antithesis.

But look at the [list of symbols the shim requires](https://github.com/antithesishq/bombadil/blob/v0.8.0/lib/antithesis-fuzzer/src/libvoidstar_shim.c#L42-L55). The stub's [libvoidstar.c](https://github.com/antithesishq/antithesis_stub/blob/v2.0.0/libvoidstar.c) exports `init_coverage_module` and `notify_coverage`, but not `fuzz_getchar`. So if you copy the stub to `/usr/lib/libvoidstar.so` and set `ANTITHESIS_OUTPUT_DIR`, Bombadil ends up only halfway to his desired star. The SDK finds its three calls and uses the stub for random values and assertions. But the shim finds two of its three calls and gives up with the `libvoidstar missing expected symbols; coverage calls will no-op` message.

> It never exclaims, because the stub has no `fuzz_getchar`.

## Serving libvoidstar.so to every container

Now let's see how we can make Bombadil use the library inside a machine where a program runs in a container, from an image someone else built. We did not want anyone to change their images, their Compose file or their programs. So the library is not in the disk the user builds. The machine itself can provide it.

Every program in a machine that opens `/usr/lib/libvoidstar.so` gets Machine's library, in every container, whatever the image has at that path. Even an image that carries the stub there gets Machine's copy. The library is read-only, so no program in the machine can change it. And because the library is part of the machine, a replay loads exactly the same one as the recording did.

Machine's library exports every function of the stub, plus `fuzz_getchar`, and it loads into programs built against glibc and musl alike.

With all that in place, the variable is the easy part. `machine disks build` sets `ANTITHESIS_OUTPUT_DIR` in each service that does not set it itself, to the machine's drop directory, `/.machine/output/drop`, the same directory as `MACHINE_DROP_OUTPUT_DIR`.

## A Bombadil that can load a library

Here is a detail that cost us a little time. Bombadil's [release download](https://github.com/antithesishq/bombadil/releases/tag/v0.8.0), `bombadil-x86_64-linux`, the one we used in the [previous post](/blog/why-run-bombadil-in-a-deterministic-hypervisor.md), is a statically linked binary, [built against musl](https://github.com/antithesishq/bombadil/blob/v0.8.0/flake.nix#L58-L62). In a statically linked musl program, `dlopen` [fails at once](https://git.musl-libc.org/cgit/musl/tree/src/ldso/dlopen.c?h=v1.2.5) with "Dynamic loading not supported", without opening any file. So that Bombadil never finds the library, in a machine, in Antithesis, or anywhere else. It runs as it would on a laptop.

The dynamically linked build is the one inside Antithesis's own `antithesishq/bombadil` image. We could have built a dynamically linked Bombadil ourselves from source. Instead, we chose to take the binary out of that image, so that what we run in the machine is the same unmodified binary that runs inside Antithesis. The image carries Chromium and is about 4 GB. Our example image takes from it only the `bombadil` binary and the three Nix store directories the binary links, glibc, gcc's runtime libraries and libgcc, and adds nano. The result is 211 MB instead of 4 GB. The Dockerfile pins Antithesis's image by digest and checks the nano specification by its SHA-256.

## Running it

Our example runs Bombadil's nano example for 30 seconds. A small script, `run.sh`, prints what Bombadil found: the value of `ANTITHESIS_OUTPUT_DIR` in Bombadil's environment, read from `/proc/<pid>/environ`, and the library Bombadil mapped, read from `/proc/<pid>/maps`.

Here are the commands to build the Compose environment, create a session, build the disk, start the machine and run it until nano exits:

```
$ docker compose build
$ machine sessions create bombadil --cpus 2 --mem 4G
$ machine disks build --compose . bombadil-exclaim-dev
$ machine create bombadil-exclaim-dev --disk bombadil-exclaim-dev --cpus 2 --mem 2048
$ machine run bombadil-exclaim-dev --until 'console~nano exited' --within 10m
```

Once executed, you can examine the output from the console:

```
$ machine output bombadil-exclaim-dev --source console | grep 'app |'
app | === bombadil: libvoidstar dlopen successful!
app | === bombadil: bombadil 0.8.0
app | === bombadil: ANTITHESIS_OUTPUT_DIR=/.machine/output/drop
app | === bombadil: loaded /usr/lib/libvoidstar.so
app | === bombadil: nano exited 1
```

And there it is, on the very first line! That line is Bombadil's own, printed by the shim when `bombadil --version` starts. The next lines are the example's: the variable Bombadil reads, and the library it mapped. The run took 34.4 seconds of machine time and had 290,237 entries. The complete console of the run, with the entries that printed each line, is [bombadil-antithesis.log](https://github.com/testflows/Machine/blob/main/examples/compose/bombadil-antithesis/bombadil-antithesis.log) in the example.

`nano exited 1` is the nano example's result. It does report violations of `hasStandardBindings`, the property about nano's key bindings. As we showed in the [previous post](/blog/why-run-bombadil-in-a-deterministic-hypervisor.md), those violations are a race between Bombadil's sampling and nano's repaint after a resize, not bugs in nano.

## Bombadil finds a new home

Bombadil now believes it is in Antithesis. It draws its random values from the library, and tells it its state boundaries and the results of its properties. Making it exclaim was the first step, and in our run these calls already mean something in the machine. Each of the 5,544 random values Bombadil drew is a decision the machine recorded. The first pass and the first violation of `hasStandardBindings` are events in the run, and so is each of the 2,210 state boundaries. The next step is to use them: answer a decision differently on a branch, and fork at a state boundary, which is exactly what Bombadil's comment asks the fuzzer to do. While Antithesis will always be his original home, it can be just one of many.

<div style="text-align: center; margin-bottom: 1.5rem">
<img alt="Bombadil laughing on the path to a cottage in a hillside, under a swirling sky with a bright star" style="width: 60%; display: block; margin: 0 auto 0.5rem" src="/images/making-bombadil-exclaim-libvoidstar-dlopen-successful-home.jpg">
<em>And Bombadil laughed. His road was long, and he did miss his home, but the voidstar had led him to another, and he knew it would not be his last.</em>
</div>

> If you have Bombadil specifications, or any program built with an Antithesis SDK, we'd love to work with you to get it running in Machine. You can [sign up](/machine/portal/signup/) for free, and for a bigger session, just drop us a note at [contact@testflows.com](mailto:contact@testflows.com).
