Fix hipBone segfault when running with rocprof #41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Running hipbone with rocprof segfaults.
The current assumption in the code was to assume the output from popen is a single line. fgets only processes a single line (up to \n). When the popen (shell) invocation is clobbered by roctracer output, what the fgets call sees is the first line which is the roctracer output, and NOT the output from the pipe, which comes in a later line. It is not clear to me why roctracer output from the parent shell is caught in the output of the child shell. I suppose there is only one stdout and so when two things write to it, you have some indeterminate ordering. This might explain why you don't see it in other OSs; perhaps they way shells are handled takes more "time" on a rhel system for a reason I don't know, and that's why we see the behaviour we see.
There are multiple ways to skin this cat. I picked one that consumes an external software dependency. The other solutions involved string parsing in C++ which is its own can of worms.