Bug #69134 libmysql.dll 5.6.11 failed to load in windows 8 (64bits)
Submitted: 3 May 2013 11:51 Modified: 22 Jun 2013 15:03
Reporter: Fernando Pereira Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Windows Severity:S1 (Critical)
Version:5.6.11 OS:Microsoft Windows (v,8 64bits)
Assigned to: CPU Architecture:Any
Tags: 5.6.11, failed, libmysql, load, windows

[3 May 2013 11:51] Fernando Pereira
Description:
Hello. I'm trying to use this DLL but it seems to have a problem.

Problem: Failed to load library (Microsoft's function getLastError() returns error code 193).

Then I tried to see what the TDUMP returns and it returns: Error: Internal Error at 0x42213f with base 0x400000.

How to repeat:
Steps to reproduce:
1. Download the MySQL 5.6 for windows (installer or zip package).
2. Install/uncompress (I've a 64bits windows 8).
3. Open Windows Command Prompt (cmd).
4. Access the libmysql folder (cd C:\Mysql...).
5. Run tdump (tdump libmysql.dll)
[3 May 2013 11:55] Shane Bester
ERROR_BAD_EXE_FORMAT
193 (0xC1)
%1 is not a valid Win32 application.
[3 May 2013 11:58] Shane Bester
What is "tdump" and what is it trying to do exactly?
I tried dumpbin from visual studio and it works...

D:\mysql-5.6.11-winx64\lib>dumpbin libmysql.dll
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Dump of file libmysql.dll

File Type: DLL

  Summary

      3DF000 .data
        2000 .idata
        C000 .pdata
       38000 .rdata
        7000 .reloc
        1000 .rsrc
       D6000 .text
        6000 data
        2000 text
[3 May 2013 12:45] Fernando Pereira
TDUMP does a dump of the file, showing the options.
The dump:
--------------------------------------------------
Microsoft Windows [versão 6.2.9200]
(c) 2012 Microsoft Corporation. Todos os direitos reservados.

C:\MySQL>cd "MySQL Server 5.6"

C:\MySQL\MySQL Server 5.6>cd lib

C:\MySQL\MySQL Server 5.6\lib>tdump libmysql.dll
Turbo Dump  Version 5.0.16.12 Copyright (c) 1988, 2000 Inprise Corporation
                   Display of File LIBMYSQL.DLL

Old Executable Header

DOS File Size                                     47E800h  (4712448. )
Load Image Size                                      450h  (  1104. )
Relocation Table entry count                          0000h  (     0. )
Relocation Table address                              0040h  (    64. )
Size of header record      (in paragraphs)            0004h  (     4. )
Minimum Memory Requirement (in paragraphs)            0000h  (     0. )
Maximum Memory Requirement (in paragraphs)            FFFFh  ( 65535. )
File load checksum                                    0000h  (     0. )
Overlay Number                                        0000h  (     0. )

Initial Stack Segment  (SS:SP)                    0000:00B8
Program Entry Point    (CS:IP)                    0000:0000

Portable Executable (PE) File

Header base: 000000F8

CPU type                 Unknown
Flags                    2022 [ executable linenumbers symbols largeaddr backwar
ds library ]
DLL flags                0140 [ ]
Linker Version           A.0
Time stamp               515ECBE4 : Fri Apr 05 10:04:36 2013
O/S Version              5.2
User Version             0.0
Subsystem Version        5.2
Subsystem                0003 [ Windows character ]
Object count             00000009
Symbols offset           00000000
Symbols count            00000000
Optional header size     00F0
Magic #                  20B
Code size                000D5E00
Init Data size           00431A00
Uninit Data size         00000000
Entry RVA                00001270
Image base               00000001
Code base                00001000
Data base                80000000
Object/File align        00001000/00000200
Reserved                 00000000
Image size               0050C000
Header size              00000400
Checksum                 00000000
Stack reserve/commit     00100000/00000000
Heap reserve/commit      00001000/00000000
Number interesting RVAs  00000000
Name                   RVA       Size
------------------  --------  --------
Exports             00001000  00000000
Imports             00000000  00000010
Resources           0010D740  00000F7F
Exceptions          004FA000  00000064
Security            00504000  00000633
Fixups              004EE000  0000A6F8
Debug               00000000  00000000
Description         00505000  00003008
Global Ptr          000D7BD0  0000001C
TLS                 00000000  00000000
Callbacks           00000000  00000000
Bound Imports       00000000  00000000
Import Addr Table   00000000  00000000
Delayed Imports     00000000  00000000
COM Runtime         004FA888  00000820
reserved            00000000  00000000

Object table:
#   Name      VirtSize    RVA     PhysSize  Phys off  Flags
--  --------  --------  --------  --------  --------  --------
01            00000000  00000000  7865742E  00000074  00000400 []
02            00000000  60000020  6164722E  00006174  000D6200 []
03            00000000  40000040  7461642E  00000061  0010DA00 []
04            00000000  C0000040  6164702E  00006174  00463600 []
05            00000000  40000040  6164692E  00006174  0046F000 []
06            00000000  C0000040  74786574  00000000  00471000 []
07            00000000  20000040  61746164  00000000  00472400 []
08            00000000  40000040  7273722E  00000063  00477600 []
09            00000000  40000040  6C65722E  0000636F  00477E00 []

Key to section flags:
ERROR: Internal error at 0x42213f with base 0x400000

C:\MySQL\MySQL Server 5.6\lib>
--------------------------------------------------

I'm using Delphi 7 and the code follows bellow:
...
var
  libHandle: THandle;
begin
  libHandle := LoadLibrary('C:\MySQL Server 5.6\lib\libmysql.dll');
...
  @mysql_get_client_info := GetAddress('mysql_get_client_info'); // returns an Access Violation Error because the library isn't loaded correctly
...
end;

After the LoadLibrary() the libHandle still 0(zero) and if you call GetLastError() you'll get error code 193.
[3 May 2013 13:01] Miguel Solorzano
It's your Delphi 7 a 64-bits application? Otherwise try the libmysql.dll 32-bits. Thanks.
[3 May 2013 13:38] Fernando Pereira
1. Uninstalled the 64 bits MySQL.
2. Installed 32 bits MySQL.
Then I tried again and got the same error.

I'm using the windows installer, downloaded at http://dev.mysql.com/downloads/installer/

During the installation I've chosen the 32 bits architecture.
[3 May 2013 13:38] Fernando Pereira
And Delphi 7 is a 32 bits application.
[3 May 2013 15:51] Miguel Solorzano
Do you have access to a pure Win32 machine so you can test the same dll on it?. I have doubts about the Delphi LoadLibrary invokes a system Windows dll not 32-bits. Thanks.
[3 May 2013 17:15] Fernando Pereira
Yes, I've access. 
So, I tried in a pure 32 bits machine (Windows v.7 32 bits).
On that machine, the OS returns that the DLL was not created for Windows and contains an error on it.
The function GetLastError() returns error code 193 too.

I tried in a 64 bits machine with windows 7, it works.
Even I selected 32 bits architecture in the installation wizard, it seems that still installing the 64 bits dll.

Thanks
[3 May 2013 18:09] Fernando Pereira
I had the same problem in another machine with Windows 8, 64 bits.
Installing MySQL 5.1 it works perfectly.
[4 May 2013 0:37] Miguel Solorzano
I tested both 64/32-bits installation with dumpbin tool and the were installed the correct dll's:

E:\Program Files\MySQL\MySQL Server 5.6\lib>dir libmysql.dll
 O volume na unidade E é SECOND
 O Número de Série do Volume é 68A3-FC87

 Pasta de E:\Program Files\MySQL\MySQL Server 5.6\lib

05/04/2013  15:04         4.712.448 libmysql.dll
               1 arquivo(s)      4.712.448 bytes
               0 pasta(s)   409.021.095.936 bytes disponíveis

E:\Program Files\MySQL\MySQL Server 5.6\lib>dumpbin /headers libmysql.dll | findstr machine
            8664 machine (x64)

E:\Program Files\MySQL\MySQL Server 5.6\lib>

-------------------------32 bit install---------------------------------

E:\Program Files (x86)\MySQL\MySQL Server 5.6\lib>dir libmysql.dll
 O volume na unidade E é SECOND
 O Número de Série do Volume é 68A3-FC87

 Pasta de E:\Program Files (x86)\MySQL\MySQL Server 5.6\lib

05/04/2013  16:59         4.468.224 libmysql.dll
               1 arquivo(s)      4.468.224 bytes
               0 pasta(s)   408.961.613.824 bytes disponíveis

E:\Program Files (x86)\MySQL\MySQL Server 5.6\lib>dumpbin /headers libmysql.dll | findstr machine
             14C machine (x86)
                   32 bit word machine

E:\Program Files (x86)\MySQL\MySQL Server 5.6\lib>

Please check on your environment if exists another libmysql.dll installed in the search system path. Thanks.
[6 May 2013 12:25] Fernando Pereira
I checked the system variable: PATH.
There's no reference to Mysql in the path.
By the way, I searched for another libmysql.dll but I didn't found another.
[22 May 2013 15:03] Tonci Grgin
Fernando,

I'm an old Delphi "freak" and checking against my ancient D6 code, library Miguel provided me with, loads. The code is:
{ Initialize MySQL dynamic library }
function MySqlLoadLib: Boolean;
begin
  if hDLL = 0 then
  begin
    hDLL := GetModuleHandle(PChar(DLL));
    LibLoaded := False;
    if hDLL = 0 then
    begin
      hDLL := LoadLibrary(PChar(DLL));
      LibLoaded := True;
    end;
  end;

  if hDLL <> 0 then begin
    @mysql_debug           := GetProcAddress(hDLL,'mysql_debug');
    @mysql_dump_debug_info := GetProcAddress(hDLL,'mysql_dump_debug_info');
...
    @mysql_close           := GetProcAddress(hDLL,'mysql_close');
    @mysql_select_db       := GetProcAddress(hDLL,'mysql_select_db');
...
    @mysql_shutdown        := GetProcAddress(hDLL,'mysql_shutdown');
    @mysql_kill            := GetProcAddress(hDLL,'mysql_kill');
...
    @mysql_escape_string   := GetProcAddress(hDLL,'mysql_escape_string');
    @mysql_get_server_info := GetProcAddress(hDLL,'mysql_get_server_info');
...
    @mysql_list_processes  := GetProcAddress(hDLL,'mysql_list_processes');
    @mysql_list_tables     := GetProcAddress(hDLL,'mysql_list_tables');
...
    @mysql_fetch_row       := GetProcAddress(hDLL,'mysql_fetch_row');
    @mysql_fetch_field     := GetProcAddress(hDLL,'mysql_fetch_field');
...
    @mysql_affected_rows   := GetProcAddress(hDLL,'mysql_affected_rows');
...
    Result := True;
  end else
    raise Exception.Create(Format(SLibraryNotFound,[DLL]));
end;

So I'd say problem is either in D7 or your setup, can't tell which.
[22 May 2013 15:19] Tonci Grgin
TDUMP, D6 WinXP 32 bit, libmysql 5.6.11.0

Attachment: tdump.txt (text/plain), 15.87 KiB.

[23 Jun 2013 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".