Skip to content
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

Coverage information is not always flushed for C/C++ programs that seg. fault #284

Open
ChrisTimperley opened this issue Oct 27, 2018 · 5 comments
Labels

Comments

@ChrisTimperley
Copy link
Collaborator

@ChrisTimperley
Copy link
Collaborator Author

FYI @afsafzal

@ChrisTimperley
Copy link
Collaborator Author

Interestingly, the signal handler below crashes once again (for certain kinds of seg. fault) when the call to __gcov_flush is made.

extern void __gcov_flush(void);
void bugzoo_sighandler(int sig){
        __gcov_flush();
        fprintf(stderr, "no bueno");
        exit(1);
}

@afsafzal
Copy link
Member

What do you mean? Do you mean __gcov_flush crashes?

@ChrisTimperley
Copy link
Collaborator Author

What do you mean? Do you mean __gcov_flush crashes?

Exactly.

If the call to __gcov_flush is removed, no bueno is printed to the stderr, as expected.

@ChrisTimperley
Copy link
Collaborator Author

ChrisTimperley commented Oct 30, 2018

void gflush(){
  fprintf(stderr, "flushing...\n");
  // __gcov_flush();
  fprintf(stderr, "flushed!\n");
}
void bugzoo_sighandler(int sig){
  fprintf(stderr, "no bueno\n");
  exit(1);
}
void bugzoo_ctor (void) __attribute__ ((constructor));
void bugzoo_ctor (void) {
  if (atexit(gflush) != 0)
    fprintf(stderr, "failed to register gflush\n");

The program above exits with code 1 and produces the following output:

no bueno
flushing...
flushed!

shell returned 1

When the call to __gcov_flush is uncommented, the following output is produced:

no bueno
flushing...
Segmentation fault (core dumped)

shell returned 139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants