UDF: Multi-valued scalar UDF with clob/blob cores sqlci with SIGSEGV

Bug #1441378 reported by Weishiun Tsai on 2015-04-07
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Trafodion
In Progress
High
Suresh Subbiah

Bug Description

While a single-valued scalar UDF works fine with the clob or blob data type. A multi-valued scalar UDF cores sqlci with SIGSEGV even with just 2 clob or blob output values.

Since clob and blob data types require large buffers, I am assuming this type of scalar UDF is stressing the heap used internally somewhere. But a core is always bad. If there is a limit on how clob and blob can be handled in a scalar UDF, a check should be put in place and an error should be returned more gracefully.

This is seen on the v0407 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
(4) Change the line “create library qa_udf_lib file '<mydir>/myudf.so';”; in mytest.sql and fill in <mydir>
(5) From sqlci, obey mytest.sql

-----------------------------------------------------------

Here is the execution output:

>>create schema mytest;

--- SQL operation complete.
>>set schema mytest;

--- SQL operation complete.
>>
>>create library qa_udf_lib file '<mydir>/myudf.so';

--- SQL operation complete.
>>
>>create function qa_udf_clob
+>(INVAL clob)
+>returns (c_clob clob)
+>language c
+>parameter style sql
+>external name 'qa_func_vcstruct'
+>library qa_udf_lib
+>deterministic
+>state area size 1024
+>allow any parallelism
+>no sql;

--- SQL operation complete.
>>
>>create function qa_udf_blob
+>(INVAL blob)
+>returns (c_blob blob)
+>language c
+>parameter style sql
+>external name 'qa_func_vcstruct'
+>library qa_udf_lib
+>deterministic
+>state area size 1024
+>allow any parallelism
+>no sql;

--- SQL operation complete.
>>
>>create function qa_udf_clob_mvf
+>(INVAL clob)
+>returns (c_clob1 clob, c_clob2 clob)
+>language c
+>parameter style sql
+>external name 'qa_func_vcstruct_mvf'
+>library qa_udf_lib
+>deterministic
+>state area size 1024
+>allow any parallelism
+>no sql;

--- SQL operation complete.
>>
>>create function qa_udf_blob_mvf
+>(INVAL blob)
+>returns (c_blob1 blob, c_blob2 blob)
+>language c
+>parameter style sql
+>external name 'qa_func_vcstruct_mvf'
+>library qa_udf_lib
+>deterministic
+>state area size 1024
+>allow any parallelism
+>no sql;

--- SQL operation complete.
>>
>>create table mytable (c_clob clob, c_blob blob);

--- SQL operation complete.
>>insert into mytable values ('CLOB_1', 'BLOB_1');

--- 1 row(s) inserted.
>>
>>select
+>cast(qa_udf_clob(c_clob) as char(10)),
+>cast(qa_udf_blob(c_blob) as char(10))
+>from mytable;

(EXPR) (EXPR)
---------- ----------

CLOB_1 BLOB_1

--- 1 row(s) selected.
>>
>>select qa_udf_clob_mvf(c_clob) from mytable;
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007ffff4c5b9a2, pid=18680, tid=140737187650592
#
# 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 [libexecutor.so+0x2489a2] ExSimpleSQLBuffer::init(NAMemory*)+0x92
#
# Core dump written. Default location: <mydir>/core or core.18680
#
# An error report file with more information is saved as:
# <mydir>/hs_err_pid18680.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
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 0x00007ffff7120a55 in os::abort(bool) ()
   from /opt/home/tools/jdk1.7.0_67/jre/lib/amd64/server/libjvm.so
#3 0x00007ffff72a0f87 in VMError::report_and_die() ()
   from /opt/home/tools/jdk1.7.0_67/jre/lib/amd64/server/libjvm.so
#4 0x00007ffff72a150e in crash_handler(int, siginfo*, void*) ()
   from /opt/home/tools/jdk1.7.0_67/jre/lib/amd64/server/libjvm.so
#5 0x00007ffff711fbf2 in os::Linux::chained_handler(int, siginfo*, void*) ()
   from /opt/home/tools/jdk1.7.0_67/jre/lib/amd64/server/libjvm.so
#6 0x00007ffff71258d6 in JVM_handle_linux_signal ()
   from /opt/home/tools/jdk1.7.0_67/jre/lib/amd64/server/libjvm.so
#7 <signal handler called>
#8 0x00007ffff7140ce9 in ParallelScavengeHeap::block_start(void const*) const
    () from /opt/home/tools/jdk1.7.0_67/jre/lib/amd64/server/libjvm.so
#9 0x00007ffff71182b0 in os::print_location(outputStream*, long, bool) ()
   from /opt/home/tools/jdk1.7.0_67/jre/lib/amd64/server/libjvm.so
#10 0x00007ffff71252bb in os::print_register_info(outputStream*, void*) ()
   from /opt/home/tools/jdk1.7.0_67/jre/lib/amd64/server/libjvm.so
#11 0x00007ffff729f57c in VMError::report(outputStream*) ()
   from /opt/home/tools/jdk1.7.0_67/jre/lib/amd64/server/libjvm.so
#12 0x00007ffff72a0b8a in VMError::report_and_die() ()
   from /opt/home/tools/jdk1.7.0_67/jre/lib/amd64/server/libjvm.so
#13 0x00007ffff712596f in JVM_handle_linux_signal ()
   from /opt/home/tools/jdk1.7.0_67/jre/lib/amd64/server/libjvm.so
