Pro*C - Program hangs if not started by UNIX user Oracle

From: Andreas Blumer <blumer_at_akros.ch>
Date: Mon, 08 Jan 2001 14:23:59 +0100
Message-ID: <3A59BF6F.FCD6E477_at_akros.ch>


Hello,

[Quoted] Does someone already had a similar problem ?

We are developping C++ programs which connects via Pro*C to Oracle 8.1.6 (unter SunOS 5.8).

They worked perfectly until last Christmas. Then we replaced our file server. Since then our programs block when trying to connect to Oracle with the statement:

        EXEC SQL CONNECT :dbname;

Our Oracle and C++ programs run on another computer (both on the same one).

In order to search for the error, I adapted (simplified) an example program of Oracle.

When I start this program as the user Oracle it works (it connects to the DB, performs an SELECT USER FROM DUAL; and disconnect). If I do the same with the DB and/or the listenner stopped, or hide the tnsnames.ora or use a wrong SID, usename, password, I get an error message from this program.

When I start it as another user (I call it JOHN) (which worked before) and make all the same tests as above, my test program simply waits undefinitly.

If I try to access my DB with SQLPLUS (as JOHN and as Oracle) it works.

I already tried the following without success:

  • Compared the environment variables of both users and also set the important environment variables of JOHN to the values of the Oracle user.
  • Examined the access rights of the files under ORACLE_BASE and set the read rights of this files, so that "others" can read them.

The program behaves the same if I try to access a DB on another computer.

At the end of my posting I appended the listing of my test program and the output of my debug session as JOHN. The debug session as Oracle looks almost the same with the difference, that the program does not hang.

Thank you very much for any help.
Andreas

  • LISTING --------------------------------------------------
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <sqlda.h>
    //#include <sqlca.h>
    #include <sqlcpr.h>

EXEC SQL BEGIN DECLARE SECTION; // Define constants for VARCHAR lengths.
#define UNAME_LEN 20
#define PWD_LEN 20
#define DBN_LEN 80

#define USER_NAME "TESTUSR"
#define DB_NAME "TESTDB"
#define PASSWORD "TESTPWD"

// Declare variables. No declare section is needed if MODE=ORACLE.

VARCHAR     username[UNAME_LEN];  // VARCHAR is an Oracle-supplied struct
VARCHAR     password[PWD_LEN];
VARCHAR     dbname[DBN_LEN];

struct
{
  VARCHAR name[50];
} userNameRec;

struct
{
  short nameInd;
} userNameIndRec;

EXEC SQL END DECLARE SECTION; // Include the SQL Communications Area. You can use #include or EXEC SQL INCLUDE.
#include <sqlca.h>

// Declare error handling function.
void sql_error(char *msg)
{

    char err_msg[128];
    size_t buf_len, msg_len;

    EXEC SQL WHENEVER SQLERROR CONTINUE;     printf("\n%s\n", msg);
    buf_len = sizeof (err_msg);
    sqlglm(err_msg, &buf_len, &msg_len);     printf("%.*s\n", msg_len, err_msg);

    EXEC SQL ROLLBACK RELEASE;
    exit(EXIT_FAILURE);
}

int main()
{

    printf("\nConnect string to DB (RETURN=%s/passord_at_%s) ? ", USER_NAME, DB_NAME);     dbname.len= (unsigned short)strlen((char *)gets((char *)dbname.arr));     if (dbname.len==0)
    {

      sprintf((char *)dbname.arr, "%s/%s_at_%s", USER_NAME, PASSWORD, DB_NAME);
      dbname.len = (unsigned short) strlen((char *) dbname.arr);
    }

    // Register sql_error() as the error handler.     EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n");

    printf("\nConnecting to Oracle DB %s/XXXXX_at_%s . . . ", USER_NAME, DB_NAME);

    // Connect to ORACLE. Program will call sql_error()     // if an error occurs when connecting to the default database.     EXEC SQL CONNECT :dbname;
    printf("connected\n");

    EXEC SQL SELECT user INTO :userNameRec INDICATOR :userNameIndRec FROM DUAL;     printf("Got user name: %s\n", userNameRec.name.arr);

    // Disconnect from ORACLE.
    printf("Disconnecting from Oracle DB . . . ");     EXEC SQL ROLLBACK WORK RELEASE;
    printf("disconnected\n");
    return 0;
}

-------------------------- END OF LISTNG -------------------------------------

-------------------------- DEBUG SESSION -------------------------------------
blumer_at_neptune:devel/tst/source/src/Biel> dbx sample1 Reading symbolic information for sample1 Reading symbolic information for rtld /usr/lib/ld.so.1 Reading symbolic information for libclntsh.so.1.0 Reading symbolic information for libthread.so.1
Reading symbolic information for libm.so.1
Reading symbolic information for libC.so.5
Reading symbolic information for libw.so.1
Reading symbolic information for libc.so.1
Reading symbolic information for libnsl.so.1
Reading symbolic information for libsocket.so.1 Reading symbolic information for libgen.so.1 Reading symbolic information for libdl.so.1 Reading symbolic information for libaio.so.1 Reading symbolic information for libmp.so.2 Reading symbolic information for libc_psr.so.1 detected a multithreaded program

