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

[clang] Segfault with -module-file-info #98365

Closed
chestnykh opened this issue Jul 10, 2024 · 6 comments · Fixed by #98439
Closed

[clang] Segfault with -module-file-info #98365

chestnykh opened this issue Jul 10, 2024 · 6 comments · Fixed by #98439
Assignees
Labels
clang:modules C++20 modules and Clang Header Modules crash Prefer [crash-on-valid] or [crash-on-invalid] good first issue https://github.com/llvm/llvm-project/contribute

Comments

@chestnykh
Copy link
Contributor

chestnykh commented Jul 10, 2024

If clang is invoked with -module-file-info and the file is of incorrect type then clang segfaults.

There is assert in the code
assert(isCurrentFileAST() && "dumping non-AST?");
Segfault occurs in release build (with disabled assertions).
Should this behavior be fixed or left unchanged?

CC: @AaronBallman @cor3ntin @Endilll

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Jul 10, 2024
@EugeneZelenko EugeneZelenko added clang:modules C++20 modules and Clang Header Modules crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang Clang issues not falling into any other category labels Jul 10, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 10, 2024

@llvm/issue-subscribers-clang-modules

Author: Dmitriy Chestnykh (chestnykh)

If clang is invoked with `-module-file-info` and the file is of incorrect type then clang segfaults.

There is assert in the code
assert(isCurrentFileAST() && "dumping non-AST?");
Segfault occurs in release build (with disabled assertions).
Should this behavior be fixed or left unchanged?

CC: @AaronBallman @cor3ntin @Endilll

@shafik
Copy link
Collaborator

shafik commented Jul 10, 2024

Seems like we should provide a diagnostic instead of crashing.

CC @ChuanqiXu9

@ChuanqiXu9
Copy link
Member

Yeah, it will be better to use a diagnostic than crashing here. The reason why it is left so long is that I thought the tool is majorly used by developers not end users. But we provide it after all. And I feel this issue is suit for beginners since beyond the background, it simply requires us to add a diagnostic for it.

@ChuanqiXu9 ChuanqiXu9 added the good first issue https://github.com/llvm/llvm-project/contribute label Jul 11, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 11, 2024

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. Check that no other contributor has already been assigned to this issue. If you believe that no one is actually working on it despite an assignment, ping the person. After one week without a response, the assignee may be changed.
  2. In the comments of this issue, request for it to be assigned to you, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
  3. Fix the issue locally.
  4. Run the test suite locally. Remember that the subdirectories under test/ create fine-grained testing targets, so you can e.g. use make check-clang-ast to only run Clang's AST tests.
  5. Create a Git commit.
  6. Run git clang-format HEAD~1 to format your changes.
  7. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.

If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.

@llvmbot
Copy link
Member

llvmbot commented Jul 11, 2024

@llvm/issue-subscribers-good-first-issue

Author: Dmitriy Chestnykh (chestnykh)

If clang is invoked with `-module-file-info` and the file is of incorrect type then clang segfaults.

There is assert in the code
assert(isCurrentFileAST() && "dumping non-AST?");
Segfault occurs in release build (with disabled assertions).
Should this behavior be fixed or left unchanged?

CC: @AaronBallman @cor3ntin @Endilll

@chestnykh
Copy link
Contributor Author

Yeah, it will be better to use a diagnostic than crashing here. The reason why it is left so long is that I thought the tool is majorly used by developers not end users. But we provide it after all. And I feel this issue is suit for beginners since beyond the background, it simply requires us to add a diagnostic for it.

Okay, I will work on this issue. Assign please it to me

chestnykh added a commit to chestnykh/llvm-project that referenced this issue Jul 11, 2024
Currently clang crashes with `-module-file-info` and input file
which is not a module
Emit error instead of segfaulting.
Fix llvm#98365
aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this issue Jul 14, 2024
Currently clang crashes with `-module-file-info` and input file which is
not a module
Emit error instead of segfaulting.
Fix llvm#98365
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules crash Prefer [crash-on-valid] or [crash-on-invalid] good first issue https://github.com/llvm/llvm-project/contribute
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants