Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 833864 - >=media-sound/lilypond-2.22.1: general protection fault due to provided fix-font-size.patch
Summary: >=media-sound/lilypond-2.22.1: general protection fault due to provided fix-f...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: Scheme Project
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2022-02-21 22:55 UTC by Jan Breig
Modified: 2022-02-24 01:24 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Revert free that leads to crash (revert_free_temporary_font_description.patch,669 bytes, patch)
2022-02-21 23:01 UTC, Jan Breig
Details | Diff
Lighttpd DEBUG output on a small test file (crash.log,6.97 KB, text/x-log)
2022-02-21 23:18 UTC, Jan Breig
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Breig 2022-02-21 22:55:22 UTC
Since version 2.22.1, the provided lilypond-<version>-fix-font-size.patch leads to a crash of lilypond when running it on any *.ly file.
The patch changes a line in pango-font.cc However in version 2.22.1, there is the additional line `pango_font_description_free (descr);` in the source code, which causes a crash when combined with the provided patch file.

Reproducible: Always

Steps to Reproduce:
1. Compile lilypond with the provided lilypond-<version>-fix-font-size.patch file
2. Run lilypond on any file e.g. `lilypond test.ly`
Actual Results:  
Lilypond crashes

Expected Results:  
Lilypond should compile the file

There are two solutions to the problem.
1. Remove the fix-font-size patch (I don't know what it is supposed to fix so i can't say if it's still needed)
2. Remove the `pango_font_description_free (descr);` line (see attached patch file)
Comment 1 Jan Breig 2022-02-21 23:01:44 UTC
Created attachment 765590 [details, diff]
Revert free that leads to crash
Comment 2 Jan Breig 2022-02-21 23:18:20 UTC
Created attachment 765591 [details]
Lighttpd DEBUG output on a small test file
Comment 3 Maciej Barć gentoo-dev 2022-02-22 15:02:52 UTC
All versions matching >=media-sound/lilypond-2.22.1 are broken you you Jan?

Also I haven't looked into it much but won't "Revert free that leads to crash" lead to memory leaks? (dunno what "pango_font_description_free" does)
Comment 4 Jan Breig 2022-02-23 17:12:11 UTC
tl;dr Yes all versions matching >=media-sound/lilypond-2.22.1 are broken. The revert patch should not produce any memory leaks.


Yes I checked all available versions (2.22.0, 2.22.1, 2.23.0, 2.23.2 and 9999). Only 2.22.0 did not crash.

I did some research regarding memory leaks.
The original code calls the function `pango_font_describe`
The provided patch file replaces this with the function `pango_context_get_font_description`.

`pango_font_describe` returns a newly-allocated PangoFontDescription object (see https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Font.describe.html). `pango_context_get_font_description` returns a pointer to an existing font description. According to the docs, the value must not be freed (see https://docs.gtk.org/Pango/method.Context.get_font_description.html).

So the call to `pango_font_description_free` is required in the original code to prevent memory leaks. But with the patch applied, not only is it not required, it is forbidden to free the value.

If anyone wants to look into this, this is the line in question: https://github.com/lilypond/lilypond/blob/6380ca5973a34f4c44766c40dbef7c09f93fc004/lily/pango-font.cc#L425
Comment 5 Maciej Barć gentoo-dev 2022-02-23 17:50:31 UTC
> So the call to `pango_font_description_free` is required in the original code to prevent memory leaks. But with the patch applied, not only is it not required, it is forbidden to free the value.

OH! Gotcha, thanks a lot Jan, I will try to merge this soon-ish.
Comment 6 Larry the Git Cow gentoo-dev 2022-02-24 01:24:09 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fcaa927cebf1bc3db1404487e3fa7757a8e1eb99

commit fcaa927cebf1bc3db1404487e3fa7757a8e1eb99
Author:     Maciej Barć <xgqt@gentoo.org>
AuthorDate: 2022-02-24 01:18:06 +0000
Commit:     Maciej Barć <xgqt@gentoo.org>
CommitDate: 2022-02-24 01:23:49 +0000

    media-sound/lilypond: add free temporary font description patch
    
    Closes: https://bugs.gentoo.org/833864
    Package-Manager: Portage-3.0.30, Repoman-3.0.3
    Signed-off-by: Maciej Barć <xgqt@gentoo.org>

 media-sound/lilypond/files/lilypond-2.22.1-free_font.patch | 14 ++++++++++++++
 .../{lilypond-2.22.1.ebuild => lilypond-2.22.1-r1.ebuild}  |  1 +
 .../{lilypond-2.23.0.ebuild => lilypond-2.23.0-r1.ebuild}  |  1 +
 .../{lilypond-2.23.2.ebuild => lilypond-2.23.2-r1.ebuild}  |  3 ++-
 media-sound/lilypond/lilypond-9999.ebuild                  |  1 +
 5 files changed, 19 insertions(+), 1 deletion(-)