RFR: [8036088] - Thread-unsafe strtok() is used to parse
Chris Hegarty
chris.hegarty at oracle.com
Tue Mar 4 04:43:44 PST 2014
On 4 Mar 2014, at 11:52, Ivan Gerasimov <ivan.gerasimov at oracle.com> wrote:
> VS compiler issues this warning on strtok() usage:
>
> : warning C4996: 'strtok': This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
>
> So, the suggested fix can reduce number of complains from the compiler.
>
> If I had realized that strtok() is thread-safe under Windows, I wouldn't bother anyone with this.
> But as the fix is already prepared, I think it's better push it, even though it adds only a little.
> If you guys are OK with the fix, of course.
The changes seem mostly benign to me. I have no objections to being listed as a reviewer.
-Chris.
>
> Sincerely yours,
> Ivan
>
>
> On 04.03.2014 14:28, Chris Hegarty wrote:
>> On 4 Mar 2014, at 03:25, Ivan Gerasimov <ivan.gerasimov at oracle.com> wrote:
>>
>>> Yes, you're right.
>>> strtok() is thread-safe in Windows unlike its Unix counterpart.
>>>
>>> Thus using strtok_s() only adds some boundary checking in this case.
>> Ivan,
>> Are you now withdrawing this request for review? Or are you suggesting that strtok_s should be used anyway?
>>
>> -Chris.
>>
>>> Sincerely yours,
>>> Ivan
>>>
>>> On 04.03.2014 0:26, Salter, Thomas A wrote:
>>>> strtok is thread-safe in MS C/C++. It uses thread-local store to hold its state. strtok_s can be called recursively to parse different strings, though it's named like the MS extensions that check for buffer overruns.
>>>>
>>>> http://msdn.microsoft.com/en-us/library/2c8d19sb(v=vs.100).aspx
>>>>
>>>> ------------------------------
>>>>
>>>> Message: 5
>>>> Date: Mon, 03 Mar 2014 21:01:15 +0400
>>>> From: Ivan Gerasimov <ivan.gerasimov at oracle.com>
>>>> Subject: Re: RFR: [8036088] - Thread-unsafe strtok() is used to parse
>>>> the list of overrides
>>>> To: Christos Zoulas <christos at zoulas.com>, OpenJDK Network Dev list
>>>> <net-dev at openjdk.java.net>
>>>> Message-ID: <5314B55B.9070406 at oracle.com>
>>>> Content-Type: text/plain; charset=UTF-8; format=flowed
>>>>
>>>> Hi Christos!
>>>>
>>>> On 03.03.2014 20:52, christos at zoulas.com wrote:
>>>>> On Mar 3, 8:32pm, ivan.gerasimov at oracle.com (Ivan Gerasimov) wrote:
>>>>> -- Subject: RFR: [8036088] - Thread-unsafe strtok() is used to parse the list
>>>>>
>>>>> | Hello!
>>>>> |
>>>>> | The strtok() function is used in
>>>>> | ./windows/native/sun/net/spi/DefaultProxySelector.c.
>>>>> | This function is not thread safe, so it may potentially cause a problem.
>>>>> |
>>>>> | The failure in this particular place would be very unlikely, because
>>>>> | this code should be executed only once during initialization.
>>>>> | Therefore, no regtest provided.
>>>>> |
>>>>> | The fix would be to use a thread-safe equivalent, which is strtok_s()
>>>>> | under Windows.
>>>>> |
>>>>> | Would you please help review this simple fix?
>>>>> |
>>>>> | BUGURL: https://bugs.openjdk.java.net/browse/JDK-8036088
>>>>> | WEBREV: http://cr.openjdk.java.net/~igerasim/8036088/0/webrev/
>>>>>
>>>>> Doesn't windows have strtok_r() IEEE Std 1003.1c-1995 (``POSIX.1'').
>>>> MSDN does not refer to strtok_r().
>>>> Grepping the JDK code shows that strtok_s() is used in the
>>>> windows-specific code.
>>>>
>>>> Sincerely yours,
>>>> Ivan
>>>>
>>>>> christos
>>>>>
>>>>>
>>>>
>>>> End of net-dev Digest, Vol 81, Issue 3
>>>> **************************************
>>>>
>>>>
>>
>>
>
More information about the net-dev
mailing list