Skip to content

Commit

Permalink
Fix random segfault (#537)
Browse files Browse the repository at this point in the history
(cherry picked from commit fd2f1b3)
  • Loading branch information
wenkaidu committed Apr 27, 2022
1 parent 40cafab commit 3ad297f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/graph/rome_models.cc
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,11 @@ static void parseOptions(struct ncclTopoSystem* system, const char *options) {
strcpy(str_temp, options);
char* tokens[MAX_OPT_TOKENS];
int numTokens = 0;
tokens[numTokens] = strtok(str_temp, "=, ");
char* state;
tokens[numTokens] = strtok_r(str_temp, "=, ", &state);
numTokens++;
while (tokens[numTokens-1] != NULL && numTokens < MAX_OPT_TOKENS)
tokens[numTokens++] = strtok(NULL, "=, ");
tokens[numTokens++] = strtok_r(NULL, "=, ", &state);
for (int i = 0; i < numTokens/2; i++) {
if (strcmp(tokens[i*2], "netGdrLevel") == 0) {
int j;
Expand Down Expand Up @@ -697,10 +698,11 @@ static bool disableNumaMatching(const char *options) {
strcpy(str_temp, options);
char* tokens[MAX_OPT_TOKENS];
int numTokens = 0;
tokens[numTokens] = strtok(str_temp, "=, ");
char* state;
tokens[numTokens] = strtok_r(str_temp, "=, ", &state);
numTokens++;
while (tokens[numTokens-1] != NULL && numTokens < MAX_OPT_TOKENS)
tokens[numTokens++] = strtok(NULL, "=, ");
tokens[numTokens++] = strtok_r(NULL, "=, ", &state);
for (int i = 0; i < numTokens/2; i++) {
if (strcmp(tokens[i*2], "disableNumaMatching") == 0) {
return (bool)atol(tokens[i*2+1]);
Expand Down

0 comments on commit 3ad297f

Please sign in to comment.