← Back to team overview

oqgraph-dev team mailing list archive

Trying the examples - mysqld segfault inserting into tol_tree caused by a NULL pointer in ha_oqgraph::open

 

Hi Arjen,

I finally managed to get mariadb running and the ha_oqgraph.so plugin loaded.
I had to turn off --skip-grant-tables, and then reset the db root password.
Anyway.

Given the passage of time I needed some direction as to what to do next.
Before emailing you for advice I thought I would at least familiarise myself
with the examples.

So I did `bzr branch lp:oqgraph` to try the tree of life examples as described
in your example blog.

The instructions omit how to create the actual graph table, so I guessed:

CREATE TABLE tol_tree (
    latch   SMALLINT  UNSIGNED NULL,
    origid  BIGINT    UNSIGNED NULL,
    destid  BIGINT    UNSIGNED NULL,
    weight  DOUBLE    NULL,
    seq     BIGINT    UNSIGNED NULL,
    linkid  BIGINT    UNSIGNED NULL,
    KEY (latch, origid, destid) USING HASH,
    KEY (latch, destid, origid) USING HASH
  ) ENGINE=OQGRAPH;

this worked :-)

However,

INSERT INTO tol_tree (origid,destid)
  SELECT parent,id FROM tol WHERE parent IS NOT NULL;

this failed ... (stack trace attachment)

I note the stack trace is full of mangled C++ identifiers ...

I then ran mysqld from gdb.  The fault repeated the same, but gdb let me see
the identifiers. (attach #2) and of course, catch the fault and examine variables.

It turns out that options->tablename in ha_oqgraph::open (--> table_name in
table.cc) is NULL. And strlen barfs because table.cc isn't checking for a NULL.

I am unfamiliar with the code as yet, so I don't know why this is NULL.


As an aside, I am used to working with code that is defensively laced with
assertions for NULL pointers, so this is a little different to me...


Note: I am building cleanly on Debian Squeeze with boost 1.42

--Andrew



-- 


https://launchpad.net/~andymc73
http://blog.oldcomputerjunk.net
Twitter: @andymc73
GPG: http://www.andrewmcdonnell.net/gpg.html


130219 22:35:05 [ERROR] mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.

To report this bug, see http://kb.askmonty.org/en/reporting-bugs

We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.

Server version: 10.0.1-MariaDB
key_buffer_size=16777216
read_buffer_size=131072
max_used_connections=2
max_threads=153
thread_count=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 351720 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0x21e5098
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x7fb96497be88 thread_stack 0x30000
addr2line: 'sql/mysqld': No such file
sql/mysqld(my_print_stacktrace+0x29)[0xa189d9]
sql/mysqld(handle_fatal_signal+0x40a)[0x69fe0a]
/lib/libpthread.so.0(+0xeff0)[0x7fb964618ff0]
/lib/libc.so.6(+0x7bcf2)[0x7fb963a5ecf2]
sql/mysqld(_Z20init_tmp_table_shareP3THDP11TABLE_SHAREPKcjS4_S4_+0xa7)[0x601e97]
/home/andrew/develop/maria/repo/andrew-dev/build/storage/oqgraph/ha_oqgraph.so(_ZN10ha_oqgraph4openEPKcij+0xa3)[0x7fb946be7de3]
sql/mysqld(_ZN7handler7ha_openEP5TABLEPKcij+0x3d)[0x6a30ad]
sql/mysqld(_Z21open_table_from_shareP3THDP11TABLE_SHAREPKcjjjP5TABLEb+0x738)[0x604398]
sql/mysqld(_Z10open_tableP3THDP10TABLE_LISTP11st_mem_rootP18Open_table_context+0xc00)[0x5427d0]
sql/mysqld(_Z11open_tablesP3THDPP10TABLE_LISTPjjP19Prelocking_strategy+0x2f7)[0x543247]
sql/mysqld(_Z20open_and_lock_tablesP3THDP10TABLE_LISTbjP19Prelocking_strategy+0x47)[0x543db7]
sql/mysqld[0x57466b]
sql/mysqld(_Z21mysql_execute_commandP3THD+0x3f9c)[0x57bfac]
sql/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x23d)[0x57e19d]
sql/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x1440)[0x57f5f0]
sql/mysqld(_Z24do_handle_one_connectionP3THD+0x1e4)[0x62a874]
sql/mysqld(handle_one_connection+0x40)[0x62a900]
/lib/libpthread.so.0(+0x68ca)[0x7fb9646108ca]
/lib/libc.so.6(clone+0x6d)[0x7fb963ab292d]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7fb940004b80): INSERT INTO tol_tree (origid,destid)   SELECT parent,id FROM tol WHERE parent IS NOT NULL
Connection ID (thread ID): 4
Status: NOT_KILLED

Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=off

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.





