[MDEV-25461] Assertion `je->state == JST_KEY' failed in Geometry::create_from_json Created: 2021-04-20  Updated: 2021-06-28  Resolved: 2021-06-28

Status: Closed
Project: MariaDB Server
Component/s: GIS, JSON
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.2.40

Type: Bug Priority: Critical
Reporter: Roel Van de Paar Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: GIS, JSON, affects-tests

Issue Links:
Relates
relates to MDEV-19723 Assertion `je->state == JST_KEY' fail... Closed

 Description   

Ref MDEV-19723

SELECT ST_ASTEXT (ST_GEOMFROMGEOJSON ("{ \"type\": \"GEOMETRYCOLLECTION\", \"coordinates\": [102.0, 0.0]}"));

Leads to:

10.6.0 a3e3225cd3b816d47621e749e21a71b6a864a96a (Debug)

mysqld: /test/10.6_dbg/sql/spatial.cc:513: static Geometry* Geometry::create_from_json(Geometry_buffer*, json_engine_t*, bool, String*): Assertion `je->state == JST_KEY' failed.

10.6.0 a3e3225cd3b816d47621e749e21a71b6a864a96a (Debug)

Core was generated by `/test/MD150421-mariadb-10.6.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x14caec984700 (LWP 2315813))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014caf7de9859 in __GI_abort () at abort.c:79
#2  0x000014caf7de9729 in __assert_fail_base (fmt=0x14caf7f7f588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55799330b991 "je->state == JST_KEY", file=0x55799330b8d9 "/test/10.6_dbg/sql/spatial.cc", line=513, function=<optimized out>) at assert.c:92
#3  0x000014caf7dfaf36 in __GI___assert_fail (assertion=assertion@entry=0x55799330b991 "je->state == JST_KEY", file=file@entry=0x55799330b8d9 "/test/10.6_dbg/sql/spatial.cc", line=line@entry=513, function=function@entry=0x55799330be10 "static Geometry* Geometry::create_from_json(Geometry_buffer*, json_engine_t*, bool, String*)") at assert.c:101
#4  0x0000557992965e65 in Geometry::create_from_json (buffer=buffer@entry=0x14caec9821d0, je=je@entry=0x14caec9820e0, er_on_3D=er_on_3D@entry=false, res=res@entry=0x14caec982240) at /test/10.6_dbg/sql/spatial.cc:513
#5  0x0000557992840fa2 in Item_func_geometry_from_json::val_str (this=0x14ca94014488, str=0x14caec982240) at /test/10.6_dbg/sql/item_geofunc.cc:159
#6  0x000055799284229b in Item_func_as_wkt::val_str_ascii (this=0x14ca940145f8, str=0x14caec9823d0) at /test/10.6_dbg/sql/item_geofunc.cc:201
#7  0x000055799286caf8 in Item_func::val_str_from_val_str_ascii (this=0x14ca940145f8, str=0x14caec9823d0, ascii_buffer=0x14ca940146c0) at /test/10.6_dbg/sql/item_strfunc.cc:98
#8  0x000055799280a3ea in Item_str_ascii_func::val_str (this=<optimized out>, str=<optimized out>) at /test/10.6_dbg/sql/item_strfunc.h:88
#9  0x00005579926abb46 in Type_handler::Item_send_str (this=<optimized out>, item=0x14ca940145f8, protocol=0x14ca940013a0, buf=<optimized out>) at /test/10.6_dbg/sql/sql_type.cc:7434
#10 0x00005579925f9061 in Type_handler_string_result::Item_send (this=<optimized out>, item=<optimized out>, protocol=<optimized out>, buf=<optimized out>) at /test/10.6_dbg/sql/sql_type.h:5434
#11 0x00005579923b51c2 in Item::send (this=0x14ca940145f8, protocol=0x14ca940013a0, buffer=0x14caec9823a0) at /test/10.6_dbg/sql/item.h:1066
#12 0x00005579923b28cc in Protocol::send_result_set_row (this=this@entry=0x14ca940013a0, row_items=row_items@entry=0x14ca94013f98) at /test/10.6_dbg/sql/protocol.cc:1331
#13 0x0000557992448cd1 in select_send::send_data (this=0x14ca94015010, items=@0x14ca94013f98: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14ca940146e0, last = 0x14ca940146e0, elements = 1}, <No data fields>}) at /test/10.6_dbg/sql/sql_class.cc:3020
#14 0x00005579925393bd in select_result_sink::send_data_with_check (sent=0, u=<optimized out>, items=<optimized out>, this=<optimized out>) at /test/10.6_dbg/sql/sql_class.h:5567
#15 JOIN::exec_inner (this=this@entry=0x14ca94015038) at /test/10.6_dbg/sql/sql_select.cc:4361
#16 0x000055799253a41a in JOIN::exec (this=this@entry=0x14ca94015038) at /test/10.6_dbg/sql/sql_select.cc:4273
#17 0x00005579925384f3 in mysql_select (thd=thd@entry=0x14ca94000db8, tables=0x0, fields=@0x14ca94013f98: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14ca940146e0, last = 0x14ca940146e0, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14ca94015010, unit=0x14ca94004f90, select_lex=0x14ca94013e48) at /test/10.6_dbg/sql/sql_select.cc:4749
#18 0x00005579925387b9 in handle_select (thd=thd@entry=0x14ca94000db8, lex=lex@entry=0x14ca94004ec8, result=result@entry=0x14ca94015010, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_dbg/sql/sql_select.cc:419
#19 0x00005579924ab8b5 in execute_sqlcom_select (thd=thd@entry=0x14ca94000db8, all_tables=0x0) at /test/10.6_dbg/sql/sql_parse.cc:6244
#20 0x00005579924b877d in mysql_execute_command (thd=thd@entry=0x14ca94000db8) at /test/10.6_dbg/sql/sql_parse.cc:3940
#21 0x00005579924a4a06 in mysql_parse (thd=thd@entry=0x14ca94000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14caec983410) at /test/10.6_dbg/sql/sql_parse.cc:8017
#22 0x00005579924b37df in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14ca94000db8, packet=packet@entry=0x14ca9400b369 "", packet_length=packet_length@entry=108, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_class.h:1331
#23 0x00005579924b6bd5 in do_command (thd=0x14ca94000db8, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_parse.cc:1406
#24 0x000055799261077c in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55799624e518, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
#25 0x0000557992610d81 in handle_one_connection (arg=arg@entry=0x55799624e518) at /test/10.6_dbg/sql/sql_connect.cc:1312
#26 0x0000557992abea03 in pfs_spawn_thread (arg=0x557996172c98) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
#27 0x000014caf82f7609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#28 0x000014caf7ee6293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.38 (dbg), 10.3.29 (dbg), 10.4.19 (dbg), 10.5.10 (dbg), 10.6.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.38 (opt), 10.3.29 (opt), 10.4.19 (opt), 10.5.10 (opt), 10.6.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.33 (dbg), 5.7.33 (opt), 8.0.23 (dbg), 8.0.23 (opt)

