-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbug_20180724.txt
565 lines (456 loc) · 14.5 KB
/
bug_20180724.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
* run scimark.lua faild
Lua.exe: scimark.lua:95: malformed number near '0x7fffffff'
https://github.com/weimingtom/KuukoBack/blob/master/kuuko/test/scimark/scimark.lua
solve:
(a)
llimits.h
- public static byte cast_uchar(object i) { return (byte)(i); } //FIXME:???remove?
+ public static byte cast_uchar(object i) {
+ if (i is char)
+ {
+ return (byte)(((char)i) & 0xff);
+ }
+ else
+ {
+ return (byte)((int)i & 0xff);
+ }
+ } //FIXME:???remove?
----------->>>>>
public static byte cast_uchar(object i) {
if (i is char)
{
return (byte)(((char)i) & 0xff);
}
else
{
return (byte)((int)i & 0xff);
}
} //FIXME:???remove?
(b)
lobject.c
}
- //#if !defined(lua_strx2number)
+// #if !defined(lua_strx2number)
- //#include <math.h>
+// #include <math.h>
- //private static int isneg (const char **s) {
- // if (**s == '-') { (*s)++; return 1; }
- // else if (**s == '+') (*s)++;
- // return 0;
- //}
+ private static int isneg (ref CharPtr s) {
+ if (s[0] == '-') { s.inc(); return 1; }
+ else if (s[0] == '+') s.inc();
+ return 0;
+ }
- //private static lua_Number readhexa (const char **s, lua_Number r, int *count) {
- // for (; lisxdigit(cast_uchar(**s)); (*s)++) { /* read integer part */
- // r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(**s)));
- // (*count)++;
- // }
- // return r;
- //}
+ private static lua_Number readhexa (ref CharPtr s, lua_Number r, ref int count) {
+ for (; lisxdigit(cast_uchar(s[0])) != 0; s.inc()) { /* read integer part */
+ r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(s[0])));
+ count++;
+ }
+ return r;
+ }
/*
** convert an hexadecimal numeric string to a number, following
** C99 specification for 'strtod'
*/
-// private static lua_Number lua_strx2number (const char *s, char **endptr) {
-// lua_Number r = 0.0;
-// int e = 0, i = 0;
-// int neg = 0; /* 1 if number is negative */
-// *endptr = cast(char *, s); /* nothing is valid yet */
-// while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */
-// neg = isneg(&s); /* check signal */
-// if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */
-// return 0.0; /* invalid format (no '0x') */
-// s += 2; /* skip '0x' */
-// r = readhexa(&s, r, &i); /* read integer part */
-// if (*s == '.') {
-// s++; /* skip dot */
-// r = readhexa(&s, r, &e); /* read fractional part */
-// }
-// if (i == 0 && e == 0)
-// return 0.0; /* invalid format (no digit) */
-// e *= -4; /* each fractional digit divides value by 2^-4 */
-// *endptr = cast(char *, s); /* valid up to here */
-// if (*s == 'p' || *s == 'P') { /* exponent part? */
-// int exp1 = 0;
-// int neg1;
-// s++; /* skip 'p' */
-// neg1 = isneg(&s); /* signal */
-// if (!lisdigit(cast_uchar(*s)))
-// goto ret; /* must have at least one digit */
-// while (lisdigit(cast_uchar(*s))) /* read exponent */
-// exp1 = exp1 * 10 + *(s++) - '0';
-// if (neg1) exp1 = -exp1;
-// e += exp1;
-// }
-// *endptr = cast(char *, s); /* valid up to here */
-// ret:
-// if (neg) r = -r;
-// return ldexp(r, e);
-// }
-//
+ private static lua_Number lua_strx2number (CharPtr s, out CharPtr endptr) {
+ lua_Number r = 0.0;
+ int e = 0, i = 0;
+ int neg = 0; /* 1 if number is negative */
+ endptr = (CharPtr)(s); /* nothing is valid yet */
+ while (lisspace(cast_uchar(s[0])) != 0) s.inc(); /* skip initial spaces */
+ neg = isneg(ref s); /* check signal */
+ if (!(s[0] == '0' && (s[0 + 1] == 'x' || s[0 + 1] == 'X'))) /* check '0x' */
+ return 0.0; /* invalid format (no '0x') */
+ s += 2; /* skip '0x' */
+ r = readhexa(ref s, r, ref i); /* read integer part */
+ if (s[0] == '.') {
+ s.inc(); /* skip dot */
+ r = readhexa(ref s, r, ref e); /* read fractional part */
+ }
+ if (i == 0 && e == 0)
+ return 0.0; /* invalid format (no digit) */
+ e *= -4; /* each fractional digit divides value by 2^-4 */
+ endptr = (CharPtr)(s); /* valid up to here */
+ if (s[0] == 'p' || s[0] == 'P') { /* exponent part? */
+ int exp1 = 0;
+ int neg1;
+ s.inc(); /* skip 'p' */
+ neg1 = isneg(ref s); /* signal */
+ if (0 == lisdigit(cast_uchar(s[0])))
+ goto ret; /* must have at least one digit */
+ while (lisdigit(cast_uchar(s[0])) != 0) { /* read exponent */
+ exp1 = exp1 * 10 + s[0] - '0'; s.inc();
+ }
+ if (neg1 != 0) exp1 = -exp1;
+ e += exp1;
+ }
+ endptr = (CharPtr)(s); /* valid up to here */
+ ret:
+ if (neg != 0) r = -r;
+ return ldexp(r, e);
+ }
+
// #endif
------->>>>>
// #if !defined(lua_strx2number)
// #include <math.h>
private static int isneg (ref CharPtr s) {
if (s[0] == '-') { s.inc(); return 1; }
else if (s[0] == '+') s.inc();
return 0;
}
private static lua_Number readhexa (ref CharPtr s, lua_Number r, ref int count) {
for (; lisxdigit(cast_uchar(s[0])) != 0; s.inc()) { /* read integer part */
r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(s[0])));
count++;
}
return r;
}
/*
** convert an hexadecimal numeric string to a number, following
** C99 specification for 'strtod'
*/
private static lua_Number lua_strx2number (CharPtr s, out CharPtr endptr) {
lua_Number r = 0.0;
int e = 0, i = 0;
int neg = 0; /* 1 if number is negative */
endptr = (CharPtr)(s); /* nothing is valid yet */
while (lisspace(cast_uchar(s[0])) != 0) s.inc(); /* skip initial spaces */
neg = isneg(ref s); /* check signal */
if (!(s[0] == '0' && (s[0 + 1] == 'x' || s[0 + 1] == 'X'))) /* check '0x' */
return 0.0; /* invalid format (no '0x') */
s += 2; /* skip '0x' */
r = readhexa(ref s, r, ref i); /* read integer part */
if (s[0] == '.') {
s.inc(); /* skip dot */
r = readhexa(ref s, r, ref e); /* read fractional part */
}
if (i == 0 && e == 0)
return 0.0; /* invalid format (no digit) */
e *= -4; /* each fractional digit divides value by 2^-4 */
endptr = (CharPtr)(s); /* valid up to here */
if (s[0] == 'p' || s[0] == 'P') { /* exponent part? */
int exp1 = 0;
int neg1;
s.inc(); /* skip 'p' */
neg1 = isneg(ref s); /* signal */
if (0 == lisdigit(cast_uchar(s[0])))
goto ret; /* must have at least one digit */
while (lisdigit(cast_uchar(s[0])) != 0) { /* read exponent */
exp1 = exp1 * 10 + s[0] - '0'; s.inc();
}
if (neg1 != 0) exp1 = -exp1;
e += exp1;
}
endptr = (CharPtr)(s); /* valid up to here */
ret:
if (neg != 0) r = -r;
return ldexp(r, e);
}
// #endif
----------->>>>>>>>>>>>
r = (r * 16.0) + cast_num(luaO_hexavalue(s[0] & 0xff));
->
r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(s[0]))); s.inc();
(c)
ltablib.c
public static int luaopen_table (lua_State L) {
luaL_newlib(L, tab_funcs);
-#if LUA_COMPAT_UNPACK
+//#if LUA_COMPAT_UNPACK
/* _G.unpack = table.unpack */
lua_getfield(L, -1, "unpack");
lua_setglobal(L, "unpack");
-#endif
+//#endif
return 1;
}
}
}
(d)
** provide its own implementation.
*/
public static double lua_str2number(CharPtr s, out CharPtr p) { return strtod(s, out p); }
//#if defined(LUA_USE_STRTODHEX)
- public static double lua_strx2number(CharPtr s, out CharPtr p) { return strtod(s, out p); }
+// public static double lua_strx2number(CharPtr s, out CharPtr p) { return strtod(s, out p); }
//#endif
/*
@@ The luai_num* macros define the primitive operations over numbers.
--------------------
(e) (for 5.2.0-beta) Error: FFT data length is not a power of 2
> return 3 == 4
true
public static int GETARG_A(Instruction i)
{
solve:
case OpCode.OP_EQ: {
TValue rb = RKB(L, base_, i, k);
TValue rc = RKC(L, base_, i, k);
//Protect(
if ((int)(equalobj(L, rb, rc)?1:0) == GETARG_A(i))
---->
if ((equalobj(L, rb, rc)?1:0) != GETARG_A(i))
------------------
(f) for lua 5.2.0 alpha
private static void new_localvar (LexState ls, TString name) {
FuncState fs = ls.fs;
Varlist is struct, not effect------> Varlist vl = ls.varl;
int reg = registerlocalvar(ls, name);
checklimit(fs, vl.nactvar + 1 - fs.firstlocal,
MAXVARS, "local variables");
luaM_growvector<vardesc>(ls.L, ref vl.actvar, vl.nactvar + 1,
ref vl.actvarsize/*, vardesc*/, Int32.MaxValue, "local variables");
vl.actvar[vl.nactvar++].idx = (ushort)(reg);
solve:
struct Varlist {
->
class Varlist {
(g) for lua 5.2.0 alpha
public static int luaO_str2d (CharPtr s, out lua_Number result) {
CharPtr endptr;
result = lua_str2number(s, out endptr);
if (checkend(s, endptr)!=0) return 1; /* conversion OK? */
----------> result = cast_num(strtoul(s, out endptr, 0)); /* try hexadecimal */
return checkend(s, endptr);
}
strtoul(s, out endptr, 0 <------if base is 0, calc base
solve:
public static ulong strtoul(CharPtr s, out CharPtr end, int base_)
{
bool is_base_zero = false;
if (base_ == 0)
{
is_base_zero = true;
base_ = 10;
}
try
{
end = new CharPtr(s.chars, s.index);
// skip over any leading whitespace
while (end[0] == ' ')
end = end.next();
// ignore any leading 0x
if ((end[0] == '0') && (end[1] == 'x')) {
end = end.next().next();
if (is_base_zero) base_ = 16;
} else if ((end[0] == '0') && (end[1] == 'X')) {
end = end.next().next();
if (is_base_zero) base_ = 16;
}
// do we have a leading + or - sign?
bool negate = false;
if (end[0] == '+')
end = end.next();
else if (end[0] == '-')
{
negate = true;
end = end.next();
}
// loop through all chars
bool invalid = false;
bool had_digits = false;
ulong result = 0;
while (true)
{
// get this char
char ch = end[0];
// which digit is this?
int this_digit = 0;
if (isdigit(ch))
this_digit = ch - '0';
else if (isalpha(ch))
this_digit = tolower(ch) - 'a' + 10;
else
break;
// is this digit valid?
if (this_digit >= base_)
invalid = true;
else
{
had_digits = true;
result = result * (ulong)base_ + (ulong)this_digit;
}
end = end.next();
}
// were any of the digits invalid?
if (invalid || (!had_digits))
{
end = s;
return System.UInt64.MaxValue;
}
// if the value was a negative then negate it here
if (negate)
result = (ulong)-(long)result;
// ok, we're done
return (ulong)result;
}
catch
{
end = s;
return 0;
}
}
----
solve 2:
public static lua_Number cast_num(bool i) { return i ? (lua_Number)1 : (lua_Number)0; }
+ public static lua_Number cast_num(ulong i) { return (lua_Number)i; }
(h) for lua-5.2.0-20100206
public static Closure luaF_newLclosure (lua_State L, int n, Table e) {
Closure c = luaC_newobj<Closure>(L, LUA_TFUNCTION, sizeLclosure(n), null, 0).cl;
c.l.isC = 0;
c.l.env = e;
c.l.nupvalues = cast_byte(n);
c.l.upvals = new UpVal[n];
for (int i = 0; i < n; i++)
c.l.upvals[i] = new UpVal(); //FIXME:???
n over upvals[]----------> while (n > 0) c.l.upvals[n] = null;
return c;
}
solve:
public static Closure luaF_newLclosure (lua_State L, Proto p) {
int n = p.sizeupvalues;
Closure c = luaC_newobj<Closure>(L, LUA_TFUNCTION, sizeLclosure(n), null, 0).cl;
c.l.isC = 0;
c.l.p = p;
c.l.nupvalues = cast_byte(n);
c.l.upvals = new UpVal[n]; //FIXME:added???
/*
for (int i = 0; i < n; i++) //FIXME:added???
c.l.upvals[i] = new UpVal(); //FIXME:??? //FIXME:added???
while (n > 0) c.l.upvals[n] = null; //FIXME:added??? while (n--) c->l.upvals[n] = NULL;
*/
while (n-- != 0) c.l.upvals[n] = null;
return c;
}
(i) for lua-5.2.0-2007
o is null----------> public static UpVal ngcotouv(GCObject o) {return (UpVal)check_exp((o == null) || (o.gch.tt == LUA_TUPVAL), o.uv); }
solve:
public static UpVal luaF_findupval (lua_State L, StkId level) {
global_State g = G(L);
GCObjectRef pp = new OpenValRef(L);
UpVal p;
UpVal uv;
while ((p = ngcotouv(pp.get())) != null && p.v >= level) {
lua_assert(p.v != p.u.value);
if (p.v == level) { /* found a corresponding upvalue? */
if (isdead(g, obj2gco(p))) /* is it dead? */
changewhite(obj2gco(p)); /* ressurect it */
return p;
}
pp = new NextRef(p);
}
->
public static UpVal luaF_findupval (lua_State L, StkId level) {
global_State g = G(L);
GCObjectRef pp = new OpenValRef(L);
UpVal p;
UpVal uv;
+ while (pp.get() != null && (p = ngcotouv(pp.get())) != null && p.v >= level) {
lua_assert(p.v != p.u.value);
if (p.v == level) { /* found a corresponding upvalue? */
if (isdead(g, obj2gco(p))) /* is it dead? */
changewhite(obj2gco(p)); /* ressurect it */
return p;
}
pp = new NextRef(p);
}
(j) ???? for lua-5.2.0-20090702, lua-5.2.0-20100206
-------------
--(scimark.lua min):
local abs, log, sin, floor = math.abs, math.log, math.sin, math.floor
--local pi, clock = math.pi, os.clock
local format = string.format
--local rand, rand_init
local function printf(...)
io.write(format(...))
end
printf("Hello")
----------------
lua:359: attempt to index global 'io' (a nil value)
stack traceback:
scimark.lua:359: in function 'printf'
scimark.lua:387: in main chunk
[C]: in ?
***maybe BECAUSE multi local equal:***
'local abs, log, sin, floor = math.abs, math.log, math.sin, math.floor'
'local abs = math.abs' is good
solve:
put '...cl = clvalue(ci.func).l;...' into '}'
avoid unreach code
}
+ /* function changed (call/return): update pointers */
+ lua_assert(ci == L.ci);
+ cl = clvalue(ci.func).l;
+ k = cl.p.k;
+ base_ = ci.u.l.base_;
}
- /* function changed (call/return): update pointers */
- lua_assert(ci == L.ci); //FIXME: unreachable here
- cl = clvalue(ci.func).l;
- k = cl.p.k;
- base_ = ci.u.l.base_;
}
workaround: (for lua-5.2.0-20100206)
function darray(n) return {} end
->
function darray() return {} end
----------------------
(y) lua-5.1.4
(y) lua-5.1.5
(y) lua-5.2.0-2007
(y) lua-5.2.0-20071029
(y) lua-5.2.0-2008
(y) lua-5.2.0-2009
(y) lua-5.2.0-20090702
(???) lua-5.2.0-20100206
(y) lua-5.2.0-alpha
(y) lua-5.2.0-beta
(y) lua-5.2.0
----------------------