| Bug #10267 | mysqltest, wrong number of loops when a script is sourced within a loop | ||
|---|---|---|---|
| Submitted: | 29 Apr 2005 16:42 | Modified: | 1 Sep 2005 19:20 |
| Reporter: | Matthias Leich | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Command-line Clients | Severity: | S3 (Non-critical) |
| Version: | 4.1 | OS: | |
| Assigned to: | Magnus Blåudd | CPU Architecture: | Any |
[29 Apr 2005 16:44]
Matthias Leich
sourced test script
Attachment: ml60i.sub (application/octet-stream, text), 53 bytes.
[29 Apr 2005 16:44]
Matthias Leich
test case
Attachment: ml60.test (application/test, text), 881 bytes.
[7 Jul 2005 9:22]
Matthias Leich
I have another testcase with nested scripts within a loop
where mysqltest crashes.
I guess this crash is another representation of this bug.
# Sourcing of files within a while loop.
# include/ml031.inc sources include/ml0311.inc
# The loops are harmless until $num exceeds 8 .
let $num= 9;
while ($num)
{
SELECT 'In loop' AS "";
--source include/ml031.inc
dec $num;
}
GDB: (I hope that I started gdb with the correct options.)
Core was generated by `/home/matthias/Arbeit/mysql-5.0/src-B/client/.libs/lt-mysqltest --no-defaults -'.
Program terminated with signal 11, Segmentation fault.
...
(gdb) bt
#0 0x403860db in getc () from /lib/tls/libc.so.6
#1 0x0804f6b6 in my_getc (file=0x0) at mysqltest.c:2050
#2 0x0804f828 in read_line (buf=0x8068b20 "SELECT 'Leaving include/ml0311.inc' AS \"\"", size=131072)
at mysqltest.c:2098
#3 0x0804fddb in read_query (q_ptr=0xbfffe228) at mysqltest.c:2260
#4 0x08053956 in main (argc=13, argv=0xbfffe2c4) at mysqltest.c:3770
(gdb)
Workaround 1: Alter mysqltest.c from
#define MAX_INCLUDE_DEPTH 16 to 32.
But this is no real bug fix, because the number of logical open files
is independend of the number of loops and definitely below 16.
Workaround 2: Alter the testscript and replace the while loop
by the necessary number of
--source ....
--source ....
But that's bad testscript architecture :(
[7 Jul 2005 9:23]
Matthias Leich
testscripts
Attachment: ml031.test (application/test, text), 320 bytes.
[7 Jul 2005 9:24]
Matthias Leich
testscript
Attachment: ml031.inc (application/octet-stream, text), 117 bytes.
[7 Jul 2005 9:25]
Matthias Leich
testscript
Attachment: ml0311.inc (application/octet-stream, text), 100 bytes.
[16 Aug 2005 11:58]
Magnus Blåudd
Problem occurs becuse the dynamic array q_lines that contains a cache of already read lines are overwritten by the lines read from the sourced file.
[16 Aug 2005 15:11]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/28339
[1 Sep 2005 19:20]
Paul DuBois
No changelog entry needed.

Description: mysqltest performes a wrong number of loops, when I have the following situation: let $outer= <n>; # Number of outer loops, <n> >= 2 while ($outer) { --source <inner script> dec $outer; } If I use the workaround let $outer= <n>; # Number of outer loops, <n> >= 2 while ($outer) { <inserted code of inner script> dec $outer; } the number of executed loops is correct. Slightly edited protocol of my test case: Test with script within outer while loop ---------------------------------------- 2 = outer loop variable after while here is the sourced script 2 = outer loop variable before dec 1 = outer loop variable after dec 1 = outer loop variable after while here is the sourced script 1 = outer loop variable before dec 0 = outer loop variable after dec here is the sourced script <------ This should never happen Test with expanded script within outer while loop ------------------------------------------------- 2 = outer loop variable after while here is the sourced script 2 = outer loop variable before dec 1 = outer loop variable after dec 1 = outer loop variable after while here is the sourced script 1 = outer loop variable before dec 0 = outer loop variable after dec My environment: - Intel PC with Linux(SuSE 9.1) - MySQL compiled from source Version 5.0 ChangeSet@1.1914, 2005-04-29 Version 4.1 ChangeSet@1.2214, 2005-04-28 BTW: It looks like this bug is old, because I found an old MySQL 5.0.3-alpha-debug for pc-linux on i686 (Source distribution) on my box and it shows the same wrong behaviour. 2005-01-08 18:12 ../libexec/mysqld 2005-01-08 18:12 ../bin/mysqltest How to repeat: Please use the attached test case files ml60.test and ml60i.sub copy them to mysql-test/t touch r/ml60.result # Produce a dummy file with # expected results ./mysql-test-run ml60 inspect r/ml60.reject # The protocol of the execution.