This issue remains critical (affect_tests), as other issues may be masked due to the generic outcome. Please fix asap.



 Comments   
Comment by Roel Van de Paar [ 2021-04-22 ]

Two related, but different stacks with this testcase:

SELECT ST_GEOMFROMGEOJSON ("{ \"type\": [ \"POINT\" ],\"coINates\": [0,0] }");

Leads to:

10.6.0 a3e3225cd3b816d47621e749e21a71b6a864a96a (Debug)

mysqld: /test/10.6_dbg/sql/spatial.cc:513: static Geometry* Geometry::create_from_json(Geometry_buffer*, json_engine_t*, bool, String*): Assertion `je->state == JST_KEY' failed.

10.6.0 a3e3225cd3b816d47621e749e21a71b6a864a96a (Debug)

Core was generated by `/test/MD150421-mariadb-10.6.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x1501a9b68700 (LWP 1279802))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00001501cca1d859 in __GI_abort () at abort.c:79
#2  0x00001501cca1d729 in __assert_fail_base (fmt=0x1501ccbb3588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x560741616991 "je->state == JST_KEY", file=0x5607416168d9 "/test/10.6_dbg/sql/spatial.cc", line=513, function=<optimized out>) at assert.c:92
#3  0x00001501cca2ef36 in __GI___assert_fail (assertion=assertion@entry=0x560741616991 "je->state == JST_KEY", file=file@entry=0x5607416168d9 "/test/10.6_dbg/sql/spatial.cc", line=line@entry=513, function=function@entry=0x560741616e10 "static Geometry* Geometry::create_from_json(Geometry_buffer*, json_engine_t*, bool, String*)") at assert.c:101
#4  0x0000560740c70e65 in Geometry::create_from_json (buffer=buffer@entry=0x1501a9b66290, je=je@entry=0x1501a9b661a0, er_on_3D=er_on_3D@entry=false, res=res@entry=0x1501a9b663d0) at /test/10.6_dbg/sql/spatial.cc:513
#5  0x0000560740b4bfa2 in Item_func_geometry_from_json::val_str (this=0x15017c014400, str=0x1501a9b663d0) at /test/10.6_dbg/sql/item_geofunc.cc:159
#6  0x00005607409b6b46 in Type_handler::Item_send_str (this=<optimized out>, item=0x15017c014400, protocol=0x15017c0013a0, buf=<optimized out>) at /test/10.6_dbg/sql/sql_type.cc:7434
#7  0x0000560740904061 in Type_handler_string_result::Item_send (this=<optimized out>, item=<optimized out>, protocol=<optimized out>, buf=<optimized out>) at /test/10.6_dbg/sql/sql_type.h:5434
#8  0x00005607406c01c2 in Item::send (this=0x15017c014400, protocol=0x15017c0013a0, buffer=0x1501a9b663a0) at /test/10.6_dbg/sql/item.h:1066
#9  0x00005607406bd8cc in Protocol::send_result_set_row (this=this@entry=0x15017c0013a0, row_items=row_items@entry=0x15017c013f58) at /test/10.6_dbg/sql/protocol.cc:1331
#10 0x0000560740753cd1 in select_send::send_data (this=0x15017c014df8, items=@0x15017c013f58: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x15017c0144e8, last = 0x15017c0144e8, elements = 1}, <No data fields>}) at /test/10.6_dbg/sql/sql_class.cc:3020
#11 0x00005607408443bd in select_result_sink::send_data_with_check (sent=0, u=<optimized out>, items=<optimized out>, this=<optimized out>) at /test/10.6_dbg/sql/sql_class.h:5567
#12 JOIN::exec_inner (this=this@entry=0x15017c014e20) at /test/10.6_dbg/sql/sql_select.cc:4361
#13 0x000056074084541a in JOIN::exec (this=this@entry=0x15017c014e20) at /test/10.6_dbg/sql/sql_select.cc:4273
#14 0x00005607408434f3 in mysql_select (thd=thd@entry=0x15017c000db8, tables=0x0, fields=@0x15017c013f58: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x15017c0144e8, last = 0x15017c0144e8, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x15017c014df8, unit=0x15017c004f90, select_lex=0x15017c013e08) at /test/10.6_dbg/sql/sql_select.cc:4749
#15 0x00005607408437b9 in handle_select (thd=thd@entry=0x15017c000db8, lex=lex@entry=0x15017c004ec8, result=result@entry=0x15017c014df8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.6_dbg/sql/sql_select.cc:419
#16 0x00005607407b68b5 in execute_sqlcom_select (thd=thd@entry=0x15017c000db8, all_tables=0x0) at /test/10.6_dbg/sql/sql_parse.cc:6244
#17 0x00005607407c377d in mysql_execute_command (thd=thd@entry=0x15017c000db8) at /test/10.6_dbg/sql/sql_parse.cc:3940
#18 0x00005607407afa06 in mysql_parse (thd=thd@entry=0x15017c000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1501a9b67410) at /test/10.6_dbg/sql/sql_parse.cc:8017
#19 0x00005607407be7df in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x15017c000db8, packet=packet@entry=0x15017c00b369 "", packet_length=packet_length@entry=77, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_class.h:1331
#20 0x00005607407c1bd5 in do_command (thd=0x15017c000db8, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_parse.cc:1406
#21 0x000056074091b77c in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5607443853d8, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
#22 0x000056074091bd81 in handle_one_connection (arg=arg@entry=0x5607443853d8) at /test/10.6_dbg/sql/sql_connect.cc:1312
#23 0x0000560740dc9a03 in pfs_spawn_thread (arg=0x5607442a9aa8) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
#24 0x00001501ccf2b609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#25 0x00001501ccb1a293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.2.38 (Debug)

