Hi,

I've been having problems with segfaults under mod_auth_mysql in Apache
1.3, which I think i've narrowed down to the MYSQL connection structure
getting corrupted on my particular mysql installation - specifically
manifesting itself with strange values of the free_me field, which results
in the structure being incorrectly free'd.

If anyone can confirm that the following shows something fundamentally
wrong with my mysql install i'd appreciate it hugely:

box 130% cat test.c
#include <mysql/mysql.h>

int main() {
        MYSQL *m;

        m = mysql_init(0);
        printf("free_me is %d\n", m->free_me);

        return 0;
}

box 131% gcc -g -L/usr/local/lib/mysql -lmysqlclient -lm -o foo test.c
box 132% ./foo
free_me is 0

This is using libmysqlclient.so.12.0.0 on a P4 Xeon running linux 2.4.22
with libc 2.3.1; mysql 4.0.17 built from source with:

./configure --prefix=/opt/mysql-4.0.17
--localstatedir=/usr/local/var/mysql --without-innodb --without-docs
--without-bench --with-mysqld-user=mysql

The code in libmysql.c appears to say:

mysql_init(MYSQL *mysql) {
  if (!mysql) {
    <malloc mysql>
    mysql->free_me=1;
  }
  ...
}

so I'm at a complete loss to explain why m->free_me appears as 0 in the
above mini example.

Meanwhile, precisely the same program on a dual PIII machine running
Debian Woody, libmysqlclient 12.0.0 to match 4.0.16 yields:

deb 30% ./foo
free_me is 1

Superficially other operations seem to work - but segfaults ensue on
mysql_close(); and gdb reveals several fields of the connection structure
to change radically between simple operations.  For instace running a
mysql_select_db() sets the value of free_me to 0x03, amongst others:

freshly inited mysql_handle, populated with some settings:

(gdb) print *mysql_handle
$1 = {net = {vio = 0x84efd30, fd = 139421480, fcntl = 139429672, buff = 0x84f6728 "", 
buff_end = 0x84f6728 "",
    write_pos = 0x6 <Address 0x6 out of bounds>, read_pos = 0x2000 <Address 0x2000 out 
of bounds>,
    last_error = "[EMAIL PROTECTED]", '\0' <repeats 174 times>, last_errno = 0, 
max_packet = 0,
    timeout = 0, pkt_nr = 0, error = 0 '\0', return_errno = 0 '\0', compress = 0 '\0', 
no_send_ok = 0 '\0', remain_in_buf = 0, length = 0,
    buf_length = 0, where_b = 0, return_status = 0x0, reading_or_writing = 0 '\0', 
save_char = 0 '\0'}, connector_fd = 0x0, host = 0x0,
  user = 0x0, passwd = 0x0, unix_socket = 0x0, server_version = 0x0, host_info = 
0x84f01a0 "auth.domain.com", info = 0x84f01e8 "auth",
  db = 0x84f01f8 "xxxxxxxx", port = 0, client_flag = 139395520, server_capabilities = 
139395456, protocol_version = 0, field_count = 0,
  server_status = 1074172704, thread_id = 0, affected_rows = 0, insert_id = 0, 
extra_info = 0, packet_length = 0, status = MYSQL_STATUS_READY,
  fields = 0x0, field_alloc = {free = 0x0, used = 0x0, pre_alloc = 0x0, min_malloc = 
0, block_size = 0, error_handler = 0x2f43},
  free_me = 0 '\0', reconnect = 0 '\0', options = {connect_timeout = 3306, client_flag 
= 8197, compress = 44 ',', named_pipe = 0 '\0',
    port = 10, host = 0x0, init_command = 0x2 <Address 0x2 out of bounds>, user = 0x8 
<Address 0x8 out of bounds>, password = 0x0,
    unix_socket = 0x0, db = 0x0, my_cnf_file = 0x0, my_cnf_group = 0x0, charset_dir = 
0x0, charset_name = 0x0, use_ssl = 0 '\0',
    ssl_key = 0x0, ssl_cert = 0x0, ssl_ca = 0x0, ssl_capath = 0x0}, scramble_buff = 
"\0\0\0\0\0\0\0\0", charset = 0x0, server_language = 0}

(gdb) step
506       if (mysql_select_db(mysql_handle,m->mysqlDB) != 0) {

(gdb) print *mysql_handle
$2 = {net = {vio = 0x84efd30, fd = 139421480, fcntl = 139429672, buff = 0x84f6728 "", 
buff_end = 0x84f6728 "",
    write_pos = 0x6 <Address 0x6 out of bounds>, read_pos = 0x2000 <Address 0x2000 out 
of bounds>,
    last_error = "[EMAIL PROTECTED]", '\0' <repeats 174 times>, last_errno = 0, 
max_packet = 0,
    timeout = 0, pkt_nr = 0, error = 0 '\0', return_errno = 0 '\0', compress = 0 '\0', 
no_send_ok = 0 '\0', remain_in_buf = 0, length = 0,
    buf_length = 0, where_b = 0, return_status = 0x0, reading_or_writing = 0 '\0', 
save_char = 0 '\0'}, connector_fd = 0x0, host = 0x0,
  user = 0x0, passwd = 0x0, unix_socket = 0x0, server_version = 0x0, host_info = 
0x84f01a0 "auth.domain.com", info = 0x84f01e8 "auth",
  db = 0x84f01f8 "xxxxxxxx", port = 0, client_flag = 139395520, server_capabilities = 
139395456, protocol_version = 0,
  field_count = 139395592, server_status = 1074172704, thread_id = 0, affected_rows = 
0, insert_id = 0, extra_info = 0, packet_length = 0,
  status = MYSQL_STATUS_READY, fields = 0xffffffff, field_alloc = {free = 0xffffffff, 
used = 0x0, pre_alloc = 0x0, min_malloc = 0,
    block_size = 0, error_handler = 0x2f43}, free_me = 3 '\003', reconnect = 0 '\0', 
options = {connect_timeout = 3306, client_flag = 8197,
    compress = 44 ',', named_pipe = 0 '\0', port = 10, host = 0x0, init_command = 0x2 
<Address 0x2 out of bounds>,
    user = 0x8 <Address 0x8 out of bounds>, password = 0x0, unix_socket = 0x0, db = 
0x0, my_cnf_file = 0x0, my_cnf_group = 0x0,
    charset_dir = 0x0, charset_name = 0x0, use_ssl = 0 '\0', ssl_key = 0x0, ssl_cert = 
0x0, ssl_ca = 0x0, ssl_capath = 0x0},
  scramble_buff = "\0\0\0\0\0\0\0\0", charset = 0x0, server_language = 0}


Any ideas would be very much appreciated;

M.

--
[EMAIL PROTECTED]

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to