[MDEV-24950] Server crash on select with st_distance and where clause Created: 2021-02-23  Updated: 2021-02-23  Resolved: 2021-02-23

Status: Closed
Project: MariaDB Server
Component/s: N/A
Affects Version/s: 10.2, 10.3, 10.4, 10.5
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Stoyan Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: SEGV, crash
Environment:

Debian 10


Attachments: Text File error.txt    
Issue Links:
Duplicate
duplicates MDEV-16549 Server crashes in Item_field::fix_fie... Closed

 Description   

The following query crashes MariaDB server versions 10.2,10.3,10.4,10.5

SELECT * FROM (

SELECT id,ST_DISTANCE(p1,p2) dist FROM (
SELECT * FROM (
SELECT seq id, POINT(lon,lat) p1 FROM
(SELECT seq,floor(RAND()*90) lon,floor(RAND()*180) lat FROM seq_1_to_10) s
)t

JOIN (
SELECT seq id2, POINT(lon,lat) p2 FROM
(SELECT seq,floor(RAND()*90) lon,floor(RAND()*180) lat FROM seq_1_to_10) s
)t2 ON t.id = t2.id2

)t

)t WHERE dist <= 1000;

Interestingly the query executes without the WHERE clause.

Attached is the full error log.



 Comments   
Comment by Alice Sherepa [ 2021-02-23 ]

Thanks! I repeated the bug, this one is the same as MDEV-16549

Version: '10.5.9-MariaDB-debug-log'  
mariadbd: /10.5/sql/item.cc:5843: virtual bool Item_field::fix_fields(THD*, Item**): Assertion `context' failed.
210223 10:46:53 [ERROR] mysqld got signal 6 ;
Server version: 10.5.9-MariaDB-debug-log
 
mysys/stacktrace.c:212(my_print_stacktrace)[0x56518ec415d8]
sigaction.c:0(__restore_rt)[0x7fb13a91a3c0]
linux/raise.c:51(__GI_raise)[0x7fb13a40618b]
stdlib/abort.c:81(__GI_abort)[0x7fb13a3e5859]
intl/loadmsgcat.c:509(get_sysdep_segment_value)[0x7fb13a3e5729]
:0(__GI___assert_fail)[0x7fb13a3f6f36]
sql/item.cc:5851(Item_field::fix_fields(THD*, Item**))[0x56518eccb296]
sql/item.h:988(Item::fix_fields_if_needed(THD*, Item**))[0x56518e19c3f7]
sql/item.cc:8989(Item_direct_view_ref::fix_fields(THD*, Item**))[0x56518ece86d4]
sql/item.h:988(Item::fix_fields_if_needed(THD*, Item**))[0x56518e19c3f7]
sql/item_func.cc:352(Item_func::fix_fields(THD*, Item**))[0x56518ed9a4e4]
sql/item.h:988(Item::fix_fields_if_needed(THD*, Item**))[0x56518e19c3f7]
sql/item_func.cc:352(Item_func::fix_fields(THD*, Item**))[0x56518ed9a4e4]
sql/sql_select.cc:1969(JOIN::optimize_inner())[0x56518e500b4d]
sql/sql_select.cc:1627(JOIN::optimize())[0x56518e4fd12e]
sql/sql_derived.cc:1026(mysql_derived_optimize(THD*, LEX*, TABLE_LIST*))[0x56518e366f19]
sql/sql_derived.cc:206(mysql_handle_single_derived(LEX*, TABLE_LIST*, unsigned int))[0x56518e36145a]
sql/sql_select.cc:2087(JOIN::optimize_inner())[0x56518e5021ee]
sql/sql_select.cc:1627(JOIN::optimize())[0x56518e4fd12e]
sql/sql_select.cc:4705(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x56518e51d925]
sql/sql_select.cc:417(handle_select(THD*, LEX*, select_result*, unsigned long))[0x56518e4ef358]
sql/sql_parse.cc:6282(execute_sqlcom_select(THD*, TABLE_LIST*))[0x56518e458ac6]
sql/sql_parse.cc:3978(mysql_execute_command(THD*))[0x56518e4479c1]
sql/sql_parse.cc:8063(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x56518e463dc0]
sql/sql_parse.cc:1892(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x56518e439fb9]
sql/sql_parse.cc:1370(do_command(THD*))[0x56518e4368e2]
sql/sql_connect.cc:1410(do_handle_one_connection(CONNECT*, bool))[0x56518e879778]
sql/sql_connect.cc:1314(handle_one_connection)[0x56518e8790dc]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x56518f584df9]
nptl/pthread_create.c:478(start_thread)[0x7fb13a90e609]
x86_64/clone.S:97(__GI___clone)[0x7fb13a4e2293]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x62b0000382a8): SELECT * FROM (
SELECT id,ST_DISTANCE(p1,p2) dist FROM (
SELECT * FROM (
SELECT seq id, POINT(lon,lat) p1 FROM
(SELECT seq,floor(RAND()*90) lon,floor(RAND()*180) lat FROM seq_1_to_10) s
)t
JOIN (
SELECT seq id2, POINT(lon,lat) p2 FROM
(SELECT seq,floor(RAND()*90) lon,floor(RAND()*180) lat FROM seq_1_to_10) s
)t2 ON t.id = t2.id2
)t
)t WHERE dist <= 1000
 
Connection ID (thread ID): 4

Comment by Stoyan [ 2021-02-23 ]

Thanks for the quick feedback.

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