mysqld: /data/10.2_dbg/sql/spatial.cc:487: static Geometry* Geometry::create_from_json(Geometry_buffer*, json_engine_t*, bool, String*): Assertion `je->state == JST_KEY' failed.

10.2.38 (Debug)

Core was generated by `/test/MD240321-mariadb-10.2.38-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x14e8cc0a9700 (LWP 1287941))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000055c5073f3189 in my_write_core (sig=sig@entry=6) at /data/10.2_dbg/mysys/stacktrace.c:382
#2  0x000055c506cea963 in handle_fatal_signal (sig=6) at /data/10.2_dbg/sql/signal_handler.cc:343
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x000014e8e6794859 in __GI_abort () at abort.c:79
#6  0x000014e8e6794729 in __assert_fail_base (fmt=0x14e8e692a588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55c50757f6fc "je->state == JST_KEY", file=0x55c50757f60c "/data/10.2_dbg/sql/spatial.cc", line=487, function=<optimized out>) at assert.c:92
#7  0x000014e8e67a5f36 in __GI___assert_fail (assertion=assertion@entry=0x55c50757f6fc "je->state == JST_KEY", file=file@entry=0x55c50757f60c "/data/10.2_dbg/sql/spatial.cc", line=line@entry=487, function=function@entry=0x55c50757f558 "static Geometry* Geometry::create_from_json(Geometry_buffer*, json_engine_t*, bool, String*)") at assert.c:101
#8  0x000055c506e673fe in Geometry::create_from_json (buffer=buffer@entry=0x14e8cc0a6320, je=je@entry=0x14e8cc0a6230, er_on_3D=er_on_3D@entry=false, res=res@entry=0x14e8cc0a63f0) at /data/10.2_dbg/sql/spatial.cc:623
#9  0x000055c506d872bc in Item_func_geometry_from_json::val_str (this=0x14e87c011548, str=0x14e8cc0a63f0) at /data/10.2_dbg/sql/item_geofunc.cc:166
#10 0x000055c506d00b2f in Item::send (this=0x14e87c011548, protocol=0x14e87c001348, buffer=0x14e8cc0a63f0) at /data/10.2_dbg/sql/item.cc:6898
#11 0x000055c506a2b016 in Protocol::send_result_set_row (this=this@entry=0x14e87c001348, row_items=row_items@entry=0x14e87c0051f0) at /data/10.2_dbg/sql/protocol.cc:992
#12 0x000055c506aa8b65 in select_send::send_data (this=0x14e87c011710, items=@0x14e87c0051f0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14e87c011628, last = 0x14e87c011628, elements = 1}, <No data fields>}) at /data/10.2_dbg/sql/sql_class.cc:2734
#13 0x000055c506b52818 in JOIN::exec_inner (this=this@entry=0x14e87c011730) at /data/10.2_dbg/sql/sql_select.cc:3534
#14 0x000055c506b53476 in JOIN::exec (this=this@entry=0x14e87c011730) at /data/10.2_dbg/sql/sql_select.cc:3437
#15 0x000055c506b53e6c in mysql_select (thd=thd@entry=0x14e87c000d90, tables=0x0, wild_num=0, fields=@0x14e87c0051f0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14e87c011628, last = 0x14e87c011628, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x14e87c011710, unit=0x14e87c004988, select_lex=0x14e87c0050c8) at /data/10.2_dbg/sql/sql_select.cc:3840
#16 0x000055c506b54101 in handle_select (thd=thd@entry=0x14e87c000d90, lex=lex@entry=0x14e87c0048c8, result=result@entry=0x14e87c011710, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/10.2_dbg/sql/sql_select.cc:361
#17 0x000055c506ad943f in execute_sqlcom_select (thd=thd@entry=0x14e87c000d90, all_tables=0x0) at /data/10.2_dbg/sql/sql_parse.cc:6274
#18 0x000055c506ae3592 in mysql_execute_command (thd=thd@entry=0x14e87c000d90) at /data/10.2_dbg/sql/sql_parse.cc:3585
#19 0x000055c506aeca52 in mysql_parse (thd=thd@entry=0x14e87c000d90, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14e8cc0a8550, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/10.2_dbg/sql/sql_parse.cc:7794
#20 0x000055c506aef555 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14e87c000d90, packet=packet@entry=0x14e87c0195d1 "", packet_length=packet_length@entry=77, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/10.2_dbg/sql/sql_class.h:1109
#21 0x000055c506af236d in do_command (thd=0x14e87c000d90) at /data/10.2_dbg/sql/sql_parse.cc:1381
#22 0x000055c506bf650c in do_handle_one_connection (connect=connect@entry=0x55c50a82f680) at /data/10.2_dbg/sql/sql_connect.cc:1336
#23 0x000055c506bf6737 in handle_one_connection (arg=0x55c50a82f680) at /data/10.2_dbg/sql/sql_connect.cc:1241
#24 0x000014e8e6c9a609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#25 0x000014e8e6891293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.38 (dbg), 10.3.29 (dbg), 10.4.19 (dbg), 10.5.10 (dbg), 10.6.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.38 (opt), 10.3.29 (opt), 10.4.19 (opt), 10.5.10 (opt), 10.6.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.33 (dbg), 5.7.33 (opt), 8.0.23 (dbg), 8.0.23 (opt)

Comment by Alexey Botchkov [ 2021-06-28 ]

https://github.com/MariaDB/server/commit/8147d2e6183a1a4a4f3db2884966f5da2d17678c

Generated at Thu Feb 08 09:37:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.