#14 <signal handler called>
#15 init (this=0x7fffe971a910, heap=0x7fffe96c90e8) at ../exp/ExpSqlTupp.h:441
#16 init (this=0x7fffe971a910, heap=0x7fffe96c90e8)
    at ../executor/ExSimpleSqlBuffer.h:71
#17 ExSimpleSQLBuffer::init (this=0x7fffe971a910, heap=0x7fffe96c90e8)
    at ../executor/ExSimpleSqlBuffer.cpp:237
#18 0x00007ffff4c5bbc9 in ExSimpleSQLBuffer::ExSimpleSQLBuffer (
    this=<value optimized out>, numberTuples=18432, tupleSize=200016,
    heap=0x7fffe96c90e8) at ../executor/ExSimpleSqlBuffer.cpp:79
#19 0x00007ffff4c4774f in ExProbeCacheTcb::ExProbeCacheTcb (
    this=0x7fffe971a838, probeCacheTdb=..., child_tcb=..., glob=0x7fffe96ea640)
    at ../executor/ExProbeCache.cpp:85
#20 0x00007ffff4c47af6 in ExProbeCacheTdb::build (this=0x7fffd5786c88,
    glob=<value optimized out>) at ../executor/ExProbeCache.cpp:45
#21 0x00007ffff4b6c831 in ExOnljTdb::build (this=0x7fffd5786dd8,
    glob=0x7fffe96ea640) at ../executor/ex_onlj.cpp:66
#22 0x00007ffff4b75171 in ex_root_tdb::build (this=0x7fffd57840c8,
    cliGlobals=0xb84320, glob=0x7fffe96ea640) at ../executor/ex_root.cpp:206
#23 0x00007ffff5fa7295 in CliStatement::fixup (this=0x7fffe96b8db8,
    cliGlobals=0xb84320, input_desc=<value optimized out>, diagsArea=...,
    doSimCheck=@0x7fffffff2018, partitionUnavailable=@0x7fffffff201c,
    donePrepare=0) at ../cli/Statement.cpp:2953
#24 0x00007ffff5fac0e1 in CliStatement::execute (this=0x7fffe96b8db8,
    cliGlobals=0xb84320, input_desc=0x7fffe96c8128,
    diagsArea=<value optimized out>, execute_state=<value optimized out>,
    fixupOnly=0, cliflags=0) at ../cli/Statement.cpp:3990
#25 0x00007ffff5f5425c in SQLCLI_PerformTasks(CliGlobals *, ULng32, SQLSTMT_ID *, SQLDESC_ID *, SQLDESC_ID *, Lng32, Lng32, typedef __va_list_tag __va_list_tag *, SQLCLI_PTR_PAIRS *, SQLCLI_PTR_PAIRS *) (cliGlobals=0xb84320, tasks=4882,
    statement_id=0x1e1cfe0, input_descriptor=0x223e190, output_descriptor=0x0,
    num_input_ptr_pairs=0, num_output_ptr_pairs=0, ap=0x7fffffff21b0,
    input_ptr_pairs=0x0, output_ptr_pairs=0x0) at ../cli/Cli.cpp:3285
#26 0x00007ffff5f54f92 in SQLCLI_Exec(CliGlobals *, SQLSTMT_ID *, SQLDESC_ID *, Lng32, typedef __va_list_tag __va_list_tag *, SQLCLI_PTR_PAIRS *) (
    cliGlobals=<value optimized out>, statement_id=<value optimized out>,
    input_descriptor=<value optimized out>,
    num_ptr_pairs=<value optimized out>, ap=<value optimized out>,
    ptr_pairs=<value optimized out>) at ../cli/Cli.cpp:3532
#27 0x00007ffff5fbb27b in SQL_EXEC_Exec (statement_id=0x1e1cfe0,
    input_descriptor=0x223e190, num_ptr_pairs=0) at ../cli/CliExtern.cpp:2071
#28 0x00007ffff79cc81b in SqlCmd::doExec (sqlci_env=0xb830f0, stmt=0x1e1cfe0,
    prep_stmt=<value optimized out>, numUnnamedParams=<value optimized out>,
    unnamedParamArray=<value optimized out>,
    unnamedParamCharSetArray=<value optimized out>, handleError=1)
    at ../sqlci/SqlCmd.cpp:1780
#29 0x00007ffff79cd212 in SqlCmd::do_execute (sqlci_env=0xb830f0,
    prep_stmt=0x1e1f020, numUnnamedParams=0, unnamedParamArray=0x0,
    unnamedParamCharSetArray=0x0, prepcode=0) at ../sqlci/SqlCmd.cpp:2116
#30 0x00007ffff79cd93d in DML::process (this=0x223f860, sqlci_env=0xb830f0)
    at ../sqlci/SqlCmd.cpp:2890
#31 0x00007ffff79b37f4 in Obey::process (this=0xb85460,
    sqlci_env=<value optimized out>) at ../sqlci/Obey.cpp:264
#32 0x00007ffff79bbfd4 in SqlciEnv::run (this=0xb830f0,
    in_filename=<value optimized out>, input_string=<value optimized out>)
    at ../sqlci/SqlciEnv.cpp:726
#33 0x00000000004019c2 in main (argc=3, argv=0x7fffffff3d18)
    at ../bin/SqlciMain.cpp:326

Weishiun Tsai (wei-shiun-tsai) wrote :
Changed in trafodion:
assignee: nobody → Suresh Subbiah (suresh-subbiah)
milestone: r1.1 → r1.2
Changed in trafodion:
status: New → In Progress
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments