Skip to content

WeasyPrint crashes with a segmentation fault #2684

Description

@al0git

Summary

WeasyPrint crashes with a segmentation fault (SIGSEGV, signal 11) when using @font-face to override certain CSS generic font-family names (monospace, serif). The original .html file triggering the crash was generated using sphinx -b simplepdf, which in turn uses weasyprint. Here is a minimal reproduction. weasyprint is installed on a linux testing system using:

uv tool install weasyprint
uv tool list
sphinx v9.1.0
- sphinx-apidoc
- sphinx-autogen
- sphinx-build
- sphinx-quickstart
sphinx-autobuild v2025.8.25
- sphinx-autobuild
twill v3.3.1
- twill
- twill-fork
weasyprint v68.1
- weasyprint

The bug does not seem to be font-file specific - any TTF/OTF font triggers the crash when used with these generic names.

Environment

System: Linux
Machine: x86_64
Version: #1 SMP PREEMPT_DYNAMIC Debian 6.18.5-1 (2026-01-16)
Release: 6.18.5+deb14-amd64

WeasyPrint version: 68.1
Python version: 3.13.12
Pydyf version: 0.12.1
Pango version: 15700

Minimal Reproduction

Crashes (exit code 139):

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>WeasyPrint Crash - Minimal Reproduction</title>
    <style>
        /* BUG: Using generic font-family name "monospace" in @font-face crashes weasyprint */
        @font-face {
            font-family: monospace;
            src: url(fonts/FiraMono-Regular.ttf);
        }
        pre { font-family: monospace; }
    </style>
</head>
<body>
    <pre>Hello World</pre>
</body>
</html>

Works (exit code 0):

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>WeasyPrint Works - Minimal Reproduction</title>
    <style>
        /* WORKS: Using custom font-family name instead of generic "monospace" */
        @font-face {
            font-family: my-mono;
            src: url(fonts/FiraMono-Regular.ttf);
        }
        pre { font-family: my-mono; }
    </style>
</head>
<body>
    <pre>Hello World</pre>
</body>
</html>

Steps to Reproduce

# This CRASHES (exit code 139)
weasyprint test_crash.html output.pdf

# This WORKS (exit code 0)  
weasyprint test_works.html output.pdf

The only difference between the two files is:

  • test_crash.html: font-family: monospace
  • test_works.html: font-family: my-mono

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashProblems preventing documents from being rendered

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions