sqlcxt() 中的分段错误

发布于 2024-10-21 16:44:58 字数 990 浏览 10 评论 0原文

我在 C 代码中使用以下函数来连接到 oracle 数据库。下面的函数有时会导致分段错误,而有时则工作。

static int Connect(char *string)
{
EXEC SQL BEGIN DECLARE SECTION;
    static char login[80];
EXEC SQL END DECLARE SECTION;

    strcpy((char *)login, string);

    EXEC SQL CONNECT :login ;

    if (sqlca.sqlcode < 0) 
        return(-1);
    return(0);
}

下面是使用核心文件生成的调试器报告。对此有何建议。

program terminated by signal SEGV (no mapping at the fault address)
0xffffffffffffffff:     <bad address 0xffffffffffffffff>
Current function is Connect
    375    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);

  [20] 0xffffffff7e587078(0x0, 0x100210f80, 0xffffffff7fffc850, 0x1000e4dd0, 0xff000000000000, 0x8080808080808080), at 0xffffffff7e587078
=>[21] login(orastring = 0xffffffff7fffcef8 "user123/[email protected]"), line 375 in "connect.c"

I am using the below function in my C code for connecting to the oracle database. The below function is causing segmentation fault sometime while work at the other time

static int Connect(char *string)
{
EXEC SQL BEGIN DECLARE SECTION;
    static char login[80];
EXEC SQL END DECLARE SECTION;

    strcpy((char *)login, string);

    EXEC SQL CONNECT :login ;

    if (sqlca.sqlcode < 0) 
        return(-1);
    return(0);
}

Below is the debugger report generated with the core file. Any suggestions on this.

program terminated by signal SEGV (no mapping at the fault address)
0xffffffffffffffff:     <bad address 0xffffffffffffffff>
Current function is Connect
    375    sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);

  [20] 0xffffffff7e587078(0x0, 0x100210f80, 0xffffffff7fffc850, 0x1000e4dd0, 0xff000000000000, 0x8080808080808080), at 0xffffffff7e587078
=>[21] login(orastring = 0xffffffff7fffcef8 "user123/[email protected]"), line 375 in "connect.c"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初心未许 2024-10-28 16:44:58

从调试器报告来看,段错误是由于访问了无法访问的内存。

我建议两个地方进行一些检查。
(a) 在使用输入参数 'string' 之前检查其是否为 NULL 值。
(b) 使用 strncpy() 代替 strcpy()

From the debugger report, seg fault is because of accessing inaccessible memory.

I would suggest two places to put some checks.
(a) Check input parameter 'string' for NULL values before using it.
(b) Use strncpy() instead of strcpy()

花开雨落又逢春i 2024-10-28 16:44:58

遇到了很多类似的问题(使用 Oracle 8.1.7),我在网上找到的大部分内容只是说:Oracle Bug(特别是如果 sqlcxt 最终调用 lxchcsn

我有一个运行 25 个线程的程序,它似乎可以工作。我更改一些设置意味着数据库调用的频率增加,并且当我在数据库调用周围放置互斥体时,这个问题就消失了(这很奇怪,因为我可以看到 25 个单独的数据库连接 - 每个线程都有自己的连接)。 context) - 并且放入互斥体有点违背了多线程的目的,

基本上,我认为这是一个 Oracle 问题。

Have had many similar issues (using Oracle 8.1.7) and most of what I've found on the 'net simply says: Oracle Bug (especially if sqlcxt eventually calls lxchcsn

I had a program running 25 threads which seemed to work. I changes some settings that meant an increase in the frequency of DB calls and this issue started to occur. When I put mutexes around the DB calls, the issue went away (which is bizarre because I could see 25 individual DB connections - each thread had its own context) - and putting in the mutexes sort of defeats the purpose of multi-threading.

Basically, I think it's an Oracle issue

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文