llvm / llvm/llvm-project

[llvm-test-suite] bug in paq8p.cpp

Open Beginner friendly
#216,779 0 comments 0 reactions 0 assignees View on GitHub
llvm test-suite
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

If `catch` block is executed, then the return value of `paqmain` is still 0 (which is a bug). Hence, in `if (rc) return rc;` the `return rc;` is not executed (which is unexpected).

```c
int paqmain(int argc, char** argv) {
...
catch(const char* s) {
if (s) printf("%s\n", s);
// <= why no return 1 here ??
}
if (pause) {
printf("\nClose this window or press ENTER to continue...\n");
getchar();
}
return 0;
}

int main(int argc, char **argv)
{
#ifndef LLVM
return paqmain(argc, argv);
#else
int rc = 1;
/* there is lot of static data, need a clean state for decompress to work
* properly, so fork */
pid_t pid = fork();
if (pid == 0) {
/* compress files */
exit(paqmain(argc, argv));
} else if (pid == -1) {
perror("fork() failed");
exit(1);
}
wait(&rc);
if (rc)
return rc;
```

Contributor guide

Open the contributing guide

Research direction

Locate paq8p.cpp in the llvm-test-suite and inspect paqmain, especially the catch block and its return path. Compare that behavior with main's rc handling and wait call. Done means failures from the catch block propagate as a nonzero result and the relevant test behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.