On Thu, 15 Jan 2026 04:24:24 GMT, Volodymyr Paprotski <[email protected]> 
wrote:

> Failure always for UU case, needle=2, len=17 
>  - (Note: `len=len-offset` in `library_call.cpp`, ie. stub does not see the 
> same len as the test case)
> 
> Following down the code layout:
> 
> if len==0
>     return 0
> if len>needle
>     return -1
> if len<=16|32 && needle<=3|6
>     optimized_short_cases
> if len>16|32
>     // big switch
>     switch(needle) {
>         default >10
>         cases 2..10 // BUG IS HERE: len 17|34, needle 2|4, case=4
>     }
> else
>     // small switch
>     switch(needle) {
>         cases 7..10
>         // others under optimized_short_cases
>     }
> 
> Furthermore.. big switch case itself has two cases..
> 
> if len-needle>31
>     // works
>     // loop
> else //  len-needle<=31
>     // BUG HERE
> 
> The else case corrects mask misalignment; the 'correction shift' is off-by-1 
> for the UTF16 case.
> 
> -----
> Why not found before?
> - testcase issue, needle was UTF8 for UTF16 case
> 
> Why only needle==2?
> - Possibly because the mask for words has two bits, so tolerated off-by-one

Looks good to me but @jatin-bhateja should have a look as well.

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

Marked as reviewed by thartmann (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29242#pullrequestreview-3665370816

Reply via email to