(gdb) bt
#0  __strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:31
#1  0x0000000000601e97 in init_tmp_table_share (thd=0x21d1058, share=0x21e1b00, key=0x20a0e40 "test", key_length=<value optimized out>, table_name=0x0, path=0x7fffda1b2a56 "") at /home/andrew/develop/maria/repo/andrew-dev/sql/table.cc:397
#2  0x00007fffda1a0de3 in ha_oqgraph::open (this=0x21e16f0, name=0x20a0e50 "./test/tol_tree", mode=<value optimized out>, test_if_locked=<value optimized out>) at /home/andrew/develop/maria/repo/andrew-dev/storage/oqgraph/ha_oqgraph.cc:332
#3  0x00000000006a30ad in handler::ha_open (this=0x0, table_arg=<value optimized out>, name=0x20a0e50 "./test/tol_tree", mode=2, test_if_locked=0) at /home/andrew/develop/maria/repo/andrew-dev/sql/handler.cc:2347
#4  0x0000000000604398 in open_table_from_share (thd=0x21d1058, share=0x20a0aa0, alias=<value optimized out>, db_stat=<value optimized out>, prgflag=<value optimized out>, ha_open_flags=<value optimized out>, outparam=0x21e0d68, is_create_table=false) at /home/andrew/develop/maria/repo/andrew-dev/sql/table.cc:2652
#5  0x00000000005427d0 in open_table (thd=0x21d1058, table_list=0x21dd190, mem_root=0x7ffff7f62a90, ot_ctx=0x7ffff7f62ad0) at /home/andrew/develop/maria/repo/andrew-dev/sql/sql_base.cc:3207
#6  0x0000000000543247 in open_and_process_table (thd=0x21d1058, start=<value optimized out>, counter=<value optimized out>, flags=<value optimized out>, prelocking_strategy=<value optimized out>) at /home/andrew/develop/maria/repo/andrew-dev/sql/sql_base.cc:4564
#7  open_tables (thd=0x21d1058, start=<value optimized out>, counter=<value optimized out>, flags=<value optimized out>, prelocking_strategy=<value optimized out>) at /home/andrew/develop/maria/repo/andrew-dev/sql/sql_base.cc:5115
#8  0x0000000000543db7 in open_and_lock_tables (thd=0x0, tables=0x21dd190, derived=true, flags=0, prelocking_strategy=0x0) at /home/andrew/develop/maria/repo/andrew-dev/sql/sql_base.cc:5718
#9  0x000000000057466b in open_and_lock_tables (thd=0x0, tables=0xffffffff, flags=<value optimized out>, derived=<value optimized out>) at /home/andrew/develop/maria/repo/andrew-dev/sql/sql_base.h:503
#10 0x000000000057bfac in mysql_execute_command (thd=0x21d1058) at /home/andrew/develop/maria/repo/andrew-dev/sql/sql_parse.cc:3355
#11 0x000000000057e19d in mysql_parse (thd=0x21d1058, rawbuf=<value optimized out>, length=89, parser_state=0x7ffff7f649c0) at /home/andrew/develop/maria/repo/andrew-dev/sql/sql_parse.cc:6124
#12 0x000000000057f5f0 in dispatch_command (command=COM_QUERY, thd=0x21d1058, packet=<value optimized out>, packet_length=<value optimized out>) at /home/andrew/develop/maria/repo/andrew-dev/sql/sql_parse.cc:1266
#13 0x000000000062a874 in do_handle_one_connection (thd_arg=<value optimized out>) at /home/andrew/develop/maria/repo/andrew-dev/sql/sql_connect.cc:1267
#14 0x000000000062a900 in handle_one_connection (arg=0x21d1058) at /home/andrew/develop/maria/repo/andrew-dev/sql/sql_connect.cc:1181
#15 0x00007ffff7bc98ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
#16 0x00007ffff706b92d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#17 0x0000000000000000 in ?? ()



Follow ups