Aix Oracle 使用sbttest测试libobk.a(shr.o)出现段错误

weixin_41270364 2026-06-02 14:37:59

操作系统:AIX 7.1
数据库版本: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
操作:使用sbttest 测试libobk.a(shr.o)
现象:两次成功调用sbtinit函数后,出现段错误(同样的代码在linux系统上编译的libobk.so可正常加载使用)

 

#include <sbt.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

static void _log(const char *msg) {
    write(STDERR_FILENO, msg, strlen(msg));
    write(STDERR_FILENO, "\n", 1);
}

int sbtopen(sbtctx *ctx, int flags) {
    return 0;
}
int sbtclose(sbtctx *ctx, int flags) {
    return 0;
}
int sbtread(sbtctx *ctx, void *buf, int *len) {
    return 0;
}
int sbtwrite(sbtctx *ctx, void *buf, int *len) {
    return 0;
}
int sbtremove(sbtctx *ctx, int flags, const char **files) {
    return 0;
}

int sbtinfo(struct sbtctx *ctx, int flags, const char **files, struct sbtinfo_t **output) {
    _log("sbtinfo");
    static struct sbtinfo_t info[2];
    info[0].type = SBTINFO_END;
    info[0].value = NULL;
    *output = info;
    return 0;
}


int sbtinit2(sbtctx *ctx, int flags, const struct sbtinfo_t *args) { _log("sbtinit2"); return 0; }
int sbtcommand(sbtctx *ctx, int flags, const char *cmd) { _log("sbtcommand"); return 0; }
int sbtbackup(sbtctx *ctx, int flags, const char *fn, const struct sbtinfo_t *info, int bs, int nu, int d) { _log("sbtbackup"); return 0; }
int sbtclose2(sbtctx *ctx, char flags) { _log("sbtclose2"); return 0; }
int sbtend(sbtctx *ctx, char flags) { _log("sbtend"); return 0; }
int sbterror(sbtctx *ctx, int f, int *e, const char **ne, char **ue) { _log("sbterror"); return 0; }
int sbtinfo2(sbtctx *ctx, char f, const char **fs, struct sbtinfo_t **o) { _log("sbtinfo2"); return 0; }
int sbtread2(sbtctx *ctx, int f, void *b) { _log("sbtread2"); return 0; }
int sbtremove2(sbtctx *ctx, int f, const char **fs) { _log("sbtremove2"); return 0; }
int sbtrestore(sbtctx *ctx, int f, char *fn, int bs) { _log("sbtrestore"); return 0; }
int sbtwrite2(sbtctx *ctx, int f, void *b) { _log("sbtwrite2"); return 0; }

int sbtinit(sbtdata *data, const struct sbtinfo_t *input, sbtopt **output) {
    _log("sbtinit");
    static sbtopt opts[20];
    static int sbt2 = 2;
    static int api_ver = 0x0200;
    static char *vendor = "DemoSBT";
    static sbtapi api;
    static size_t ctx_size = 8192;
    static unsigned int maxsize = 2*1024*1024;
    static unsigned int mm_ver = 1;
    int i = 0;
    memset(&api, 0, sizeof(api));
    api.sbtinit2   = sbtinit2;
    api.sbtcommand = sbtcommand;
    api.sbtbackup  = sbtbackup;
    api.sbtclose2  = sbtclose2;
    api.sbtend     = sbtend;
    api.sbterror   = sbterror;
    api.sbtinfo2   = sbtinfo2;
    api.sbtread2   = sbtread2;
    api.sbtremove2 = sbtremove2;
    api.sbtrestore = sbtrestore;
    api.sbtwrite2  = sbtwrite2;

    opts[i].type = SBTOPT_2;            opts[i].value = &sbt2;           i++;
    opts[i].type = SBTOPT_API_VERSION;  opts[i].value = &api_ver;        i++;
    opts[i].type = SBTOPT_VENDOR;       opts[i].value = vendor;          i++;
    opts[i].type = SBTOPT_API;          opts[i].value = &api;            i++;
    opts[i].type = SBTOPT_CONTEXT_SIZE; opts[i].value = &ctx_size;       i++;
    opts[i].type = SBTOPT_MAXSIZE;      opts[i].value = &maxsize;        i++;
    opts[i].type = SBTOPT_MM_VERSION;   opts[i].value = &mm_ver;         i++;
    opts[i].type = SBTOPT_END;          opts[i].value = NULL;

    *output = opts;
    data->status = 0;
    data->error = 0;
    return 0;
}

 

...全文
172 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

17,134

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