Display notes for a possible call chain if an unsafe function is found to be
called (maybe indirectly) from a signal handler.
The call chain displayed this way includes probably not the first calls of
the functions, but it is a valid possible (in non path-sensitive way) one.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp | ||
---|---|---|
199–200 | Do we have to worry about CallLevel + 1 being negative here? (Is there a need for an assert?) | |
207–208 | Do we have to worry about call expressions for which we cannot find the declaration (like a call through a function pointer)? (Should we add some test coverage involving a call stack with a call through a function pointer?) | |
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h | ||
39–43 | Might as well not make this an optional parameter -- no real benefit from it (there's only two call sites). |
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp | ||
---|---|---|
199–200 | Really yes, but here is no assert because it is on line 161 and the function is called only there. A df_iterator path contains the start and end node, and there should be at least one function if we have any report do show, the path length should be at least 1 (make assert for that?). (Later there could be cases when the function is called with path length 1.) | |
207–208 | A declaration should always be there in the CallGraphNode, probably not a definition. The call graph does not insert nodes for function pointer calls. |
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp | ||
---|---|---|
199–200 | Thanks for the explanation -- an assert that the path has at least 1 element wouldn't be awful, but also doesn't seem like something we'd get a lot of value from here. It's up to you if you want to add an assert or not. | |
207–208 | Oh! I didn't know the CallGraph didn't model calls through function pointers (I had assumed we would model that because there's still a CallExpr involved.) Can you add a test case involving a call stack with a call through a function pointer (with comments), just to demonstrate the behavior? |
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp | ||
---|---|---|
192–218 | Small nit. |
Might as well not make this an optional parameter -- no real benefit from it (there's only two call sites).