Bug #106642 Running unit test mysys_pathfuncs-t failed
Description:
Hello,
I found there may be a bug in https://github.com/mysql/mysql-server/blob/8.0/mysys/mf_tempfile.cc after running mysys_pathfuncs-t failed
[ RUN ] Mysys.CreateTempFile
/flash1/daoke.wangc/mysql-server/unittest/gunit/mysys_pathfuncs-t.cc:155: Failure
Value of: dst
Expected: matches regular expression "/tmp/[a]+fd=[0-9]+"
Actual: "/tmp/aaaaaaaaaaaaaaaaaaaaaaafmmPrB\0\0\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA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\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA" (no terminating NUL) (of type char [512])
[ FAILED ] Mysys.CreateTempFile (0 ms)
[ RUN ] Mysys.UnpackDirname
[ OK ] Mysys.UnpackDirname (0 ms)
[----------] 12 tests from Mysys (1 ms total)
[----------] Global test environment tear-down
[==========] 12 tests from 1 test suite ran. (1 ms total)
[ PASSED ] 11 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] Mysys.CreateTempFile
1 FAILED TEST
Because we expect a file name like /tmp/aaaaaaafd=2342 however it is /tmp/aaaaaaaaaaaaaaaaaaaaaaafmmPrB in mysys_pathfuncs-t.cc
152 File fileno = create_temp_file(dst, "/tmp", prefix, 42, UNLINK_FILE, 0);
153 EXPECT_GE(fileno, 0);
154 my_close(fileno, 0);
155 EXPECT_THAT(dst, MatchesRegex("/tmp/[a]+fd=[0-9]+")); <--------
156 aset(dst, 0xaa);
I debug in line about the detail , and found I always got ERRNO=21(Is a directory) error when using dirname_buf("/tmp/") to open file.
135 if (!dir && !(dir = getenv("TMPDIR"))) dir = DEFAULT_TMPDIR;
(gdb)
138 convert_dirname(dirname_buf, dir, nullptr);
(gdb)
141 int max_filename_len = snprintf(to, FN_REFLEN, "%s%.20sfd=%d", dirname_buf,
(gdb)
142 prefix ? prefix : "tmp.", 4 * 1024 * 1024);
(gdb)
143 if (max_filename_len >= FN_REFLEN) {
(gdb)
152 file = open(dirname_buf, O_RDWR | O_TMPFILE | O_CLOEXEC, S_IRUSR | S_IWUSR);
(gdb)
153 if (file >= 0) {
(gdb) p dirname_buf
$110 = "/tmp/\000\000\000\213\306J\000\000\000\000\000`\324\377\377\377\177\000\000\060\322\377\377\377\177\000\000\200\324\377\377\377\177\000\000\370\311J\000\000\000\000\000\260\324\377\377\377\177\000\000\375\036\207\366\377\177\000\000\224\266X\000\000\000\000\000\375\036\207\366\377\177\000\000\000\330\377\377\377\177\000\000\000\064\273\366\377\177\000\000\020\330\377\377\377\177\000\000\034\223\206\000\000\000\000\000\377\377\377\377\000\000\000\000\001\000\000\000\000\000\000\000(\330\377\377\377\177\000\000*l\204\366\377\177\000\000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaap\323\377\377\377\177\000\000P\323\377\377\377\177\000\000\200\323\377\377\377\177\000\000`\323\377\377\377\177\000\000\000\000\000\000\000\000\000\000\220\323\377\377\377\177\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\177\000\000\000\000\000\000aaaa\240\323\377\377\377\177\000\000\000\000\000\000\377\177\000\000\375\036\207\366\377\177\000\000\000\000\000\000\000\000\000\000\000\064\273\366\377\177\000\000\360\330\377\377\377\177\000\000L\223\206\000\000\000\000\000\024\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\b\331\377\377\377\177\000\000*l\204\366\377\177\000\000\003\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\037\223\206\000\000\000\000\000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaP\324\377\377\377\177\000\000\060\324\377\377\377\177\000\000\231\214J\000\000\000\000\000@\324\377\377\377\177\000\000?\324\377\377\377\177\000\000\245\326\377\377\377\177\000\000\240\324\377\377\377\177\000\000\005\002\000\000\000\000\000\000\240\324\377\377\377\177\000a\020\324\377\377\377\177\000\000\214\202J\000\000\000\000"
(gdb) p to
$111 = 0x7fffffffd6b0 "/tmp/aaaaaaaaaaaaaaaaaaaafd=4194304"
(gdb) p file
$112 = -1
(gdb) p *((int*(*)())__errno_location)()
$113 = 21
Maybe we should change EXPECT_THAT(dst, MatchesRegex("/tmp/[a]+fd=[0-9]+")); ?
How to repeat:
make mysys_pathfuncs-t
./runtime_output_directory/mysys_pathfuncs-t
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.052 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.