Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/libmain/shared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <algorithm>
#include <exception>
#include <iostream>
#include <dlfcn.h>

#include <cstdlib>
#include <sys/time.h>
Expand Down Expand Up @@ -408,3 +409,16 @@ PrintFreed::~PrintFreed()
}

} // namespace nix

typedef void (*cxa_throw_type)(void *, void *, void (*) (void *));

void __cxa_throw(void * exc, void * tinfo_, void (*dest)(void *))
Comment on lines +413 to +415
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance the second argument could be declared std::type_info * instead of void *? That would make the tinfo / tinfo_ distinction unnecessary.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That changes the mangled name in a way that doesn't match the real __cxa_throw, so unfortunately it doesn't work.

{
auto * tinfo = (std::type_info *) tinfo_;

if (*tinfo == typeid(std::logic_error))
abort();

static auto orig_cxa_throw = (cxa_throw_type) dlsym(RTLD_NEXT, "__cxa_throw");
orig_cxa_throw(exc, tinfo_, dest);
}
Loading