Merge pull request #2455 from stchaker/fix_mac_segfault

avoid python C API segfault on intel mac
This commit is contained in:
Paul Romano 2023-04-21 10:55:41 -05:00 committed by GitHub
commit fffdedf5d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 2 deletions

View file

@ -68,7 +68,12 @@ extern std::string path_input; //!< directory where main .xml files resides
extern std::string path_output; //!< directory where output files are written
extern std::string path_particle_restart; //!< path to a particle restart file
extern std::string path_sourcepoint; //!< path to a source file
extern "C" std::string path_statepoint; //!< path to a statepoint file
extern std::string path_statepoint; //!< path to a statepoint file
// This is required because the c_str() may not be the first thing in
// std::string. Sometimes it is, but it seems libc++ may not be like that
// on some computers, like the intel Mac.
extern "C" const char* path_statepoint_c; //!< C pointer to statepoint file name
extern "C" int32_t n_inactive; //!< number of inactive batches
extern "C" int32_t max_lost_particles; //!< maximum number of lost particles

View file

@ -56,7 +56,7 @@ class _Settings:
@property
def path_statepoint(self):
path = c_char_p.in_dll(_dll, 'path_statepoint').value
path = c_char_p.in_dll(_dll, 'path_statepoint_c').value
return path.decode()
@property

View file

@ -193,6 +193,7 @@ int parse_command_line(int argc, char* argv[])
// Set path and flag for type of run
if (filetype == "statepoint") {
settings::path_statepoint = argv[i];
settings::path_statepoint_c = settings::path_statepoint.c_str();
settings::restart_run = true;
} else if (filetype == "particle restart") {
settings::path_particle_restart = argv[i];

View file

@ -82,6 +82,7 @@ std::string path_output;
std::string path_particle_restart;
std::string path_sourcepoint;
std::string path_statepoint;
const char* path_statepoint_c {path_statepoint.c_str()};
int32_t n_inactive {0};
int32_t max_lost_particles {10};