We wrote a wrapper with LD_PRELOAD. When mysqld does pthread_attr_setstacksize() we translate it into an anonymous mmap() and use pthread_attr_setstackaddr() instead. It's the equivalent of FLOATING_STACKS. ;)

Our mysqld (which is running as slave) will seg fault if we set
the thread_stack to 256k.  Running it with thread_stack set to 2MB
works flawlessly (that is until we allocate 256 threads).

mysql 3.23.58 doesn't like <2MB thread stacks in our environment.

Is this normal?


I suspect you have a bug in your wrapper somewhere. Note that you delegate the stack creation at 2MB or higher to the regular pthread_attr_setstacksize()



Michael:


I noticed a couple more problems with your wrapper upon further examination. pthread_attr_setstacksize() is called only once from main() and it initializes the variable in the global thread descriptor structure. When you allocate memory, and then point the user stack at it with pthread_attr_setstackaddr(), what you end up with is all threads sharing the same stack, which would lead to a quick coredump.

In order to use user stacks and do your own stack memory management you would need to either make changes in mysqld ( look at create_new_thread() in sql/mysqld.cc, and remember that you need to clean up on thread exit, see man pthread_cleanup_push), or overwrite pthread_create() as well as pthread_exit().

It would seem to me that recompling libpthread.so with FLOATING_STACKS and putting it in LD_PRELOAD would be a simpler solution.

--
Sasha Pachev
Create online surveys at http://www.surveyz.com/

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



Reply via email to