Description:
I have a Fedora 10 Linux box with MySQL server 5.0.84 on server side.
On client side is Mac OS Leopard with MySQL Connector/ODBC 5.1
Everything work fine with default charset settings.
After swiching connector to cp1251 charset ODBC Administrator gets crashes:
--------------
Process: ODBC Administrator [52431]
Path: /Applications/Utilities/ODBC Administrator.app/Contents/MacOS/ODBC Administrator
Identifier: com.apple.odbcadministrator
Version: 1.1.0 (1.1.0)
Build Info: iodbcadmin-280000~20
Code Type: X86 (Native)
Parent Process: launchd [260]
Date/Time: 2009-09-11 18:25:20.863 +0700
OS Version: Mac OS X 10.5.6 (9G55)
Report Version: 6
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000020
Crashed Thread: 0
Thread 0 Crashed:
0 libmyodbc5.so 0x1830852e mystr_get_prev_token + 46
1 libmyodbc5.so 0x183085d5 check_if_positioned_cursor_exists + 101
2 libmyodbc5.so 0x1830ee79 my_SQLExecute + 89
3 libmyodbc5.so 0x18317cb8 SQLExecDirectW + 56
4 libiodbc.2.dylib 0x0005cc42 SQLExecDirect_Internal + 439
5 libiodbc.2.dylib 0x0005d1c5 SQLExecDirect + 269
6 libmyodbc3S.so 0x17b1631d MYODBCSetupDataSourceDialog::doLoadCharsetNamesUsingDriverManager() + 605
-------------
After playing with gdb and inspecting connector sources i realized that segfault occurs inside my_isspace macro:
-----driver/cursor.c----
static const char *mystr_get_prev_token(CHARSET_INFO *charset,
.....
} while (*pos < 0 || !my_isspace(charset, *pos)) ;
---------------------
very likely that charset argument has wrong (NULL ?) value at this time.
Probably, something missed at driver/connect.c in
SQLRETURN myodbc_set_initial_character_set(DBC *dbc, const char *charset) function.
How to repeat:
1. Probably set same environment as in description section
2. Create a database on the server
3. Launch ODBC Administrator
4. Add DSN with MySQL Connector to connect to database from 2nd item
5. Test must be successful
6. Open "Connect Options" tab
7. Select "cp1251" in "Character Set" Combobox
8. Try to select another charset from this Combobox. Segfault.
Actually, if cp1251 is selected, any application that queries this DSN will segfault too.
Some other charsets do same result (koi8u, greek, cp866...),
but utf8, latin1, latin2 do not.