<HTML><BODY>Looks good to me and @mraleph: <a href="https://github.com/LuaJIT/LuaJIT/issues/505#issuecomment-528482812">https://github.com/LuaJIT/LuaJIT/issues/505#issuecomment-528482812</a> <br><br><br><br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">
Четверг, 5 сентября 2019, 20:55 +03:00 от Igor Munkin <imun@tarantool.org>:<br>
<br>
<div id="">
<div class="js-helper js-readmsg-msg">
<style type="text/css"></style>
<div>
<div id="style_15677061320253029451_BODY">Fix provided within 587532e leads to invalid end index of the string<br>
being matched while recording<br>
<br>
Test related to this bug is also provided within this changeset<br>
<br>
Relates to: LuaJIT gh-505<br>
Fix: tarantool gh-4476<br>
---<br>
src/lj_ffrecord.c | 4 +-<br>
test/fix_string_find_recording.test.lua | 79 +++++++++++++++++++++++++<br>
2 files changed, 81 insertions(+), 2 deletions(-)<br>
create mode 100755 test/fix_string_find_recording.test.lua<br>
<br>
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c<br>
index 632b8f2..8dfa80e 100644<br>
--- a/src/lj_ffrecord.c<br>
+++ b/src/lj_ffrecord.c<br>
@@ -950,8 +950,8 @@ static void LJ_FASTCALL recff_string_find(jit_State *J, RecordFFData *rd)<br>
TRef pos;<br>
emitir(IRTG(IR_NE, IRT_PGC), tr, trp0);<br>
/* Caveat: can't use STRREF trstr 0 here because that might be pointing into a wrong string due to folding. */<br>
- pos = emitir(IRTI(IR_SUB), tr, trsptr);<br>
- J->base[0] = emitir(IRTI(IR_ADD), pos, emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, 1)));<br>
+ pos = emitir(IRTI(IR_ADD), trstart, emitir(IRTI(IR_SUB), tr, trsptr));<br>
+ J->base[0] = emitir(IRTI(IR_ADD), pos, lj_ir_kint(J, 1));<br>
J->base[1] = emitir(IRTI(IR_ADD), pos, trplen);<br>
rd->nres = 2;<br>
} else {<br>
diff --git a/test/fix_string_find_recording.test.lua b/test/fix_string_find_recording.test.lua<br>
new file mode 100755<br>
index 0000000..d3fc9e1<br>
--- /dev/null<br>
+++ b/test/fix_string_find_recording.test.lua<br>
@@ -0,0 +1,79 @@<br>
+#!/usr/bin/env tarantool<br>
+<br>
+tap = require('tap')<br>
+<br>
+test = tap.test("fix-string-find-recording")<br>
+test:plan(1)<br>
+<br>
+local err = [[module 'kit.1.10.3-136' not found:<br>
+ no field package.preload['kit.1.10.3-136']<br>
+ no file './kit/1/10/3-136.lua'<br>
+ no file './kit/1/10/3-136/init.lua'<br>
+ no file './kit/1/10/3-136.so'<br>
+ no file '/bug/.rocks/share/tarantool/kit/1/10/3-136.lua'<br>
+ no file '/bug/.rocks/share/tarantool/kit/1/10/3-136/init.lua'<br>
+ no file '/.rocks/share/tarantool/kit/1/10/3-136.lua'<br>
+ no file '/.rocks/share/tarantool/kit/1/10/3-136/init.lua'<br>
+ no file '/bug/.rocks/lib/tarantool/kit/1/10/3-136.so'<br>
+ no file '/.rocks/lib/tarantool/kit/1/10/3-136.so'<br>
+ no file '/bug/app/kit/1/10/3-136.lua'<br>
+ no file '/bug/app/kit/1/10/3-136/init.lua'<br>
+ no file '/bug/libs/share/lua/5.1/kit/1/10/3-136.lua'<br>
+ no file '/bug/libs/share/lua/5.1/kit/1/10/3-136/init.lua'<br>
+ no file '/root/.luarocks/share/lua/5.1/kit/1/10/3-136.lua'<br>
+ no file '/root/.luarocks/share/lua/5.1/kit/1/10/3-136/init.lua'<br>
+ no file '/root/.luarocks/share/lua/kit/1/10/3-136.lua'<br>
+ no file '/root/.luarocks/share/lua/kit/1/10/3-136/init.lua'<br>
+ no file '/usr/local/share/tarantool/kit/1/10/3-136.lua'<br>
+ no file '/usr/local/share/tarantool/kit/1/10/3-136/init.lua'<br>
+ no file '/usr/share/tarantool/kit/1/10/3-136.lua'<br>
+ no file '/usr/share/tarantool/kit/1/10/3-136/init.lua'<br>
+ no file '/usr/local/share/lua/5.1/kit/1/10/3-136.lua'<br>
+ no file '/usr/local/share/lua/5.1/kit/1/10/3-136/init.lua'<br>
+ no file '/usr/share/lua/5.1/kit/1/10/3-136.lua'<br>
+ no file '/usr/share/lua/5.1/kit/1/10/3-136/init.lua'<br>
+ no file '/bug/libs/lib/lua/5.1/kit/1/10/3-136.so'<br>
+ no file '/bug/libs/lib/lua/kit/1/10/3-136.so'<br>
+ no file '/bug/libs/lib64/lua/5.1/kit/1/10/3-136.so'<br>
+ no file '/root/.luarocks/lib/lua/5.1/kit/1/10/3-136.so'<br>
+ no file '/root/.luarocks/lib/lua/kit/1/10/3-136.so'<br>
+ no file '/usr/local/lib64/tarantool/kit/1/10/3-136.so'<br>
+ no file '/usr/lib64/tarantool/kit/1/10/3-136.so'<br>
+ no file '/usr/local/lib64/lua/5.1/kit/1/10/3-136.so'<br>
+ no file '/usr/lib64/lua/5.1/kit/1/10/3-136.so'<br>
+ no file '/bug/libs/lib/lua/5.1/kit.so'<br>
+ no file '/bug/libs/lib/lua/kit.so'<br>
+ no file '/bug/libs/lib64/lua/5.1/kit.so'<br>
+ no file '/root/.luarocks/lib/lua/5.1/kit.so'<br>
+ no file '/root/.luarocks/lib/lua/kit.so'<br>
+ no file '/usr/local/lib64/tarantool/kit.so'<br>
+ no file '/usr/lib64/tarantool/kit.so'<br>
+ no file '/usr/local/lib64/lua/5.1/kit.so'<br>
+ no file '/usr/lib64/lua/5.1/kit.so']]<br>
+<br>
+local at, s, e<br>
+local count_vm = 0<br>
+<br>
+jit.off()<br>
+<br>
+repeat<br>
+ s, e = err:find("\n\t", at, true)<br>
+ at = e<br>
+ count_vm = count_vm + 1<br>
+until not e<br>
+<br>
+local count_jit = 0<br>
+<br>
+jit.on()<br>
+jit.opt.start(0, 'hotloop=1')<br>
+<br>
+repeat<br>
+ s, e = err:find("\n\t", at, true)<br>
+ at = e<br>
+ count_jit = count_jit + 1<br>
+ assert(count_jit <= count_vm, "Trace goes in cycles")<br>
+until not e<br>
+<br>
+test:is(count_vm, count_jit)<br>
+<br>
+test:check()<br>
-- <br>
2.22.1<br>
<br>
<br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
<br>-- <br>Sergey Ostanevich<br></BODY></HTML>