llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[MIRSampleProfile] nullptr deref crash when profile sample use file not found

Open nickdesaulniers opened this issue 8 months ago • 8 comments

Trying to reproduce https://github.com/llvm/llvm-project/issues/188897, I failed to pass a valid file for -fprofile-sample-use=; this caused a crash because Reader is nullptr in MIRProfileLoader::runOnFunction. Should be easy to guard against this I think. cc @htyu (author of 958a3d8e2dec95a878dfc9d823861b3a6c674534)

nickdesaulniers avatar Mar 31 '26 22:03 nickdesaulniers

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 is working on this issue. If someone is assigned to the issue or claimed to be working on it, ping the person. After one week without a response, the assignee may be changed.
  2. Leave a comment indicating that you are working on the issue, 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 avatar Mar 31 '26 22:03 llvmbot

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

Author: Nick Desaulniers (nickdesaulniers)

Trying to reproduce https://github.com/llvm/llvm-project/issues/188897, I failed to pass a valid file for `-fprofile-sample-use=`; this caused a crash because `Reader` is `nullptr` in `MIRProfileLoader::runOnFunction`. Should be easy to guard against this I think. cc @htyu (author of 958a3d8e2dec95a878dfc9d823861b3a6c674534)

llvmbot avatar Mar 31 '26 22:03 llvmbot

Does it reproduce in godbolt? If so it is always helpful to provide them.

shafik avatar Apr 01 '26 15:04 shafik

$ clang++ -cc1 -emit-obj -fprofile-sample-use=/dev/foo -mllvm -enable-fs-discriminator=true -x c++ foo.i

is crashing for me at c1ebd2f1c07f1dc51df1c1a56891fe564cbadc19. Can't seem to get clang to crash on godbolt with these flags though.

// foo.i
void android_logger_list_alloc_internal() {}

nickdesaulniers avatar Apr 01 '26 16:04 nickdesaulniers

@nickdesaulniers Hi, I'd like to work on this.

jensensang avatar Apr 02 '26 04:04 jensensang

I would also like to take this issue.

heturing avatar Apr 02 '26 13:04 heturing

I have locally fixed this issue and am preparing a PR

frank-515 avatar Apr 02 '26 14:04 frank-515

I want to work on this

purnima-nlp avatar Jul 13 '26 15:07 purnima-nlp