-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug_20170911.txt
More file actions
444 lines (376 loc) · 10.8 KB
/
bug_20170911.txt
File metadata and controls
444 lines (376 loc) · 10.8 KB
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
(1) return 0
lua-5.2.0 fixed
GetUnmanagedSize
...
+ else if (t == typeof(lua_Number))
+ return 8;
----------------------
(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 <---
(y) lua-5.2.0-20100206
(y) lua-5.2.0-alpha
(y) lua-5.2.0-beta
(y) lua-5.2.0
----------------------
(2) log
lua-5.2.0 fixed
static void print_version() {
Lua.luai_writestring(Lua.LUA_COPYRIGHT, (uint)Lua.strlen(Lua.LUA_COPYRIGHT)); //FIXME:changed, (uint)
Lua.luai_writeline();
+ Lua.WriteLog(">>>>print_version");
}
static int loadline(Lua.lua_State L) {
int status;
Lua.lua_settop(L, 0);
if (pushline(L, 1)==0)
return -1; /* no input */
for (;;) { /* repeat until gets a complete line */
uint l;
Lua.CharPtr line = Lua.lua_tolstring(L, 1, out l);
+ Lua.WriteLog(line.ToString());
+ public static void WriteLog(string strLog)
{
string sFileName = "log_" + DateTime.Now.ToString("yyyy-MM-dd") + ".log";
FileMode mode = File.Exists(sFileName) ? FileMode.Append : FileMode.Create;
using (FileStream fs = new FileStream(sFileName, mode, FileAccess.Write))
{
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + " --- " + strLog);
}
}
}
----------------------
(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 <---------????
(y) lua-5.2.0-20100206
(y) lua-5.2.0-alpha
(y) lua-5.2.0-beta
(y) lua-5.2.0
----------------------
(3) a = "hello"..nil
a = ""..nil
lua-5.2.0 pending
dotty dotty not work, not LUAI_THROW (LuaException)
luaL_traceback throw exception (see (6))
another bugs:
<lua-5.2.0-20090702>
private static void traversestack (global_State g, lua_State L) {
StkId o;
if (L.stack == null)
return; /* stack not completely built yet */
markvalue(g, gt(L)); /* mark global table */
****lua_TValue.inc(ref o) : System.IndexOutOfRangeException: ---------------> for (o = new lua_TValue(L.stack); o < L.top; lua_TValue.inc(ref o)) //FIXME:L.stack->new StkId(L.stack[0])
markvalue(g, o);
if (g.gcstate == GCSatomic) { /* final traversal? */
for (; o <= L.stack_last; StkId.inc(ref o)) /* clear not-marked stack slice */
setnilvalue(o);
}
}
for (o = new lua_TValue(L.stack); o < L.top; lua_TValue.inc(ref o)) //FIXME:L.stack->new StkId(L.stack[0])
->
for (o = new lua_TValue(L.stack); o < L.top; o = o + 1) //FIXME:L.stack->new StkId(L.stack[0]) //FIXME:don't use lua_TValue.inc(), overflow ([-1])
<lua-5.2.0-2009>
<lua-5.2.0-20090702>
public static uint luaC_separateudata (lua_State L, int all) {
global_State g = G(L);
uint deadmem = 0; /* total size of all objects to be finalized */
GCObjectRef p = new NextRef(g.mainthread);
GCObject curr;
GCObjectRef lastnext = new TobefnzRef(g); //FIXME:??????
/* find last 'next' field in 'tobefnz' list (to insert elements in its end) */
while (lastnext.get() != null) lastnext = new NextRef(gch(lastnext.get()));
while ((curr = p.get()) != null) { /* traverse all finalizable objects */
lua_assert(ttisuserdata(gch(curr)) && !isfinalized(gco2u(curr)));
lua_assert(testbit(gch(curr).marked, SEPARATED));
if (!(all != 0 || iswhite(curr))) /* not being collected? */
****----------> p = new NextRef(gch(curr).next); /* don't bother with it */
else {
l_setbit(ref gch(curr).marked, FINALIZEDBIT); /* won't be finalized again */
deadmem += sizeudata(gco2u(curr));
p.set(gch(curr).next); /* remove 'curr' from 'rootgc' list */
/* link 'curr' at the end of 'tobefnz' list */
gch(curr).next = lastnext.get();
lastnext.set(curr);
lastnext = new NextRef(gch(curr));
}
}
return deadmem;
}
p = new NextRef(gch(curr).next); /* don't bother with it */
->
p = new NextRef(gch(curr)); /* don't bother with it */
----------------------
(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
() lua-5.2.0-2009 <--------???
() lua-5.2.0-20090702 <--------???
(y) lua-5.2.0-20100206
(y) lua-5.2.0-alpha
(y) lua-5.2.0-beta
(y) lua-5.2.0
----------------------
(4)
#if CATCH_EXCEPTIONS
lua-5.2.0 fixed
catch (Exception e)
{
+ Debug.Assert(e is LuaException, "Exception isn't LuaException");
Debug.WriteLine(e); //FIXME:added for debug
----------------------
(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
(y) lua-5.2.0-20100206
(y) lua-5.2.0-alpha
(y) lua-5.2.0-beta
(y) lua-5.2.0
----------------------
(5) retun a
lua-5.2.0 fixed
dotty dotty not work
public void Write(int type, byte[] buffer, int offset, int count)
{
if (type == TYPE_STDOUT)
->
public void Write(int type, byte[] buffer, int offset, int count)
{
if (type == TYPE_STDOUT || type == TYPE_STDERR)
...
if (str.Length > 0)
{
---> if (type == TYPE_STDOUT)
{
UnityEngine.Debug.Log(str);
}
else if (type == TYPE_STDERR)
{
UnityEngine.Debug.LogError(str);
}
}
#else
---> if (type == TYPE_STDOUT)
{
stdout_.Write(buffer, offset, count);
}
else if (type == TYPE_STDERR)
{
stderr_.Write(buffer, offset, count);
}
#endif
----------------------
(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
(y) lua-5.2.0-20100206
(y) lua-5.2.0-alpha
(y) lua-5.2.0-beta
(y) lua-5.2.0
----------------------
(6) exception no traceback ("stack traceback:")
luaL_traceback throw exception
lua-5.2.0 fixed
solve:
base_ci[0] -> base_ci
becuase base_ci is from new CallInfo(), not from luaM_realloc_, so don't use base_ci[0]
>>>>>>>>>>>>>>>>>>>>>> TODO:add detect code for 'values is null' error
------------------
error:
public class CallInfo : ArrayElement
{
private CallInfo[] values = null;
private int index = -1;
public void set_index(int index)
{
this.index = index;
}
public void set_array(object array)
{
this.values = (CallInfo[])array;
Debug.Assert(this.values != null);
}
public CallInfo this[int offset]
{
values is null ---> get { return values[index+offset]; }
}
search in ldo.c.cs, ldebug.c.cs
all base_ci[0] after lua-5.2.0-2009 (see base_ci define in lstate.h.cs)
----------------------
(-) lua-5.1.4
(-) lua-5.1.5
(-) lua-5.2.0-2007
(-) lua-5.2.0-20071029
(-) lua-5.2.0-2008
(-) lua-5.2.0-2009 <--------???
(y) lua-5.2.0-20090702
(y) lua-5.2.0-20100206
(y) lua-5.2.0-alpha
(y) lua-5.2.0-beta
(y) lua-5.2.0
----------------------
(x)(7) seem not bug ???
static Lua.CharPtr progname = LUA_PROGNAME; // <---------------progname is null
lua-5.2.0 fixed(???)
----------------------
(-) lua-5.1.4
(-) lua-5.1.5
(-) lua-5.2.0-2007
(-) lua-5.2.0-20071029
(-) lua-5.2.0-2008
(-) lua-5.2.0-2009
(-) lua-5.2.0-20090702
(-) lua-5.2.0-20100206
(-) lua-5.2.0-alpha
(-) lua-5.2.0-beta
(-) lua-5.2.0
----------------------
(8) sharpdevelop x86 arch
lua-5.2.0 pending
----------------------
(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
(y) lua-5.2.0-20100206
(y) lua-5.2.0-alpha
(y) lua-5.2.0-beta
(y) lua-5.2.0
----------------------
(9) no >> prompt
lua-5.2.0 fixed
example:
Lua 5.2.0 Copyright (C) 1994-2011 Lua.org, PUC-Rio
> print("hello
stdin:1: unfinished string near '"hello'
static Lua.CharPtr get_prompt(Lua.lua_State L, int firstline) {
Lua.CharPtr p;
Lua.lua_getglobal(L, (firstline!=0) ? "_PROMPT" : "_PROMPT2");
p = Lua.lua_tostring(L, -1);
------> if (p == null) p = ((firstline!=0) ? LUA_PROMPT : LUA_PROMPT2);
Lua.lua_pop(L, 1); /* remove global */
return p;
}
static int incomplete(Lua.lua_State L, int status) {
if (status == Lua.LUA_ERRSYNTAX) {
uint lmsg;
Lua.CharPtr msg = Lua.lua_tolstring(L, -1, out lmsg);
if (lmsg >= marklen && Lua.strcmp(msg + lmsg - marklen, EOFMARK) == 0) {
not enter----> Lua.lua_pop(L, 1);
return 1;
}
}
return 0; /* else... */
}
-----------------
solve:
(a)
/*
** add 1 to char to allow index -1 (EOZ)
*/
- public static int testprop(int c, int p) { return luai_ctype_[c+1] & p; }
+ public static int testprop(int c, int p) { if (c == EOZ) {c = -1;} return luai_ctype_[c+1] & p; } //FIXME:added, if (c == EOZ) {c = -1;}
-->done
(b)
private static int llex (LexState ls, SemInfo seminfo) {
luaZ_resetbuffer(ls.buff);
for (;;) {
- switch (ls.current) {
+ switch (ls.current) {
case '\n': case '\r': { /* line breaks */
inclinenumber(ls);
break;
}
case ' ': case '\f': case '\t': case '\v': { /* spaces */
-->???
(c)
- public static int EOF = -1;
+ public static int EOF = 0xffff; //-1; //FIXME:changed
--->done
(d)
fgets
try
{
while (true)
{
str[index] = (char)stream.ReadByte();
- if (str[index] == '\n')
+ if (str[index] == '\r')
+ {
+ str[index] = '\n';
+ }
+ else if (str[index] == '\n')
+ {
+ str[index] = '\0';
break;
- if (str[index] == '\xffff') //Ctrl+Z
+ }
+ else if (str[index] == '\xffff') //Ctrl+Z
+ {
return null;
+ }
if (index >= str.chars.Length)
break;
index++;
}
}
-->done
(e)
- int result = (byte)(z.p[0]); z.p.inc(); return result; //FIXME:changed
+ int result = (int)(z.p[0]); z.p.inc(); return result; //FIXME:changed, (byte)->(int)
}
-->done
-->see here: public static int char2int(char c) { return (int)c; }
(f)
public partial class Lua
{
- public const int EOZ = -1; /* end of stream */
+ public const int EOZ = 0xffff; //-1; /* end of stream */ //FIXME:changed here
public class ZIO : Zio { };
- public static int zgetc(ZIO z) { if (z.n-- > 0) {int ch = (byte)(z.p[0]);z.p.inc();return ch;} else return luaZ_fill(z); }
-
+ public static int zgetc(ZIO z) { if (z.n-- > 0) {int ch = (int)(z.p[0]);z.p.inc();return ch;} else { return luaZ_fill(z); }} //FIXME:(byte)->(int)
+
public class Mbuffer {
public CharPtr buffer = new CharPtr();
public uint n;
public uint buffsize;
};
-->done
----------------------
(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 <-----------no 'int testprop('
(y) lua-5.2.0-20090702
(y) lua-5.2.0-20100206
(y) lua-5.2.0-alpha
(y) lua-5.2.0-beta
(y) lua-5.2.0
----------------------
not done: (9-done) (3-done) (6-done)