(dbx 1) run
Running: sample1
(process id 13642)

Connect string to DB (RETURN=TESTUSR/passord_at_TESTDB) ?

Connecting to Oracle DB TESTUSR/XXXXX_at_TESTDB . . . Reading symbolic information for nss_files.so.1 Reading symbolic information for nss_nisplus.so.1 Reading symbolic information for straddr.so Reading symbolic information for libdoor.so.1 dbx: warning: Interrupt ignored but forwarded to child. t_at_1 (l_at_1) signal INT (Interrupt) in __sigprocmask at 0xff379bf0 0xff379bf0: __sigprocmask+0x0008: retl (dbx 2) where
current thread: t_at_1

=>[1] __sigprocmask(0x0, 0xffbe7b28, 0x0, 0x249e8, 0xffbe7b08, 0x0), at 0xff379bf0
  [2] __bounceself(0x24a50, 0xff39adc8, 0xff38e000, 0x0, 0xff38e000, 0x24a80), at 0xff36e26c
  [3] _mutex_adaptive_lock(0xff399944, 0x66666400, 0x4c00, 0x1, 0x4d58, 0xfffeffff), at 0xff36ad88
  [4] _cmutex_lock(0xfeb9eac8, 0xff, 0xff236000, 0xfeb2b0b0, 0x410d0, 0x0), at 0xff36ab1c
  [5] user2netname(0x1, 0x8a, 0x0, 0xfeb9ae30, 0x0, 0x0), at 0xfeb2b0b0
  [6] authdes_pk_seccreate(0x410d8, 0x410a8, 0xf, 0x0, 0x0, 0xffbe8030), at 0xfeb2adf8
  [7] nis_make_rpchandle_gss_svc(0x0, 0xffbe8040, 0x3d728, 0x3c730, 0x3dd08, 0x3da30), at 0xfeb64880
  [8] nis_make_rpchandle_uaddr(0xffbe8030, 0x0, 0x187cc, 0x3, 0x6, 0x0), at 0xfeb64268
  [9] nis_handle(0xfeb9f400, 0x354a, 0x3da30, 0xfeb9ae30, 0x0, 0x1), at 0xfeb6aed0
  [10] __nis_get_server(0x0, 0xfeb9ae30, 0x2, 0xfeba1ed8, 0xfeba1ea8, 0xfeba1eb8), at 0xfeb1f3b4
  [11] __nis_finddirectory_remote(0x3d9f8, 0x3dc28, 0x3d9f8, 0x1, 0x0, 0x3dce8), at 0xfeb6a488
  [12] NisCache::loadDirectory(0x3d678, 0x3dbed, 0x0, 0x1, 0x3d688, 0x1), at 0xfeb7088c
  [13] NisCache::bindReplica(0x3acd8, 0x3dbed, 0xffbe840c, 0x3acd8, 0x3dbed, 0x2e), at 0xfeb70328
  [14] __nis_CacheBindDir(0x3dbed, 0x0, 0x0, 0xffbe840c, 0x3dbed, 0x3d9f8), at 0xfeb73900
  [15] nis_bind_dir(0x3dbe8, 0xffbe840c, 0xffbe840c, 0x30003, 0xffbe840c, 0x3dbe8), at 0xfeb5fc84
  [16] __nis_get_server(0xffbe840c, 0xfeb9ae30, 0x2, 0xfeba1ed8, 0xfeba1ea8, 0xfeba1eb8), at 0xfeb1f174
  [17] __nis_remote_lookup(0xffbe84c4, 0x0, 0x1, 0x0, 0x0, 0xfeb9ae30), at 0xfeb6a150
  [18] nis_list(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfeb1d990
  [19] __nis_principal(0xffbe8ddc, 0x8a, 0xffbe8ddc, 0xfeb9ae30, 0x8a, 0x3b110), at 0xfeb63588
  [20] user2netname_nisplus(0xffbe92a8, 0xffbe9310, 0x8a, 0x3b110, 0xfeb9ae30, 0xffbe9310), at 0xfeb2b3a4
  [21] user2netname(0x1, 0x3be00, 0x0, 0xfeb9ae30, 0x3be30, 0x0), at 0xfeb2b10c
  [22] authdes_pk_seccreate(0x40ad8, 0x3d910, 0xf, 0x0, 0x0, 0xffbe9680), at 0xfeb2adf8
  [23] nis_make_rpchandle_gss_svc(0x0, 0xffbe9690, 0x3d5e8, 0x3c730, 0x3db88, 0x3ad70), at 0xfeb64880
  [24] nis_make_rpchandle_uaddr(0xffbe9680, 0x0, 0x187cc, 0x3, 0x6, 0x0), at 0xfeb64268
  [25] nis_handle(0xfeb9f400, 0x354a, 0x3ad70, 0xfeb9ae30, 0x0, 0x1), at 0xfeb6aed0
  [26] __nis_get_server(0x0, 0xfeb9ae30, 0x2, 0xfeba1ed8, 0xfeba1ea8, 0xfeba1eb8), at 0xfeb1f3b4
  [27] __nis_finddirectory_remote(0x3d040, 0x25388, 0x3d040, 0x1, 0x0, 0x3db68), at 0xfeb6a488
  [28] NisCache::loadDirectory(0x3c4a0, 0x2e8c7, 0x0, 0x1, 0x3c4b0, 0x1), at 0xfeb7088c
  [29] NisCache::bindReplica(0x3acd8, 0x2e8c7, 0xffbe9a5c, 0x3acd8, 0x2e8c7, 0x2e), at 0xfeb70328
  [30] __nis_CacheBindDir(0x2e8c7, 0x0, 0x0, 0xffbe9a5c, 0x2e8c7, 0x0), at 0xfeb73900
  [31] nis_bind_dir(0x2e8c0, 0xffbe9a5c, 0xffbe9a5c, 0x10003, 0xffbe9a5c, 0x2e8c0), at 0xfeb5fc84
  [32] __nis_get_server(0xffbe9a5c, 0xfeb9ae30, 0x2, 0xfeba1ed8, 0xfeba1ea8, 0xfeba1eb8), at 0xfeb1f174
  [33] __nis_remote_lookup(0xffbe9b14, 0x0, 0x1, 0x0, 0x0, 0xfeb9ae30), at 0xfeb6a150
  [34] nis_list(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 0xfeb1d990
  [35] _nss_nisplus_lookup(0xffbea0e8, 0xffbea0e8, 0xff0b6b18, 0xffbea004, 0xff0c8000, 0xff0b6b18), at 0xff0b21ac
  [36] getbyuid(0x3aca0, 0xffbea0e8, 0xff0c8000, 0x3b104, 0x1, 0x3ac40), at 0xff0b3824
  [37] _nss_search(0x1, 0xff238ef4, 0xff23d4ec, 0xff0b37f4, 0x3ac48, 0x3aca0), at 0xff1c7638
  [38] _uncached_getpwuid_r(0x8a, 0xffbea6ec, 0xffbea5ec, 0x100, 0xff238d48, 0xffbea580), at 0xff212cfc
  [39] _getpwuid_r(0x8a, 0xffbea180, 0xffbea5ec, 0x100, 0xffbea6ec, 0x8a), at 0xff212c70
  [40] snigun(0xffbeb9a8, 0xffbea9a8, 0x1000, 0x3a8a0, 0xffbeb9c4, 0xffbecc25), at 0xfed2d15c
  [41] niqnamcd(0x1000, 0xffbecc3c, 0xff05ea58, 0x39878, 0xff02cb70, 0x0), at 0xfed238f8
  [42] niqname(0xffbedf80, 0x1, 0x39878, 0xff02cb70, 0x1, 0x0), at 0xfed24be0
  [43] kwfnran(0x24e58, 0x3, 0xffbedf84, 0xffbedf80, 0x37a2c, 0x37a30), at 0xfed20ca4
  [44] kwfcinit(0x2da2c, 0x24e58, 0x3, 0xffbedf84, 0xffbedf80, 0x1000), at 0xfed07550
  [45] kpuatch(0x2a030, 0x2d410, 0x24e58, 0x3, 0x0, 0x2f1c4), at 0xfecb7fa0
  [46] OCIServerAttach(0x2d8c8, 0x2d410, 0x24e58, 0x3, 0x0, 0xf8e9dacb), at 0xfecf79dc
  [47] sqlv8c(0x0, 0x24e58, 0x248b6, 0x15, 0x0, 0x0), at 0xfec96664
  [48] sqllam(0xff0485c0, 0x248b6, 0x15, 0x0, 0x0, 0x0), at 0xfec96d80
  [49] sqllo3t(0xff0485c0, 0x4, 0xffbee61c, 0xffbee268, 0xffbee27c, 0xffbee28c), at 0xfec7dc80
  [50] sqlcnt(0xff0485c0, 0xffbee268, 0xc, 0xff0097e0, 0x0, 0x4), at 0xfec7b5ec
  [51] sqlexp(0xffbee5cc, 0xff0097e0, 0x0, 0xff0097f4, 0x1b, 0x4), at 0xfec7cf0c
  [52] sqlcmex(0x0, 0x2dfc0, 0xffbee5cc, 0x24590, 0xff0097e0, 0xff02cb70), at 0xfec75b50
  [53] sqlcxt(0x0, 0x2458c, 0xffbee5cc, 0x24590, 0x81010100, 0xff00), at 0xfec76068
  [54] main(0x1, 0xffbee704, 0xffbee70c, 0x24400, 0x0, 0x0), at 0x111ac
(dbx 3)
------------------------------ END OF DEBUG SESSION ---------------------------------------
Received on Mon Jan 08 2001 - 14:23:59 CET

Original text of this message