RFR: 8321971: Improve the user name detection logic in perfMemory get_user_name_slow [v3]

Johan Sjölen jsjolen at openjdk.org
Mon Feb 19 20:07:56 UTC 2024


On Wed, 20 Dec 2023 12:18:36 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Jaikiran Pai has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:
>> 
>>  - remove redundant if block
>>  - merge latest from master branch
>>  - David's review comments - reduce if blocks and release the array outside if block
>>  - David's review comment - punctuation
>>  - 8321971: Improve the user name detection logic in perfMemory get_user_name_slow
>
> Just a note - I have incorporated the review comments, except from Johan which I'm still investigating and will update this PR soon.

Hi @jaikiran,

I looked at the `snprintf` issue, the easiest way of fixing this is this:

```c++
{
    char* name = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
  int bytes_required = snprintf(name, nbytes, "%s/%d", dirname, pid);
  if (bytes_required >= nbytes) {
    // Our output was truncated
    FREE_C_HEAP_ARRAY(name);
    nbytes = bytes_required;
    name = NEW_C_HEAP_ARRAY(char, nbytes, mtInternal);
    bytes_required = snprintf(name, nbytes, "%s/%d", dirname, pid);
    assert(bytes_required < nbytes, "must be");
    }
}
}

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17104#issuecomment-1953095597


More information about the serviceability-dev mailing list