Skip to content

Commit 2b17d87

Browse files
lucasgelfondclaude
andcommitted
Build with wasm exceptions so zimg errors don't abort the module
zimg throws and catches C++ exceptions for invalid parameters. Without exception support the throw aborted the whole core (found by the fuzzer with zscale=w=3:h=-1). -fwasm-exceptions also selects wasm setjmp/longjmp, so every library is built with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9c22d39 commit 2b17d87

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎Dockerfile‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ ARG EXTRA_LDFLAGS
1111
ARG MAKE_JOBS
1212
ENV INSTALL_DIR=/opt
1313
# FFmpeg's command line tools need threads since 6.1, so everything is built with pthreads.
14-
ENV CFLAGS="-I$INSTALL_DIR/include -pthread $EXTRA_CFLAGS"
14+
# zimg reports errors with C++ exceptions it catches itself, so everything is also
15+
# built with wasm exceptions (and the matching setjmp/longjmp).
16+
ENV CFLAGS="-I$INSTALL_DIR/include -pthread -fwasm-exceptions $EXTRA_CFLAGS"
1517
ENV CXXFLAGS="$CFLAGS"
1618
ENV LDFLAGS="-L$INSTALL_DIR/lib $CFLAGS $EXTRA_LDFLAGS"
1719
ENV EM_PKG_CONFIG_PATH=$INSTALL_DIR/lib/pkgconfig:/emsdk/upstream/emscripten/system/lib/pkgconfig
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Found by `npm run fuzz`: zimg (the zscale filter) reports errors by
2+
// throwing C++ exceptions it catches itself. The core was built without
3+
// exception support, so any zscale error aborted the whole module.
4+
import { useCore, execLogged } from "../../helpers.js";
5+
6+
export default function () {
7+
const ctx = useCore();
8+
9+
it("an invalid zscale size is an error, not a crash", () => {
10+
const run = (vf) => execLogged(ctx.core, "-f", "lavfi", "-i", "color=c=red:s=64x48:d=0.3", "-vf", vf, "-f", "null", "-").ret;
11+
expect(() => run("zscale=w=3:h=-1")).to.not.throw();
12+
expect(run("zscale=w=32:h=24")).to.equal(0);
13+
});
14+
}

0 commit comments

Comments
 (0)