Skip to content

Commit c3be3c6

Browse files
authored
fix: crash in exception handling after OSL JIT (#2113)
This change fixes crashes that could be observed on Ubuntu 24.04. The crash happens in exception handling after rendering a scene with OSL shaders. This seems to be a bug in libgcc which was fixed in 14.3, but Ubuntu 24.04 is shipped with 14.2. There is a report in the GCC bug tracker: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119151 Note that this is a runtime dependency, so it doesn't really matter that a different GCC version was using during compilation as the EH frames registration happens at runtime. The easiest solution is to simply disable EH frames registration in OSL's MemoryManager. This should not affect any runtime exception unwinding as this MemoryManager is only used during JIT, so all the EH frames are unregistered from the process when the JIT code is actually executed. The issue was originally noticed in Blender, here is the report with some extra investigation and details: https://projects.blender.org/blender/blender/issues/156348 Signed-off-by: Sergey Sharybin <sergey@blender.org>
1 parent 2e38787 commit c3be3c6

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/liboslexec/llvm_util.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,22 @@ class LLVM_Util::MemoryManager final : public LLVMMemoryManager {
348348
return mm->allocateDataSection(Size, Alignment, SectionID, SectionName,
349349
IsReadOnly);
350350
}
351-
void registerEHFrames(uint8_t* Addr, uint64_t LoadAddr,
352-
size_t Size) override
351+
352+
// This memory manager is only used during JIT, where it is unnecessary to
353+
// register EH frames in the process, as the generated code is not being
354+
// executed yet. On certain platforms registering EH frames could lead to
355+
// crashes due to a bug in libgcc:
356+
//
357+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119151
358+
//
359+
// For example, the crash can be observed on Ubuntu 24.04 which is shipped
360+
// with the affected version of libgcc. To side-step the crash, simply do
361+
// not register EH frames as they are not needed during JIT.
362+
void registerEHFrames(uint8_t* /*Addr*/, uint64_t /*LoadAddr*/,
363+
size_t /*Size*/) override
353364
{
354-
mm->registerEHFrames(Addr, LoadAddr, Size);
355365
}
356-
void deregisterEHFrames() override { mm->deregisterEHFrames(); }
366+
void deregisterEHFrames() override {}
357367

358368
uint64_t getSymbolAddress(const std::string& Name) override
359369
{

0 commit comments

Comments
 (0)