Bug #44677 libmysqld crashes with a high ulimit -n on second initialisation
Submitted: 5 May 2009 19:51 Modified: 8 May 2009 20:49
Reporter: Andrew Hutchings Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S3 (Non-critical)
Version:5.0.81 OS:Linux (Fedora 10 & SLED 9)
Assigned to: CPU Architecture:Any

[5 May 2009 19:51] Andrew Hutchings
Description:
When ulimit -n is high libmysqld will crash on a second mysql_library_init (after the first was ended cleanly).  This only affects 5.0, not 5.1.  Tested on 5.0.22 and 5.0.81.

Segfault only happens without gdb.  Stack is as follows:

Program terminated with signal 11, Segmentation fault.
[New process 23333]
#0  memcpy () at ../sysdeps/x86_64/memcpy.S:420
420		movq	  (%rsi), %rax
(gdb) bt
#0  memcpy () at ../sysdeps/x86_64/memcpy.S:420
#1  0x0000000000431bc3 in my_set_max_open_files (files=<value optimized out>)
    at my_file.c:129
#2  0x000000000041ae6e in init_common_variables (argv=0x23035d0, argc=8)
    at ../sql/mysqld.cc:2630
#3  init_embedded_server (argc=8, argv=0xa13a80, groups=<value optimized out>)
    at lib_sql.cc:469
#4  0x0000000000416883 in mysql_server_init (argc=8, argv=0xa13a80, 
    groups=0xa13ae0) at libmysql.c:162
#5  0x0000000000406ca0 in mysql_interface::server_init (this=0x7fff688eec30, 
    directoryVal=@0x7fff688eeca0) at cust_test.cpp:92
#6  0x0000000000406e59 in main () at cust_test.cpp:19

How to repeat:
1. Get test file (will attach shortly)
2. g++ cust_test.cpp -o cust_test -g -lz `mysql-5.0.81-debug/bin/mysql_config --include --libmysqld-libs`
3. ulimit -n 8192
4. ./cust_test
[Segfault here]
[8 May 2009 20:49] Omer Barnir
The issue is limited to 5.0 and libmysqld is not supported in that version