Segmentation fault (core dumped)
or with:
munmap_chunk(): invalid pointer
Aborted (core dumped)
depending on how it was run (console, argument to python3 or through MS Visual Code).
I found several bug reports similar to this, most was closed, or led to nowhere. I tried a short debugging session, just to see if I can quickly find a workaround:
$ gdb python3
then in gdb console:
(gdb) r draw_mark.py
and after a crash:
(gdb) where
gives location of a call to calloc(), which actually crashes:
#1 0x00007fffe86261e2 in hb_object_create<hb_font_t> () at hb-object.hh:225
Couldn't find anything suspicious about it, except maybe usage of pure-C allocations in a C++ templatized code might not be by-the-book, i.e. new should be preferred. Anyway, that code is a part of HarfBuzz, which is called by _imagingft, which is used by Raqm, which is used by Pillow. Good luck submitting bug report or fix, with a proper minimal example, then waiting for a patch to arrive in my Linux distro repository.
This is where I decided to look around, and after a short search I stumbled upon cairo. Tried it via pycairo, with hundreds of filled, outlined polygons, hundreds of outlined texts; tried generating hundred images, it works. Well, except show_text() doesn't do anything if called after set_source_rgba(), not sure if bug, or I'm using the API wrongly.
The thing is, I don't like cairo API, it's context sensitive. So, it's entirely possible to insert a few graphical elements in otherwise working code, and then suddenly it spits out garbage.
Another thing is, I'm still debating with myself, should I ditch Python, and go full Rust (via Gtk-rs)? This way I'd remove at least one dependency from the whole project. This would be opportunity to redo rendering code, while knowing in advance all of requirements. Also, this would make me finally sit down and learn Rust properly.
Or, should I do the most opportune thing, and just translate code to Python 3 + pycairo?
No comments:
Post a Comment