Bug #55662 | _dosmaperr wipes out the errno set in _open_osfhandle and gives (errno: 22) | ||
---|---|---|---|
Submitted: | 31 Jul 2010 14:00 | Modified: | 6 Nov 2012 3:29 |
Reporter: | Shane Bester (Platinum Quality Contributor) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Windows | Severity: | S3 (Non-critical) |
Version: | 5.1.49 | OS: | Windows |
Assigned to: | CPU Architecture: | Any |
[31 Jul 2010 14:00]
Shane Bester
[30 Sep 2010 14:39]
MySQL Verification Team
http://msdn.microsoft.com/en-us/library/t3ayayh1(VS.80).aspx
[30 Sep 2010 15:33]
MySQL Verification Team
There is bug here, for example, in my_sopen(): if ((fh= _open_osfhandle((intptr_t)osfh, oflag & (_O_APPEND | _O_RDONLY | _O_TEXT))) == -1) { _dosmaperr(GetLastError()); /* map error */ CloseHandle(osfh); } When _open_osfhandle() fails, it sets errno to EMFILE (24). I'd suggest either not calling _dosmaperr, or first saving errno... The next call to _dosmaperr(GetLastError()); sets errno to EINVAL (22) since the OS error was zero. As a result, we have different code paths - We get: ERROR 1017 (HY000) at line 4485: Can't find file: '.\test\t1099.frm' (errno: 22) Instead of the expected: ERROR 1016 (HY000) at line 4485: Can't open file: '.\test\t1099.frm' (errno: 24) Since mysql takes a different code path in the case of errno 24, this is a bug.
[6 Nov 2012 3:29]
Philip Olson
This bug is fixed in the 5.7 branch, and the changelog entry reads as follows: On Microsoft Windows, a failed API or function call in "mysqld.exe" could sometimes report the error code 22, instead of the proper error code. Thank you for the bug report.