Avoid recursive cache lock in SDL TTF ports - #27590
Conversation
When building port libraries, build_port compiles sources with emcc in a subprocess while the parent process holds EM_CACHE_IS_LOCKED. Passing -sUSE_* flags causes the child emcc to resolve ports and attempt to acquire the cache lock if dependencies like harfbuzz are not yet in the cache, causing an AssertionError. Pass include directories directly instead of port settings flags when compiling SDL TTF port sources. Also ensure parent directories exist when writing port assets.
| self.set_setting('USE_SDL', 2) | ||
| self.set_setting('USE_SDL_TTF', 2) | ||
| with shared.cache.lock('test_sdl_ttf_parent_cache_lock'): | ||
| ports.get_port_by_name('sdl2_ttf').get(ports.Ports, settings, shared) |
There was a problem hiding this comment.
I'd rather find a way to test this from outside using embuilder and/or emcc rather then using the internal API like this.
|
In other words, the assertion in question should never fire. At least when when N process are all trying to build the same ports. The only time this assertion should ever fire is if another process deletes a ports right after the current process builds it. But being robust against the deletion of ports is not something I think we can ever really be robust against, and deleting ports while other folks are using the compiler seems like a situation that lead to crash like this. The question is, how is it possible that the second process is deleting/clearing libsdl2 here: emscripten/tools/ports/__init__.py Line 428 in 0dc8f19 |
When building port libraries, build_port compiles sources with emcc in a subprocess while the parent process holds EM_CACHE_IS_LOCKED. Passing -sUSE_* flags causes the child emcc to resolve ports and attempt to acquire the cache lock if dependencies like harfbuzz are not yet in the cache, causing an AssertionError.
Pass include directories directly instead of port settings flags when compiling SDL TTF port sources. Also ensure parent directories exist when writing port assets.