When using Pro*C (a embedded SQL preprocessor from Oracle for C-Code) or OCI I noticed that the connect/init routine installs some signal handlers.
当使用Pro * C(Oracle for C-Code的嵌入式SQL预处理器)或OCI时,我注意到connect / init例程安装了一些信号处理程序。
That means before a
这意味着之前
EXEC SQL CONNECT :username IDENTIFIED BY :password USING :dbspec ;
or a
OCIEnvNlsCreate()
I can verify that for example those signals have following handlers:
我可以验证,例如这些信号有以下处理程序:
No NAME Pointer SA_SIGINFO SIG_DFL SIG_IGN
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
1 SIGHUP (nil) false true false
2 SIGINT (nil) false true false
3 SIGQUIT (nil) false true false
4 SIGILL (nil) false true false
5 SIGTRAP (nil) false true false
6 SIGABRT (nil) false true false
7 SIGBUS (nil) false true false
8 SIGFPE (nil) false true false
9 SIGKILL (nil) false true false
10 SIGUSR1 (nil) false true false
11 SIGSEGV (nil) false true false
12 SIGUSR2 (nil) false true false
13 SIGPIPE (nil) false true false
14 SIGALRM (nil) false true false
After the connect/init statement the table looks like:
在connect / init语句之后,表格如下所示:
No NAME Pointer SA_SIGINFO SIG_DFL SIG_IGN
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
1 SIGHUP (nil) false true false
2 SIGINT 0x7eff9e60bdac true false false
3 SIGQUIT 0x7eff9ea17f9c true false false
4 SIGILL 0x7eff9ea17f9c true false false
5 SIGTRAP 0x7eff9ea17f9c true false false
6 SIGABRT 0x7eff9ea17f9c true false false
7 SIGBUS 0x7eff9ea17f9c true false false
8 SIGFPE 0x7eff9ea17f9c true false false
9 SIGKILL (nil) false true false
10 SIGUSR1 (nil) false true false
11 SIGSEGV 0x7eff9ea17f9c true false false
12 SIGUSR2 (nil) false true false
13 SIGPIPE 0x1 true false true
14 SIGALRM (nil) false true false
where 0x7eff9e60bdac denotes sslsshandler()
and 0x7eff9ea17f9c denotes skgesig_sigactionHandler()
- both symbols defined in libclntsh.so.11.1
- the Oracle runtime library.
其中0x7eff9e60bdac表示sslsshandler(),0x7eff9ea17f9c表示skgesig_sigactionHandler() - libclntsh.so.11.1中定义的两个符号 - Oracle运行时库。
I am concerned about those Oracle signal handlers because it seems that they introduce quite some non-deterministic behaviour. That means depending on the OS, hardware and kind of segfault/abort I've observed following behaviour:
我担心那些Oracle信号处理程序,因为它们似乎引入了一些非确定性的行为。这意味着取决于操作系统,硬件和段错误/中止的类型,我观察到以下行为:
- an ugly stacktrace that does not contain much useful information
- direct program exit with exit-status 1 - without any core file writing and no error message
- direct program exit with exit-status 0 (sic!)
一个丑陋的堆栈跟踪,不包含太多有用的信息
退出状态为1的直接程序退出 - 没有任何核心文件写入且没有错误消息
退出状态为0的直接程序退出(原文如此!)
Especially the last behaviour is grotesque.
特别是最后的行为是怪诞的。
Thus, I am interested in:
因此,我感兴趣的是:
- the motivation - why are those signal handlers installed by Oracle?
- how to disable them? - at least for signals that yield a core file by default - because for my use-case I want a core under those circumstances (during development) or a reliable and informative exit status in production
- is it safe to overwrite the Oracle signal-handler via e.g.
act.sa_handler = SIG_DFL; sigaction(SIGABRT, &act, 0);
? - what are the disadvantages of resetting SIGABRT/SIGSEGV and friends to SIG_DFL after connect?
动机 - 为什么Oracle安装了那些信号处理程序?
如何禁用它们? - 至少对于默认产生核心文件的信号 - 因为对于我的用例,我想在这种情况下(开发期间)获得核心,或者在生产中获得可靠且信息丰富的退出状态
通过例如覆盖Oracle信号处理程序是否安全act.sa_handler = SIG_DFL; sigaction(SIGABRT,&act,0); ?
连接后将SIGABRT / SIGSEGV和朋友重置为SIG_DFL有什么缺点?
2 个解决方案
#1
8
Signal handling and diagnostic framework considerations: the OCI diagnostic framework installs signal handlers that may impact any signal handling that you use in your application. You can disable OCI signal handling by setting
信号处理和诊断框架注意事项:OCI诊断框架安装可能影响您在应用程序中使用的任何信号处理的信号处理程序。您可以通过设置禁用OCI信号处理
DIAG_SIGHANDLER_ENABLED=FALSE
in the sqlnet.ora file. Refer to "Fault Diagnosability in OCI" in Oracle Call Interface Programmer's Guide for information.
在sqlnet.ora文件中。有关信息,请参阅“Oracle调用接口程序员指南”中的“OCI中的故障可诊断性”。
Please try to configure this environment variable in sqlnet.ora file
请尝试在sqlnet.ora文件中配置此环境变量
#2
0
I would patch the Oracle .so
file to replace the sigaction
string with nosigactn
and make a no-op function in your program called nosigactn
with the same signature as sigaction
.
我会修补Oracle .so文件以用nosigactn替换sigaction字符串,并在你的程序中创建一个名为nosigactn的no-op函数,其签名与sigaction相同。
#1
8
Signal handling and diagnostic framework considerations: the OCI diagnostic framework installs signal handlers that may impact any signal handling that you use in your application. You can disable OCI signal handling by setting
信号处理和诊断框架注意事项:OCI诊断框架安装可能影响您在应用程序中使用的任何信号处理的信号处理程序。您可以通过设置禁用OCI信号处理
DIAG_SIGHANDLER_ENABLED=FALSE
in the sqlnet.ora file. Refer to "Fault Diagnosability in OCI" in Oracle Call Interface Programmer's Guide for information.
在sqlnet.ora文件中。有关信息,请参阅“Oracle调用接口程序员指南”中的“OCI中的故障可诊断性”。
Please try to configure this environment variable in sqlnet.ora file
请尝试在sqlnet.ora文件中配置此环境变量
#2
0
I would patch the Oracle .so
file to replace the sigaction
string with nosigactn
and make a no-op function in your program called nosigactn
with the same signature as sigaction
.
我会修补Oracle .so文件以用nosigactn替换sigaction字符串,并在你的程序中创建一个名为nosigactn的no-op函数,其签名与sigaction相同。