From 69dc94c6500722b122cf8e6649c598f3ecb5d663 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Fri, 27 May 2016 14:50:29 +0200 Subject: [PATCH] [SMPI] Fix headers for call-location tracing. smpi_trace_set_call_location() accesses smpi_process_data(). The data field however is not initialized until MPI_Init() gets called; hence, a segfault is caused. This issue does not exist for the fortran wrappers! The solution is to initialize the field just before the MPI_Init call. --- include/smpi/smpi_extended_traces.h | 2 +- tools/smpi/generate_smpi_defines.pl | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/smpi/smpi_extended_traces.h b/include/smpi/smpi_extended_traces.h index c856e41bd0..f5dd7e5567 100644 --- a/include/smpi/smpi_extended_traces.h +++ b/include/smpi/smpi_extended_traces.h @@ -1,7 +1,7 @@ // This file has been automatically generated by the script // in tools/smpi/./generate_smpi_defines.pl // DO NOT EDIT MANUALLY. ALL CHANGES WILL BE OVERWRITTEN! -#define MPI_Init(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Init(__VA_ARGS__); }) +#define MPI_Init(...) ({ smpi_process_init(__VA_ARGS__); smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Init(NULL, NULL); }) #define MPI_Finalize(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Finalize(__VA_ARGS__); }) #define MPI_Finalized(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Finalized(__VA_ARGS__); }) #define MPI_Init_thread(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Init_thread(__VA_ARGS__); }) diff --git a/tools/smpi/generate_smpi_defines.pl b/tools/smpi/generate_smpi_defines.pl index a719771890..1306f45c0d 100755 --- a/tools/smpi/generate_smpi_defines.pl +++ b/tools/smpi/generate_smpi_defines.pl @@ -40,7 +40,12 @@ sub output_macro { print "#define ". uc($id) ." smpi_trace_set_call_location(__FILE__,__LINE__); call ". lc $id ."\n"; } else { - print "#define $id(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); $id(__VA_ARGS__); })\n"; + if ($id eq "MPI_Init") { + print "#define MPI_Init(...) ({ smpi_process_init(__VA_ARGS__); smpi_trace_set_call_location(__FILE__,__LINE__); MPI_Init(NULL, NULL); })\n"; + } + else { + print "#define $id(...) ({ smpi_trace_set_call_location(__FILE__,__LINE__); $id(__VA_ARGS__); })\n"; + } } } -- 2.20.1