@@ -486,6 +486,53 @@ int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag,
486486
487487// Add more MPI function hooks as needed...
488488
489+ // Override problematic OpenMPI internal function to prevent SIGILL
490+ int ompi_errhandler_init (void ) {
491+ static int initialized = 0 ;
492+ static typeof (ompi_errhandler_init ) * orig_ompi_errhandler_init = NULL ;
493+
494+ if (initialized ) {
495+ LOG_TRACE ("ompi_errhandler_init already initialized, skipping\n" );
496+ return 0 ; // Return success without doing anything
497+ }
498+
499+ // Try to load the original function
500+ if (!orig_ompi_errhandler_init ) {
501+ orig_ompi_errhandler_init = dlsym (RTLD_NEXT , "ompi_errhandler_init" );
502+ if (!orig_ompi_errhandler_init ) {
503+ // If we can't find it, that's okay - just mark as initialized
504+ LOG_DEBUG ("ompi_errhandler_init not found in RTLD_NEXT, returning success\n" );
505+ initialized = 1 ;
506+ return 0 ; // Return MPI_SUCCESS (0)
507+ }
508+ }
509+
510+ LOG_TRACE ("Calling original ompi_errhandler_init at %p\n" , orig_ompi_errhandler_init );
511+
512+ // Set flag first to prevent recursion
513+ initialized = 1 ;
514+
515+ // Call original if it exists
516+ if (orig_ompi_errhandler_init ) {
517+ return orig_ompi_errhandler_init ();
518+ }
519+
520+ return 0 ; // Return success
521+ }
522+
523+ // Alternative: completely stub out the function if it's causing issues
524+ // Uncomment this version if the above still causes SIGILL
525+ /*
526+ int ompi_errhandler_init(void) {
527+ static int called = 0;
528+ if (!called) {
529+ called = 1;
530+ LOG_DEBUG("ompi_errhandler_init stubbed out to prevent SIGILL\n");
531+ }
532+ return 0; // Always return success
533+ }
534+ */
535+
489536// Library constructor
490537__attribute__((constructor ))
491538static void shim_init (void ) {
0 commit comments