Skip to content

[compiler-rt] During profile flushing, setup SIGKILL mask earlier #68622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
24 changes: 16 additions & 8 deletions compiler-rt/lib/profile/InstrProfilingFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,10 +1034,14 @@ int __llvm_profile_write_file(void) {
int rc, Length;
const char *Filename;
char *FilenameBuf;
int PDeathSig = 0;

// Temporarily suspend getting SIGKILL when the parent exits.
int PDeathSig = lprofSuspendSigKill();

if (lprofProfileDumped() || __llvm_profile_is_continuous_mode_enabled()) {
PROF_NOTE("Profile data not written to file: %s.\n", "already written");
if (PDeathSig == 1)
lprofRestoreSigKill();
return 0;
}

Expand All @@ -1048,6 +1052,8 @@ int __llvm_profile_write_file(void) {
/* Check the filename. */
if (!Filename) {
PROF_ERR("Failed to write file : %s\n", "Filename not set");
if (PDeathSig == 1)
lprofRestoreSigKill();
return -1;
}

Expand All @@ -1057,12 +1063,11 @@ int __llvm_profile_write_file(void) {
"expected %d, but get %d\n",
INSTR_PROF_RAW_VERSION,
(int)GET_VERSION(__llvm_profile_get_version()));
if (PDeathSig == 1)
lprofRestoreSigKill();
return -1;
}

// Temporarily suspend getting SIGKILL when the parent exits.
PDeathSig = lprofSuspendSigKill();

/* Write profile data to the file. */
rc = writeFile(Filename);
if (rc)
Expand Down Expand Up @@ -1095,7 +1100,9 @@ int __llvm_orderfile_write_file(void) {
int rc, Length, LengthBeforeAppend, SuffixLength;
const char *Filename;
char *FilenameBuf;
int PDeathSig = 0;

// Temporarily suspend getting SIGKILL when the parent exits.
int PDeathSig = lprofSuspendSigKill();

SuffixLength = strlen(OrderFileSuffix);
Length = getCurFilenameLength() + SuffixLength;
Expand All @@ -1105,6 +1112,8 @@ int __llvm_orderfile_write_file(void) {
/* Check the filename. */
if (!Filename) {
PROF_ERR("Failed to write file : %s\n", "Filename not set");
if (PDeathSig == 1)
lprofRestoreSigKill();
return -1;
}

Expand All @@ -1119,12 +1128,11 @@ int __llvm_orderfile_write_file(void) {
"expected %d, but get %d\n",
INSTR_PROF_RAW_VERSION,
(int)GET_VERSION(__llvm_profile_get_version()));
if (PDeathSig == 1)
lprofRestoreSigKill();
return -1;
}

// Temporarily suspend getting SIGKILL when the parent exits.
PDeathSig = lprofSuspendSigKill();

/* Write order data to the file. */
rc = writeOrderFile(Filename);
if (rc)
Expand Down