TMUDF: A TMUDF with nonexisting external name crashes sqlci with a core
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Trafodion |
Fix Released
|
High
|
Hans Zeller |
Bug Description
As shown in the following example, 2 TMUDFs were defined. qa_tmudf1() was defined with a valid external name from the so file, while qa_tmudf2() was defined with an external name that does not exist. Invoking qa_tmudf2() crashes sqlci with a core at bindRowValues()
It’s not unusual for a user to misspell the external name of a tmudf at the definition time, especially when the external name is case sensitive. This error should be handled more gracefully, either by giving a proper error message at the definition time, or at the run time, instead of crashing sqlci with a core.
This is seen on the v0305 build installed on a workstation. To reproduce it:
(1) Download the attached tar file and untar it to get the 3 files in there. Put the files in any directory <mydir>
(2) Make sure that you have run ./sqenv.sh of your Trafodion instance first as building UDF needs $MY_SQROOT for the header files.
(3) Run build.sh from <mydir> to build the UDF so file.
(4) Change the line create library qaTmudfLib file '<mydir>
(5) From sqlci, obey mytest.sql
-------
Here is the execution output:
>>log mytest.log clear;
>>drop schema mytest cascade;
*** ERROR[1003] Schema TRAFODION.MYTEST does not exist.
--- SQL operation failed with errors.
>>create schema mytest;
--- SQL operation complete.
>>set schema mytest;
--- SQL operation complete.
>>
>>create library qaTmudfLib file '<mydir>
--- SQL operation complete.
>>
>>create table mytable (a int, b int);
--- SQL operation complete.
>>insert into mytable values (1,1),(2,2);
--- 2 row(s) inserted.
>>
>>create table_mapping function qa_tmudf1()
+>external name 'QA_TMUDF'
+>language cpp
+>library qaTmudfLib;
--- SQL operation complete.
>>
>>select * from UDF(qa_
A B
----------- -----------
1 1
2 2
--- 2 row(s) selected.
>>
>>create table_mapping function qa_tmudf2()
+>external name 'DONTEXIST'
+>language cpp
+>library qaTmudfLib;
--- SQL operation complete.
>>
>>select * from UDF(qa_
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fffef
#
# JRE version: Java(TM) SE Runtime Environment (7.0_67-b01) (build 1.7.0_67-b01)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [liboptimizer.
#
# Core dump written. Default location: <my_dir>/core or core.32392
#
# An error report file with more information is saved as:
# <my_dir>
#
# If you would like to submit a bug report, please visit:
# http://
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Aborted (core dumped)
-------
Here is the stack trace of the core:
(gdb) bt
#0 0x00000039e28328a5 in raise () from /lib64/libc.so.6
#1 0x00000039e283400d in abort () from /lib64/libc.so.6
#2 0x00007ffff7122a55 in os::abort(bool) ()
from /opt/home/
#3 0x00007ffff72a2f87 in VMError:
from /opt/home/
#4 0x00007ffff712796f in JVM_handle_
from /opt/home/
#5 <signal handler called>
#6 0x00007fffef80a975 in bindRowValues (bindWA=
exprTree=<value optimized out>, vidList=..., parent=<value optimized out>,
inTrueRoot=1) at ../optimizer/
#7 0x00007fffef8188fa in RelRoot::bindNode (this=0x7fffd73
bindWA=
#8 0x00007ffff111406e in CmpMain::compile (this=0x7ffffff
input_
gen_
fragmentDir
cacheable=
at ../sqlcomp/
#9 0x00007ffff1116e7c in CmpMain::sqlcomp (this=0x7ffffff
input_
gen_
fragmentDir
cacheable=
at ../sqlcomp/
#10 0x00007ffff1118180 in CmpMain::sqlcomp (this=0x7ffffff
gen_
phase=
at ../sqlcomp/
#11 0x00007ffff55c7478 in CmpStatement:
sqltext=<value optimized out>) at ../arkcmp/
#12 0x00007ffff55ba903 in CmpContext:
data=
charset=15, op=CmpMessageOb
gen_
at ../arkcmp/
#13 0x00007ffff5faf857 in CliStatement:
source=
passed_
at ../cli/
#14 0x00007ffff5fafca6 in CliStatement:
source=
passed_
unpackTdbs=1, cliFlags=129) at ../cli/
#15 0x00007ffff5f5f984 in SQLCLI_Prepare2 (cliGlobals=
statement_
gencode_len=0, ret_gencode_
query_
uniqueStmtI
#16 0x00007ffff5fbcf50 in SQL_EXEC_Prepare2 (statement_
sql_
query_
uniqueStmtI
flags=129) at ../cli/
#17 0x00007ffff79cedaf in SqlCmd::do_prepare (sqlci_
prep_
sqlStmt=
statisticsT
#18 0x00007ffff79ce1b0 in DML::process (this=0x295ba10, sqlci_env=0xb819b0)
at ../sqlci/
#19 0x00007ffff79b4a84 in Obey::process (this=0x29504c0,
sqlci_
#20 0x00007ffff79bcf14 in SqlciEnv::run (this=0xb819b0,
in_
at ../sqlci/
#21 0x00000000004019c2 in main (argc=3, argv=0x7fffffff
at ../bin/
Changed in trafodion: | |
assignee: | nobody → Hans Zeller (hans-zeller) |
Thanks, yes, I see two things wrong here. First, the CREATE FUNCTION should fail with an error, because we didn't find the entry point. Second, the SELECT needs to give a good error message, also saying that it cannot find the entry point.