You are viewing a plain text version of this content. The canonical link for it is here.
Posted to codereview@trafodion.apache.org by prashanth-vasudev <gi...@git.apache.org> on 2017/01/10 17:42:06 UTC
[GitHub] incubator-trafodion pull request #909: [TRAFODION-2433] Capture and log call...
GitHub user prashanth-vasudev opened a pull request:
https://github.com/apache/incubator-trafodion/pull/909
[TRAFODION-2433] Capture and log call trace upon internal assert failure.
This is an attempt to capture and log the function call trace incase of internal assertion call failures.
Initial change takes care capturing and logging for executor and some scenarios in compiler. There are additional scenarios in compiler(like in unregistered call back case) this capture can be extended, but currently not included. Additional scenarios can be extended in future.
For call trace functionality to work, linux system calls such as backtrace and backtrace_symbols is used. These calls require gcc compiler option "-rdynamic" be enabled. This compiler option does not generate debug symbols. More info on this is clearly articulated here for reference;
http://stackoverflow.com/questions/8623884/gcc-debug-symbols-g-flag-vs-linkers-rdynamic-option?rq=1
Sample output of assert failure call trace in logs as below.
Executor assert:
============
2017-01-10 03:16:21,973, FATAL, SQL.EXE, Node Number: 0, CPU: 0, PIN: 21080, Process Name: $Z000H7A,,,Process Stack Trace:
../lib/linux/64bit/debug/libtdm_sqlmxevents.so : SQLMXLoggingArea::logSQLMXAssertionFailureEvent(char const*, int, char const*, char const*, int const*, char const*)+0x239
../lib/linux/64bit/debug/libtdm_sqlexport.so : assert_botch_abend(char const*, int, char const*, char const*)+0x89
../lib/linux/64bit/debug/libsort.so : Qsort::Qsort(unsigned int, unsigned int, unsigned int, int, unsigned int, SortScratchSpace*, int, NAMemory*, SortError*, int, SortUtil*)+0x159
../lib/linux/64bit/debug/libsort.so : SortUtil::sortInitialize(SortUtilConfig&, unsigned int)+0x1e5
../lib/linux/64bit/debug/libexecutor.so : ExSortTcb::workUp()+0x1a2
../lib/linux/64bit/debug/libexecutor.so : ExSortTcb::sWorkUp(ex_tcb*)+0x18
../lib/linux/64bit/debug/libexecutor.so : ExSubtask::work()+0x21
../lib/linux/64bit/debug/libexecutor.so : ExScheduler::work(long)+0x5aa
../lib/linux/64bit/debug/libexecutor.so : ex_root_tcb::execute(CliGlobals*, ExExeStmtGlobals*, Descriptor*, ComDiagsArea*&, int)+0x100c
../lib/linux/64bit/debug/libcli.so : CliStatement::execute(CliGlobals*, Descriptor*, ComDiagsArea&, CliStatement::ExecState, int, unsigned int)+0x27ce
../lib/linux/64bit/debug/libcli.so : SQLCLI_PerformTasks+0xa6b
../lib/linux/64bit/debug/libcli.so : SQLCLI_Exec+0x8d
../lib/linux/64bit/debug/libcli.so : SQL_EXEC_Exec+0x14d
../lib/linux/64bit/debug/libexecutor.so : ExeCliInterface::exec(char*, int)+0x122
../lib/linux/64bit/debug/libexecutor.so : ExeCliInterface::fetchRowsPrologue(char const*, int, int, char*)+0x161
../lib/linux/64bit/debug/libexecutor.so : ExeCliInterface::fetchAllRows(Queue*&, char const*, int, int, int, int)+0x81
../lib/linux/64bit/debug/libsqlcomp.so : CmpSeabaseDDL::getSeabaseColumnInfo(ExeCliInterface*, long, NAString const&, NAString const&, NAString const&, char*, int*, int*, int*, ComTdbVirtTableColumnInfo**)+0xdd
../lib/linux/64bit/debug/libsqlcomp.so : CmpSeabaseDDL::getSeabaseUserTableDesc(NAString const&, NAString const&, NAString const&, ComObjectType, int, int, int&)+0x83c
../lib/linux/64bit/debug/libsqlcomp.so : CmpSeabaseDDL::getSeabaseTableDesc(NAString const&, NAString const&, NAString const&, ComObjectType, int)+0x60d
Compiler Assert:
============
2017-01-10 17:24:15,899, FATAL, SQL.EXE, Node Number: 0, CPU: 0, PIN: 18362, Process Name: $Z000EZM,,,Compiler Internal Assert Failure, FILE: ../sqlcomp/nadefaults.cpp, LINE: 5167 CONDITION: FALSE Process Stack Trace:
../lib/linux/64bit/debug/libarkcmplib.so : CmpAssertInternal(char const*, char const*, int)+0x36
../lib/linux/64bit/debug/libsqlcomp.so : NADefaults::isReadonlyAttribute(char const*) const+0x3f
../lib/linux/64bit/debug/liboptimizer.so : ControlQueryDefault::bindNode(BindWA*)+0xf6
../lib/linux/64bit/debug/liboptimizer.so : RelExpr::bindChildren(BindWA*)+0x115
../lib/linux/64bit/debug/liboptimizer.so : RelRoot::bindNode(BindWA*)+0x2069
../lib/linux/64bit/debug/libsqlcomp.so : CmpMain::compile(char const*, int, RelExpr*&, char**, unsigned int*, NAMemory*, CmpMain::CompilerPhase, FragmentDir**, int, int, int*, timeval*, int)+0xf2d
../lib/linux/64bit/debug/libsqlcomp.so : CmpMain::sqlcomp(char const*, int, RelExpr*&, char**, unsigned int*, NAMemory*, CmpMain::CompilerPhase, FragmentDir**, int, int, int*, timeval*, int)+0xed
../lib/linux/64bit/debug/libsqlcomp.so : CmpMain::sqlcomp(QueryText&, int, char**, unsigned int*, NAMemory*, CmpMain::CompilerPhase, FragmentDir**, int)+0x906
../lib/linux/64bit/debug/libarkcmplib.so : CmpStatement::process(CmpMessageSQLText const&)+0x4ff
../lib/linux/64bit/debug/libarkcmplib.so : CmpContext::compileDirect(char*, unsigned int, NAMemory*, int, CmpMessageObj::MessageTypeEnum, char*&, unsigned int&, unsigned int, char const*, int, ComDiagsArea*)+0x56b
../lib/linux/64bit/debug/libcli.so : CliStatement::prepare2(char*, ComDiagsArea&, char*, unsigned int, int, int, unsigned int)+0xecb
../lib/linux/64bit/debug/libcli.so : CliStatement::prepare(char*, ComDiagsArea&, char*, unsigned int, int, int, unsigned int)+0x17c
../lib/linux/64bit/debug/libcli.so : SQLCLI_Prepare2+0x4c4
../lib/linux/64bit/debug/libcli.so : SQL_EXEC_Prepare2+0xce
../lib/linux/64bit/debug/libsqlcilib.so : SqlCmd::do_prepare(SqlciEnv*, PrepStmt*, char*, int, int, int*, int*)+0x726
../lib/linux/64bit/debug/libsqlcilib.so : DML::process(SqlciEnv*)+0x20d
../lib/linux/64bit/debug/libsqlcilib.so : SqlciEnv::executeCommands(InputStmt*&)+0x4ee
../lib/linux/64bit/debug/libsqlcilib.so : SqlciEnv::run()+0x51
sqlci : main+0x38b
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/prashanth-vasudev/incubator-trafodion btassert
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-trafodion/pull/909.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #909
----
commit 49a6bab2000eaf74336e4ea69b3fb75ccb7b6ff5
Author: Prashant Vasudev <pr...@esgyn.com>
Date: 2017-01-10T17:25:49Z
[TRAFODION-2433] Capture and log call trace upon internal assert failure.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-trafodion pull request #909: [TRAFODION-2433] Capture and log call...
Posted by selvaganesang <gi...@git.apache.org>.
Github user selvaganesang commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/909#discussion_r95595859
--- Diff: core/sql/sqlmxevents/logmxevent_traf.cpp ---
@@ -185,9 +187,9 @@ void SQLMXLoggingArea::logPrivMgrInfo(const char *filename,
}
-static void writeStackTrace(char *s, int bufLen)
+Int32 writeStackTrace(char *s, int bufLen)
--- End diff --
Looks like buflen is not being used to limit the stack trace being copied. This can lead to buffer overflow. 8K is too small for the deep stack we would get in Trafodion
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-trafodion pull request #909: [TRAFODION-2433] Capture and log call...
Posted by prashanth-vasudev <gi...@git.apache.org>.
Github user prashanth-vasudev commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/909#discussion_r98519641
--- Diff: core/sql/arkcmp/CompException.cpp ---
@@ -113,11 +114,21 @@ FatalException::FatalException(const char *msg,
else {
msg_[0] = 0;
}
+ if(stackTrace) {
+ strncpy(stackTrace_, stackTrace, sizeof(stackTrace_));
+ stackTrace_[sizeof(stackTrace_)-1] = 0;
--- End diff --
Thanks for the review. Have fixed to address the issue. sizeof(stackTrace_) should be ok here since it will be receiving buffer size.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-trafodion pull request #909: [TRAFODION-2433] Capture and log call...
Posted by selvaganesang <gi...@git.apache.org>.
Github user selvaganesang commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/909#discussion_r98322624
--- Diff: core/sql/arkcmp/CompException.cpp ---
@@ -113,11 +114,21 @@ FatalException::FatalException(const char *msg,
else {
msg_[0] = 0;
}
+ if(stackTrace) {
+ strncpy(stackTrace_, stackTrace, sizeof(stackTrace_));
+ stackTrace_[sizeof(stackTrace_)-1] = 0;
--- End diff --
There is a possibility of the buffer over read with this code.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-trafodion pull request #909: [TRAFODION-2433] Capture and log call...
Posted by selvaganesang <gi...@git.apache.org>.
Github user selvaganesang commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/909#discussion_r98810157
--- Diff: core/sql/arkcmp/CompException.cpp ---
@@ -113,11 +114,21 @@ FatalException::FatalException(const char *msg,
else {
msg_[0] = 0;
}
+ if(stackTrace) {
+ strncpy(stackTrace_, stackTrace, sizeof(stackTrace_));
+ stackTrace_[sizeof(stackTrace_)-1] = 0;
--- End diff --
@prashanth-vasudev What I meant is if the stackTrace_ is declared as char *, then sizeof(stackTrace_) would return 4 or 8 bytes irrespective of the buffer size that was allocated to hold the stack trace. If it is declared as char stackTrace_[<max_stack_trace_len>], then sizeof(stackTrace_) will be correct.
This article illustrates the concern I mentioned via a program.
http://www.geeksforgeeks.org/using-sizof-operator-with-array-paratmeters/
This may not be applicable here though because stackTrace_ is the member variable of the class and this is the method of the class.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-trafodion pull request #909: [TRAFODION-2433] Capture and log call...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/incubator-trafodion/pull/909
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-trafodion pull request #909: [TRAFODION-2433] Capture and log call...
Posted by prashanth-vasudev <gi...@git.apache.org>.
Github user prashanth-vasudev commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/909#discussion_r98937516
--- Diff: core/sql/arkcmp/CompException.cpp ---
@@ -113,11 +114,21 @@ FatalException::FatalException(const char *msg,
else {
msg_[0] = 0;
}
+ if(stackTrace) {
+ strncpy(stackTrace_, stackTrace, sizeof(stackTrace_));
+ stackTrace_[sizeof(stackTrace_)-1] = 0;
--- End diff --
Yes. stackTrace_ and msg_ are declared as stackTrace_[max len] and msg_[max len] in core/sql/arkcmp/CompException.h. This is part of the diffs in this PR.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-trafodion pull request #909: [TRAFODION-2433] Capture and log call...
Posted by selvaganesang <gi...@git.apache.org>.
Github user selvaganesang commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/909#discussion_r98322656
--- Diff: core/sql/arkcmp/CompException.cpp ---
@@ -113,11 +114,21 @@ FatalException::FatalException(const char *msg,
else {
msg_[0] = 0;
}
+ if(stackTrace) {
+ strncpy(stackTrace_, stackTrace, sizeof(stackTrace_));
+ stackTrace_[sizeof(stackTrace_)-1] = 0;
--- End diff --
Though sizeof(stackTrace_) should work fine in this case you are implicitly assuming that it is not a pointer
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---