Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#80131 - [python-weasyprint] segfault when no font installed

Attached to Project: Arch Linux
Opened by Hector Urbina (ajendrex) - Wednesday, 01 November 2023, 14:01 GMT
Last edited by George Rawlinson (rawlinsong) - Friday, 03 November 2023, 21:09 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Caleb Maclennan (alerque)
George Rawlinson (rawlinsong)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

I can't produce any pdf, always get a Segmentation Fault error.

If I try with the same html input in Mac Os it works fine.

Additional info:
* package version(s)

weasyprint 60.1-1
fontconfig 2:2.14.2-1
pango 1:1.51.1-1

* config and/or log files etc.
Full output is:
```
(process:194): Pango-CRITICAL **: 13:49:19.232: pango_font_describe: assertion 'font != NULL' failed
(process:194): Pango-CRITICAL **: 13:49:19.232: pango_font_description_unset_fields: assertion 'desc != NULL' failed
(process:194): Pango-CRITICAL **: 13:49:19.232: pango_font_description_hash: assertion 'desc != NULL' failed
(process:194): Pango-CRITICAL **: 13:49:19.232: pango_font_get_hb_font: assertion 'PANGO_IS_FONT (font)' failed
Segmentation fault
```


* link to upstream bug report, if any
# TODO

Steps to reproduce:
1. In a clean directory, create a file named `Dockerfile` with this content:
```
FROM archlinux/archlinux

RUN pacman -Sy --noconfirm python-weasyprint
```

2. Build with `docker build . -t wbug`
3. Enter a terminal in the created image with `docker run -ti wbug`
4. In the terminal, run `python`
5. In python, run the following:
```
from weasyprint import HTML
doc = HTML(string="<html><body><h1>Title</h1></body></html>")
doc.write_pdf("output.pdf")
```

Any string that you pass which needs to render text will fail. I also tried this:
```
from weasyprint.text.fonts import FontConfiguration
from weasyprint import HTML

doc = HTML(string="<html><body><h1>Title</h1></body></html>")
doc.write_pdf("output.pdf", font_config=FontConfiguration())
```

but it keeps failing.
This task depends upon

Closed by  George Rawlinson (rawlinsong)
Friday, 03 November 2023, 21:09 GMT
Reason for closing:  Fixed
Additional comments about closing:  60.1-2
Comment by Toolybird (Toolybird) - Wednesday, 01 November 2023, 19:13 GMT
> Critical

Please respect the guidelines [1].

[1] https://wiki.archlinux.org/title/Bug_reporting_guidelines#Severity
Comment by Toolybird (Toolybird) - Wednesday, 01 November 2023, 20:46 GMT
Works fine here i.e. cannot repro. You appear to have a local issue of some kind. Seeing as there is no indication of an Arch packaging issue here, please try the more suitable support channels (Forum/IRC/Mailing Lists/Reddit/etc) to see if anyone can assist with troubleshooting/debugging.
Comment by Toolybird (Toolybird) - Wednesday, 01 November 2023, 21:14 GMT
Actually, I can now repro when no fonts are installed. Simple solution is to therefore install a font.

>>> from weasyprint import HTML
/usr/lib/python3.11/site-packages/weasyprint/text/fonts.py:65: UserWarning: No fonts configured in FontConfig. Expect ugly output.
warn('No fonts configured in FontConfig. Expect ugly output.')

Edit: Maybe a simple dep on "ttf-font" would do the trick?
Comment by George Rawlinson (rawlinsong) - Wednesday, 01 November 2023, 23:33 GMT
What a bizarre edge case, looks like ttf-font is becoming a dependency…
Comment by Hector Urbina (ajendrex) - Thursday, 02 November 2023, 00:22 GMT
> Please respect the guidelines [1].

I'm sorry Toolybird! It felt critical to me but didn't really look for guidelines.


> Maybe a simple dep on "ttf-font" would do the trick?

Yep, that did it. Thank you a lot!! I ended up installing gnu-free-fonts because there are several providers for ttf-font.

Should I do something to close this?
Comment by George Rawlinson (rawlinsong) - Friday, 03 November 2023, 21:05 GMT
No need, I'm updating the package shortly, and will close the ticket once done. :)

Loading...