Closed bobek closed 1 year ago
Thanks for reporting. Could you please try the tip of the master
branch of Insiders? If setting concurrency: 2
on the latest release, it's very likely related to the problem reported in #5515 and should be fixed subsequently.
... also, if 4.33.2 works, it's very likely related to the problem reported in #5515.
I have just tested the tip of the master
with 1f0db88ae applied. Also verified, that it really passes expected value to the ThreadPoolExecutor
. Everything seems fine.
Interestingly at about 10% of executions, I would get the following crash:
ERROR - Error building page 'Getting_Started/Overview/faq.md': unknown file format
Traceback (most recent call last):
File "/home/bobek/Sources/ipf/docs/docs/venv/bin/mkdocs", line 8, in <module>
sys.exit(cli())
^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/mkdocs/__main__.py", line 250, in build_command
build.build(cfg, dirty=not clean)
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/mkdocs/commands/build.py", line 329, in build
_build_page(file.page, config, doc_files, nav, env, dirty)
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/mkdocs/commands/build.py", line 234, in _build_page
output = config.plugins.run_event('post_page', output, page=page, config=config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/mkdocs/plugins.py", line 520, in run_event
result = method(item, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/material/plugins/social/plugin.py", line 162, in on_post_page
raise future.exception()
File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/material/plugins/social/plugin.py", line 297, in _generate
self.card_layer_jobs[h].result(),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/material/plugins/social/plugin.py", line 331, in _render
image = self._render_typography(layer, image)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/material/plugins/social/plugin.py", line 416, in _render_typography
current, spacing = _metrics(path, line, input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/material/plugins/social/plugin.py", line 882, in _metrics
typeface = ImageFont.truetype(path, 1000)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/PIL/ImageFont.py", line 996, in truetype
return freetype(font)
^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/PIL/ImageFont.py", line 993, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bobek/Sources/ipf/docs/docs/venv/lib/python3.11/site-packages/PIL/ImageFont.py", line 248, in __init__
self.font = core.getfont(
^^^^^^^^^^^^^
OSError: unknown file format
Hmm, interesting. Are there actually font files in .cache/plugins/social/fonts
? Fonts are downloaded from Google Fonts, maybe that failed for some reasons and it's masquerades by this error. Could you try and create a reproduction?
Additionally, does the same happen when you run with concurrency: 1
? Because before you said that setting it to concurrency: 2
fixed the problem entirely, which is what was fixed in the last commit mentioned.
Okay, I think I know where this might be coming from – currently, if the font that is used for the social card hasn't been downloaded before, a thread will download it from Google. However, all threads might be trying to download it from Google and will overwrite the font files multiple times. This might lead to a half-overwritten font file that is then used by a thread that downloaded it earlier, resulting in a broken font file.
This is now fixed in 99fb7c16c
. Downloading of fonts is now synchronized with a lock, so the font is only downloaded once. @bobek could you check the tip of master
again, and check whether this fixes OSError: unknown file format
?
Sorry, @squidfunk , was snowed under daily stuff.
This might lead to a half-overwritten font file that is then used by a thread that downloaded it earlier, resulting in a broken font file.
Sounds plausible, those pesky race conditions ;)
@bobek could you check the tip of master again, and check whether this fixes OSError: unknown file format?
Confirmed, run through the sequence without hitting any issues.
Thank you!
Perfect! Glad we could sort it out that quickly ☺️ I'll issue a new Insiders release today.
Released as part of 9.1.13+insiders-4.34.1.
Context
No response
Bug description
We have been facing random SIGBUS crashes after update to
9.1.12-insiders-4.34.0
.Way to replicate is to delete
.cache
directory to force recreation of all social cards. It will then crash with about 75% chance.5515 inspired me to try setting
concurrency: 2
, I cannot say it fixed the issues, but I have not seen it crash so far. I have not studied the code yet, but maybe thecpus-1
doesn't work (yet) and your fix from #5515 will basically fix this one as well?I have
Python 3.11.2
, but also tested on3.10
with the same behavior.gdb
backtrace from core file:Related links
5515
Reproduction
I don't have reproduction archive at the moment. Our code-base is fortunately open ( https://github.com/ipfabric/docs )
Steps to reproduce
.cache
mkdocs build
to get all social cards generatedBrowser
No response
Before submitting