RFR(S): 8214773: Replace use of thread unsafe strtok
Baesken, Matthias
matthias.baesken at sap.com
Tue Dec 4 15:44:05 UTC 2018
Hello Nils, the fix looks fine to me .
Btw, , speaking about " thread unsafe functions" - we also still have a number of remaining strerror usages .
Examples :
hotspot :
zErrno.cpp
49 return strerror(_error);
logFileOutput.cpp
251 _file_name, strerror(errno));
jdk :
jdk/src/java.base/unix/native/libjli/java_md_common.c
195 /*
196 * TODO: its safer to use strerror_r but is not available on
197 * Solaris 8. Until then....
198 */
199 emsg = strerror(errno);
For hotspot it would probably make sense to go for os::strerror instead ; not so sure for jdk .
Best regards, Matthias
> Message: 1
> Date: Tue, 4 Dec 2018 22:47:49 +1000
> From: David Holmes <david.holmes at oracle.com>
> To: Nils Eliasson <nils.eliasson at oracle.com>,
> hotspot-dev at openjdk.java.net, hotspot-compiler-
> dev at openjdk.java.net
> Subject: Re: RFR(S): 8214773: Replace use of thread unsafe strtok
> Message-ID: <2bab588c-8e0c-2b14-2314-e803cdcfadf3 at oracle.com>
> Content-Type: text/plain; charset=utf-8; format=flowed
>
> <re-send as the original email addresses are mangled>
>
> Hi Nils,
>
> Can you just define one version in os_posix.cpp and one in os_windows.cpp?
>
> This per-os function really seems like overkill in this case. You could
> just add a Windows specific #define to convert strtok_r to strtok_s.
>
> Thanks,
> David
>
>
> On 4/12/2018 8:01 pm, Nils Eliasson wrote:
> > Hi,
> >
> > Hotspot has a few uses of the thread unsafe strtok function. Most of the
> > them are probably benign since they happen during startup. The use in
> > compilerDirectives however has been reported to cause errors in user
> > applications that also use strtok though jni. (See bug report or mail to
> > compiler list.)
> >
> > In this patch I replace all uses of strtok. The call need to go through
> > the os specific files since windows uses a different function (strtok_s)
> > than the rest of the platforms (strtok_r).
> >
> > Bug: https://bugs.openjdk.java.net/browse/JDK-8214773
> >
> > Webrev: http://cr.openjdk.java.net/~neliasso/8214773/webrev.01/
> >
> > Thanks to Andre Gillet at Nuance who reported the bug.
> >
> > Regards,
> >
> > Nils Eliasson
> >
More information about the hotspot-dev
mailing list