openlink / virtuoso-opensource

Virtuoso is a high-performance and scalable Multi-Model RDBMS, Data Integration Middleware, Linked Data Deployment, and HTTP Application Server Platform
http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/
Other
848 stars 214 forks source link

Fuzzer: Virtuoso 7.2.11 crashed at `dfe_unit_gb_dependant` #1192

Closed fuboat closed 7 months ago

fuboat commented 7 months ago

The PoC is generated by my DBMS fuzzer. It can also be reproduced in the beta docker image.

CREATE TABLE v0 ( v1 INT , v2 NUMERIC NOT NULL CHECK ( v1 >= -32768 AND v1 <= 4 ) ) ;
 SELECT v2 FROM v0 WHERE v1 NOT IN ( 0 ) AND v1 IN ( CASE WHEN v1 = 37 THEN -128 ELSE ( SELECT * , 0 + 16 FROM v0 WHERE 'x' IS NOT NULL GROUP BY NULL * -128 ) END ) ORDER BY v2 / 33 ;

backtrace:

#0 0x73c3c0 (dfe_unit_gb_dependant+0x80)
#1 0x73c704 (dfe_unit_gb_dependant+0x3c4)
#2 0x73d1f2 (dfe_unit_gb_dependant+0xeb2)
#3 0x743eeb (sqlg_make_sort_nodes+0x194b)
#4 0x7465bd (sqlg_group_node+0x55d)
#5 0x748e26 (sqlg_dt_query_1+0x906)
#6 0x72ce44 (sqlg_dfe_code+0x234)
#7 0x71b7bc (sqlc_searched_case+0xb5c)
#8 0x716ada (scalar_exp_generate+0x9fa)
#9 0x7321ec (sqlg_pred_1+0x17c)
#10 0x7324f9 (sqlg_pred_1+0x489)
#11 0x736c81 (sqlg_pred_body_1+0x231)
#12 0x7308f7 (sqlg_make_np_ts+0xc77)
#13 0x749750 (sqlg_dt_query_1+0x1230)
#14 0x74a9e7 (sqlg_top_1+0x107)
#15 0x70ffb4 (sqlo_top_select+0x164)
#16 0x6b9b6f (sql_stmt_comp+0x8bf)
#17 0x6bc9d2 (sql_compile_1+0x1a62)
#18 0x7cba60 (stmt_set_query+0x340)
#19 0x7cd952 (sf_sql_execute+0x922)
#20 0x7cecde (sf_sql_execute_w+0x17e)
#21 0x7d799d (sf_sql_execute_wrapper+0x3d)
#22 0xe214bc (future_wrapper+0x3fc)
#23 0xe28dbe (_thread_boot+0x11e)
#24 0x7f5b31d39609 (start_thread+0xd9)
#25 0x7f5b31b09133 (clone+0x43)

ways to reproduce (write poc to the file /tmp/test.sql first):

# remove the old one
docker container rm virtdb_test -f
# start virtuoso through docker
docker run --name virtdb_test -itd --env DBA_PASSWORD=dba  pkleef/virtuoso-opensource-7
# wait the server starting
sleep 10
# check whether the simple query works
echo "SELECT 1;" | docker exec -i virtdb_test isql 1111 dba
# run the poc
cat /tmp/test.sql | docker exec -i virtdb_test isql 1111 dba
pkleef commented 7 months ago

This issue has been fixed by recent commits on the develop/7 branch