using my_thread_* in a library

2002-07-31 Thread Guillaume Morin

Hi folks,

I am the maintainer of NSS MySQL which is, as you may have guessed, a
nss module using MySQL as backend. It shares a mysql connection between
threads. As explained in the documentation, I use my_thread_init and
my_thread_end functions to properly manage that situation.

As you may know, a nss module provides UNIX user lookup functions such
as getgrnam. That means that basically any applications can call the nss
modules function even the ones which uses MySQL too. And there lies the
issue. Indeed, if the application follows this path :

- calls mysql_connect or mysql_thread_init
...
- calls a function like getgrnam 
- does MySQL stuff

The application will segfault since the nss module has called
my_thread_end. I do not see any solutions to this because if I remove
calls to my_thread_end I create a memory leak. I've read the source of
my_thread_init, it seems that there is no way to know if the MySQL data
was already allocated (in this case, I would not call my_thread_end).

Could anyone help me out ?

TIA.

PS: Please keep me CC'ed as I am not subscribed.

-- 
Guillaume Morin [EMAIL PROTECTED]

  I wish you were here

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




segfault in mysql_real_escape_string

2001-09-10 Thread Guillaume Morin

Hi folks,

I've the main developer of nss-mysql. I've found out a very strange
problem.

On a Debian potato, mysql 3.23.38 and glibc 2.1.3

This bit of code segfault on the last line. The string useris correct
(printed correctly in log).


/* we escape the user string */
secure_user = malloc(strlen(user) * 2 + 1);
if ( secure_user == NULL ) {
_nss_mysql_log(LOG_ERR,initgroups: not enough memory to escape the 
user string);
*errnop = EAGAIN;
return NSS_STATUS_TRYAGAIN;
}

mysql_real_escape_string(mysql_auth,secure_user,user,strlen(user));

This part is taken from the initgroups function and segfaults everytime
when called from Apache.  I've noticed that upgrading libc to 2.2.4
fixes the problem. I guess this is a problem in the client lib.

Any hints will be welcome.

-- 
Guillaume Morin [EMAIL PROTECTED]

Justice is lost, Justice is raped, Justice is done. (Metallica)

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php