-
Notifications
You must be signed in to change notification settings - Fork 4.7k
The BPF tools report blown stacks but provide no information about how to track down the offenders #13290
Comments
The second requirement Limit the warnings to only the code pulled into the final program seems a bit unrealistic, because when the compiler is processing a function and determines that the function's stack size exceeds the limit, it cannot be known whether this function's code will be pulled into the final program. |
llvm already outputs the name of the function that blows the stack. I added printing the filename and line where the function is defined, when debug information is available. I also reduced the number of messages to one only for each function For example,
Unfortunately llvm cannot demangle rustc's name mangling, so it may be necessary to filter the messages through rustfilt. This fix will be included in the bpf-tools v1.4 release. |
@dmakarov Can we defer the stack size check to the end where we know which functions are pulled into the final binary? That info is probably not retained all the way to the final link, but maybe there is a way to do so? |
Not sure if it's possible. This check is done as part of the frame index elimination. The frame index is used to compute the offsets encoded in instructions referring to the corresponding stack entries. By the link time, this information is available only in instructions encoding, it seems. If the warning is for the function in an external package that is not controlled by the user, then it's not useful, but not much can be done about it anyway. If it warns about the code that the user controls, it seems the warning is useful at this point as well as it would be at the link time. |
It is still useful in an external package if the function is pulled into the final binary because the developer has the choice to not call it and do something else. Not recommending this because it's pretty ugly but we could someone store the stack usage of each function and then lookup and report during link or post-link? |
Maybe it's better at link time to have a pass that analyzes offsets encoded in instructions and reports those that exceed the stack size limit, but that probably requires LTO to be enabled. |
Can we add a pass to the linker? |
This is resolved by enabling the variable size stack in the RBPF VM. The support for variable size stacks has been added to the VM. solana-labs/rbpf#274 |
Problem
If a function exceeds the supported stack size LLVM will warn the user but not provide information on what function is the offender.
Background: We've found that in Rust, there are often packages that a program depends on that exceed the stack usage even though the program is not actually using the offending functionality. (or maybe a dependency of a dependency). Instead of halting program compilation LLVM posts a warning.
Proposed Solution
The text was updated successfully, but these errors were encountered: