WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
235348
[JSC] Fix YarrJIT backtrackCharacterClassNonGreedy breakpoint
https://bugs.webkit.org/show_bug.cgi?id=235348
Summary
[JSC] Fix YarrJIT backtrackCharacterClassNonGreedy breakpoint
Yusuke Suzuki
Reported
2022-01-18 22:51:23 PST
[JSC] Fix YarrJIT backtrackCharacterClassNonGreedy breakpoint
Attachments
Patch
(2.81 KB, patch)
2022-01-18 22:57 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Yusuke Suzuki
Comment 1
2022-01-18 22:57:59 PST
Created
attachment 449465
[details]
Patch
Yusuke Suzuki
Comment 2
2022-01-18 22:58:18 PST
rdar://84108897
Darin Adler
Comment 3
2022-01-19 08:53:13 PST
Comment on
attachment 449465
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=449465&action=review
> Source/JavaScriptCore/yarr/YarrJIT.cpp:2062 > + m_jit.sub32(MacroAssembler::TrustedImm32(1), m_regs.index);
Do we need anything different in the m_decodeSurrogatePairs case? In that case it might be incremented my more than one?
Yusuke Suzuki
Comment 4
2022-01-19 09:37:09 PST
Comment on
attachment 449465
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=449465&action=review
>> Source/JavaScriptCore/yarr/YarrJIT.cpp:2062 >> + m_jit.sub32(MacroAssembler::TrustedImm32(1), m_regs.index); > > Do we need anything different in the m_decodeSurrogatePairs case? In that case it might be incremented my more than one?
nonGreedyFailuresDecrementIndex is added only when m_decodeSurrogatePairs is true. So, this path will be taken only when m_decodeSurrogatePairs is true case. (nonGreedyFailuresDecrementIndex is added in L2052, which is executed when m_decodeSurrogatePairs is true).
Darin Adler
Comment 5
2022-01-19 09:46:00 PST
Comment on
attachment 449465
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=449465&action=review
>>> Source/JavaScriptCore/yarr/YarrJIT.cpp:2062 >>> + m_jit.sub32(MacroAssembler::TrustedImm32(1), m_regs.index); >> >> Do we need anything different in the m_decodeSurrogatePairs case? In that case it might be incremented my more than one? > > nonGreedyFailuresDecrementIndex is added only when m_decodeSurrogatePairs is true. So, this path will be taken only when m_decodeSurrogatePairs is true case. (nonGreedyFailuresDecrementIndex is added in L2052, which is executed when m_decodeSurrogatePairs is true).
OK, maybe I can’t review then, because I can’t spot the add32 that this subtract is reversing, so I suppose you need a review from a subject matter expert. Sorry, I was hoping I could save a little time by being your reviewer!
Yusuke Suzuki
Comment 6
2022-01-19 10:39:20 PST
Comment on
attachment 449465
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=449465&action=review
>>>> Source/JavaScriptCore/yarr/YarrJIT.cpp:2062 >>>> + m_jit.sub32(MacroAssembler::TrustedImm32(1), m_regs.index); >>> >>> Do we need anything different in the m_decodeSurrogatePairs case? In that case it might be incremented my more than one? >> >> nonGreedyFailuresDecrementIndex is added only when m_decodeSurrogatePairs is true. So, this path will be taken only when m_decodeSurrogatePairs is true case. (nonGreedyFailuresDecrementIndex is added in L2052, which is executed when m_decodeSurrogatePairs is true). > > OK, maybe I can’t review then, because I can’t spot the add32 that this subtract is reversing, so I suppose you need a review from a subject matter expert. Sorry, I was hoping I could save a little time by being your reviewer!
np!!!!! Thank you for your review :D
Michael Saboff
Comment 7
2022-01-19 11:22:46 PST
Comment on
attachment 449465
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=449465&action=review
r=me
>>>>> Source/JavaScriptCore/yarr/YarrJIT.cpp:2062 >>>>> + m_jit.sub32(MacroAssembler::TrustedImm32(1), m_regs.index); >>>> >>>> Do we need anything different in the m_decodeSurrogatePairs case? In that case it might be incremented my more than one? >>> >>> nonGreedyFailuresDecrementIndex is added only when m_decodeSurrogatePairs is true. So, this path will be taken only when m_decodeSurrogatePairs is true case. (nonGreedyFailuresDecrementIndex is added in L2052, which is executed when m_decodeSurrogatePairs is true). >> >> OK, maybe I can’t review then, because I can’t spot the add32 that this subtract is reversing, so I suppose you need a review from a subject matter expert. Sorry, I was hoping I could save a little time by being your reviewer! > > np!!!!! Thank you for your review :D
This is safe and appropriate because we only get in this case when the following is true (from reading L2050-2063 and L516-520): 1) We are in the m_decodeSurrogatePairs case. 2) We are trying to match a non-BMP character. 3) We are at the end of the string input with the first of the two characters, i.e. we have incremented 1. 4) There we can't advance the index for the second character we can't read. Therefore we need to decrement index by 1 and fall through to the failed non-greedy match.
Yusuke Suzuki
Comment 8
2022-01-19 11:27:12 PST
Comment on
attachment 449465
[details]
Patch Thanks!
EWS
Comment 9
2022-01-19 11:53:50 PST
Committed
r288224
(
246184@main
): <
https://commits.webkit.org/246184@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 449465
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug