PING: RFR(S): 8240360: NativeLibraryEvent has wrong library name on Linux
Langer, Christoph
christoph.langer at sap.com
Tue Apr 7 06:17:03 UTC 2020
Hi Denghui,
I think your fix is good.
Best regards
Christoph
> -----Original Message-----
> From: hotspot-runtime-dev <hotspot-runtime-dev-
> bounces at openjdk.java.net> On Behalf Of Denghui Dong
> Sent: Dienstag, 31. März 2020 12:02
> To: hotspot-jfr-dev <hotspot-jfr-dev at openjdk.java.net>; hotspot-runtime-
> dev at openjdk.java.net; hotspot-dev at openjdk.java.net
> Subject: Re: PING: RFR(S): 8240360: NativeLibraryEvent has wrong library
> name on Linux
>
> Hi,
>
> Could anyone review it, need one more reviewer.
>
> Webrev: http://cr.openjdk.java.net/~ddong/8240360/webrev.01/
> JBS: https://bugs.openjdk.java.net/browse/JDK-8240360
>
>
> Thanks
> Denghui
>
>
> ------------------------------------------------------------------
> From:董登辉(卓昂) <denghui.ddh at alibaba-inc.com>
> Send Time:2020年3月23日(星期一) 21:26
> To:hotspot-jfr-dev <hotspot-jfr-dev at openjdk.java.net>; Yasumasa Suenaga
> <suenaga at oss.nttdata.com>
> Subject:Re: PING: RFR(S): 8240360: NativeLibraryEvent has wrong library
> name on Linux
>
> Thank you Yasumasa.
>
> Can I get one more reviewer please?
>
> Cheers,
> Denghui Dong
> ------------------------------------------------------------------
> From:Yasumasa Suenaga <suenaga at oss.nttdata.com>
> Send Time:2020年3月23日(星期一) 20:25
> To:董登辉(卓昂) <denghui.ddh at alibaba-inc.com>; hotspot-jfr-dev
> <hotspot-jfr-dev at openjdk.java.net>
> Subject:Re: PING: RFR(S): 8240360: NativeLibraryEvent has wrong library
> name on Linux
>
> Hi Denghui,
>
> On 2020/03/23 18:08, Denghui Dong wrote:
> > Hi Yasumasa,
> >
> > Thanks for the review.
> >
> > I agree with you that it's necessary to filter those lines in which the file is
> not a shared object by check the exec bit.
> > I think we should create another bug to trace the problem that you
> mentioned.
>
> I filed it:
> https://bugs.openjdk.java.net/browse/JDK-8241439
>
> I think we might use dl_iterate_phdr() for the fix. I will try it.
>
>
> > BTW, Could you sponsor it?
>
> Sure, but you need to get one more reviewer before pushing.
>
>
> Thanks,
>
> Yasumasa
>
>
> > Thanks,
> > Denghui Dong
> >
> > ------------------------------------------------------------------
> > From:Yasumasa Suenaga <suenaga at oss.nttdata.com>
> > Send Time:2020年3月23日(星期一) 16:31
> > To:董登辉(卓昂) <denghui.ddh at alibaba-inc.com>; hotspot-jfr-dev
> <hotspot-jfr-dev at openjdk.java.net>
> > Subject:Re: PING: RFR(S): 8240360: NativeLibraryEvent has wrong library
> name on Linux
> >
> > Hi Denghui,
> >
> > Your change looks good.
> >
> > However, we might need to update os::get_loaded_modules_info()
> more.
> > Currently, we would get multiple jdk.NativeLibrary events from 1 library
> as below:
> >
> > ```
> > jdk.NativeLibrary {
> > startTime = 16:59:06.621
> > name = "/usr/lib64/libc-2.30.so"
> > baseAddress = 0x7FDB06ACC000
> > topAddress = 0x7FDB06AF1000
> > }
> >
> > jdk.NativeLibrary {
> > startTime = 16:59:06.621
> > name = "/usr/lib64/libc-2.30.so"
> > baseAddress = 0x7FDB06AF1000
> > topAddress = 0x7FDB06C40000
> > }
> >
> > :
> >
> > ```
> >
> > In addition, we would get the events even if they are not shared library
> as below:
> >
> > ```
> > jdk.NativeLibrary {
> > startTime = 16:59:06.621
> > name = "/home/ysuenaga/OpenJDK/jdk/build/linux-x86_64-server-
> fastdebug/images/jdk/lib/server/cl
> > asses.jsa"
> > baseAddress = 0x800000000
> > topAddress = 0x800007000
> > }
> > ```
> >
> > os::get_loaded_modules_info() has introduced in JDK-8056242, and it
> says this function is for dll/so/dylibs.
> > In fact, os::get_loaded_modules_info() uses EnumProcessModules() in
> Windows.
> >
> > So I think we need to check exec bit, and merge same library to one
> event.
> > But I think it is another issue, and I'm not sure my think is correct.
> >
> > Thus I agree with your change now.
> >
> >
> > Thanks,
> >
> > Yasumasa (ysuenaga)
> >
> >
> > On 2020/03/20 11:12, Denghui Dong wrote:
> > > PING: Could you review it?
> > >
> > > Webrev: http://cr.openjdk.java.net/~ddong/8240360/webrev.01/
> > > JBS: https://bugs.openjdk.java.net/browse/JDK-8240360
> > >
> > > In Linux, EventNativeLibrary has a wrong name if the target library is
> located in a device whose device number (major or minor) exceeds the
> range of two digits.
> > >
> > > My fix is small, use "%*s" to ignore perms, offset and device.
> > >
> > > --- old/src/hotspot/os/linux/os_linux.cpp 2020-03-10
> 14:35:41.224134041 +0800
> > > +++ new/src/hotspot/os/linux/os_linux.cpp 2020-03-10
> 14:35:41.090129104 +0800
> > > @@ -2078,20 +2078,18 @@
> > >
> > > // Read line by line from 'file'
> > > while (fgets(line, sizeof(line), procmapsFile) != NULL) {
> > > - u8 base, top, offset, inode;
> > > - char permissions[5];
> > > - char device[6];
> > > + u8 base, top, inode;
> > > char name[sizeof(line)];
> > >
> > > - // Parse fields from line
> > > - int matches = sscanf(line, UINT64_FORMAT_X "-"
> UINT64_FORMAT_X " %4s " UINT64_FORMAT_X " %5s " INT64_FORMAT "
> %s",
> > > - &base, &top, permissions, &offset, device, &inode, name);
> > > - // the last entry 'name' is empty for some entries, so we might
> have 6 matches instead of 7 for some lines
> > > - if (matches < 6) continue;
> > > - if (matches == 6) name[0] = '\0';
> > > + // Parse fields from line, discard perms, offset and device
> > > + int matches = sscanf(line, UINT64_FORMAT_X "-"
> UINT64_FORMAT_X " %*s %*s %*s " INT64_FORMAT " %s",
> > > + &base, &top, &inode, name);
> > > + // the last entry 'name' is empty for some entries, so we might
> have 3 matches instead of 4 for some lines
> > > + if (matches < 3) continue;
> > > + if (matches == 3) name[0] = '\0';
> > >
> > > - // Filter by device id '00:00' so that we only get file system mapped
> files.
> > > - if (strcmp(device, "00:00") != 0) {
> > > + // Filter by inode 0 so that we only get file system mapped files.
> > > + if (inode != 0) {
> > >
> > > // Call callback with the fields of interest
> > > if(callback(name, (address)base, (address)top, param)) {
> > >
> > >
> > > Thanks,
> > > Denghui Dong
> > >
> > >
> > >
> > > ------------------------------------------------------------------
> > > From:董登辉(卓昂) <denghui.ddh at alibaba-inc.com>
> > > Send Time:2020年3月10日(星期二) 14:16
> > > To:hotspot-jfr-dev <hotspot-jfr-dev at openjdk.java.net>
> > > Subject:Re: RFR(S): 8240360: NativeLibraryEvent has wrong library
> name on Linux
> > >
> > > Hi,
> > > I used a new way to fix this problem.
> > > Ignore "perms", "offset" and "device" fields by "%*s" so that we don't
> need to be concerned about the length of the device,
> > > and use "inode" instead of "device" for filtering.
> > >
> > > Webrev: http://cr.openjdk.java.net/~ddong/8240360/webrev.01/
> > >
> > > Could you review it?
> > >
> > > Thanks,
> > > Denghui Dong
> > > ------------------------------------------------------------------
> > > From:董登辉(卓昂) <denghui.ddh at alibaba-inc.com>
> > > Send Time:2020年3月4日(星期三) 12:05
> > > To:hotspot-jfr-dev <hotspot-jfr-dev at openjdk.java.net>
> > > Subject:Re: RFR(S): 8240360: NativeLibraryEvent has wrong library
> name on Linux
> > >
> > > Testing: jdk/jfr all passed.
> > > ------------------------------------------------------------------
> > > From:董登辉(卓昂) <denghui.ddh at alibaba-inc.com>
> > > Send Time:2020年3月3日(星期二) 22:25
> > > To:hotspot-jfr-dev <hotspot-jfr-dev at openjdk.java.net>
> > > Subject:RFR(S): 8240360: NativeLibraryEvent has wrong library name on
> Linux
> > >
> > > Hi team,
> > >
> > > I found TestNativeLibrariesEvent is always failed in my Linux
> environment.
> > >
> > > The root cause is that os::get_loaded_modules_info in os_linux.cpp
> can not read library name correctly,
> > > because the device number in my Linux environment is 103:01, the
> format passed to sscanf can't identify
> > > it.
> > >
> > > I found the limit of major and minor device number in Linux from
> > >
> https://github.com/torvalds/linux/blob/master/include/linux/kdev_t.h, and
> made this patch.
> > >
> > > Please review this small change that fixes this problem.
> > >
> > > Bug: https://bugs.openjdk.java.net/browse/JDK-8240360
> > > Webrev: http://cr.openjdk.java.net/~ddong/8240360/webrev.00/
> > >
> > >
> > > Thanks
> > > Denghui Dong
> > >
> >
More information about the hotspot-jfr-dev
mailing list