RFR: 8268361: Fix the infinite loop in next_line [v2]

Severin Gehwolf sgehwolf at openjdk.java.net
Wed Jun 9 07:32:15 UTC 2021


On Tue, 8 Jun 2021 16:43:14 GMT, UncleNine <github.com+1964054+UncleNine at openjdk.org> wrote:

>> In my case,  it happened in the container environment.
>> the /proc filesystem of the container is provided by  lxcfs, but a lxcfs bug may make the /proc/stat mount point change, then  the file descriptor is different and fgetc function returns an EOF on error,  But c != '\n' is true and it leads to the  infinit loop.
>> Below are our flamegraph in the production , it happends on serveral frameworks(micrometer, elasticsearch..)which use the api "sun/management/OperatingSystemImpl.getSystemCpuLoad"
>> ![107140246-bb490f80-695b-11eb-9f62-0116079f4f4a](https://user-images.githubusercontent.com/1964054/121218982-d5690f00-c8b5-11eb-8c1e-e39f2f2bc6a5.jpg)
>
> I use  top -Hp $PID command and the thread show 100% cpu usage
> ![top](https://user-images.githubusercontent.com/1964054/121224786-7ad2b180-c8bb-11eb-8c1b-e32b131d4327.png)
> ![jtack](https://user-images.githubusercontent.com/1964054/121224813-81612900-c8bb-11eb-80e1-29d15989dc17.png)

@UncleNine We should handle the case in the `get_totalticks()` function - which seems to be the only user of `next_line()` - when `next_line()` returns EOF as David said. One way would be to return the 'c' character read in `next_line` and if it's EOF, return -2 in `get_totalticks()`.

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

PR: https://git.openjdk.java.net/jdk/pull/4378


More information about the serviceability-dev mailing list