8.1.7 OCI & Unix core dumps

From: Daryl K. Jackson, Jr. <djackson_at_secant.com>
Date: 4 Oct 2001 08:12:31 -0700
Message-ID: <b3e0d7fa.0110040712.eea77c2_at_posting.google.com>


We have an application that needs to provide a shared library which is linked against the Oracle client library. Under 8.0.5 we had no problems on our supported Unix platforms. Now with 8.1.7 we are experiencing core dumps with the most basic operation on Solaris 2.6 or 7, Red Hat Linux 6.2, and AIX 4.3. I have provided a small sample below which compiles on Solaris with Forte 6 OR Red Hat Linux 6.2 with GCC 2.95.2. This sample uses GNU make to build. This sample completes a connection but core dumps on exit EXCEPT on Solaris 8. Are we doing anything wrong? Has anyone else observed this change in behavior?

Thank You Kindly,
Daryl

/***** START OF dynamic.c *****/
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define FileExists(f) (access(f, 0) == 0)
#define FUNC_NAME "ConnectToDatabase"

typedef void (*Function)(void);

int main(int argc, char *argv[])

{	char lib[256];
	Function conn;
	void *handle;

	getcwd(lib, 240);
	strcat(lib, "/libOra8.so");
	if (FileExists(lib))
	{	handle = dlopen(lib, RTLD_LAZY | RTLD_GLOBAL);
		if (handle != NULL)
		{	conn = (Function) dlsym(handle, (char *) FUNC_NAME);
			if (conn)
				conn();
			else
				fprintf(stdout, "\nCould Not Resolve %s: %s\n", FUNC_NAME,
dlerror());
		}
		else
			fprintf(stdout, "\nError loading %s\n", lib);
		dlclose(handle);
	}
	else
		fprintf(stdout, "\n%s does not exist!\n", lib);
	return(0);

}

/***** END OF dynamic.c *****/

/***** START OF makefile *****/
include unix.mak

# Oracle 8.0.5:
#O8Incs := -I$(O8)/rdbms/demo -I$(O8)/plsql/public
-I$(O8)/network/public
# Oracle 8.1.7:
O8Incs := -I$(O8)/rdbms/demo -I$(O8)/rdbms/public

all: env dynamic libOra8.so

clean:

        rm -rf core dynamic *.so *.o *.log SunWS_cache

env:

	_at_if [ -z "$(Compiler)" ]; then \
		echo ""; \
		echo "Please execute '. vars' if using Sh or Bash"; \
		echo ""; \
		exit 1; \
	fi



dynamic:	dynamic.c
	$(cc) $(ccFlags) -o $_at_ $? $(ccLibs) $(DL_$(OS))

libOra8.so:	oracle.c
	$(sl) $(ccFlags_SL) $(O8Incs) -o $_at_ $? -L$(O8)/lib -lclntsh $(ccLibs)

/***** END OF makefile *****/

/***** START OF oracle.c *****/
#include <stdio.h>
#include <string.h>

#include <oci.h>

#ifndef HDA_SIZE

        #define HDA_SIZE 256
#endif
#define USER "scott/tiger_at_o8i1"

void ConnectToDatabase()

{	Lda_Def lda;		/* logon definition area */
	sword err;
	ub1 hda[HDA_SIZE];	/* host data area */

	memset(hda, '\0', HDA_SIZE);

	fprintf(stdout, "Connecting to database...");
	err = olog(&lda, hda, (text *) USER, -1, (text *) 0, -1, (text *) 0,
-1, OCI_LM_DEF);
	fprintf(stdout, (err ? "Failed!\n" : "Success!\n"));

	ologof(&lda);
	return;

}

/***** END OF oracle.c *****/

/***** START OF unix.mak *****/
# GNU GCC 2.95.2:

cc_gcc          := /opt/gcc-2.95.2/bin/gcc
ccFlags_gcc     := -D_GNU_SOURCE -D_REENTRANT -g0 -ggdb -I. -w
ccFlags_SL_gcc  := -fPIC
ccLibs_gcc      := -lpthread -lm
sl_gcc          = $(cc_gcc) -Wl,-h,$_at_ -shared


# Sun Forte 6:
cc_WS6 := /opt/SUNWspro/WS6U1/bin/cc ccFlags_WS6 := -g -mt -xs -I. -z defs ccFlags_SL_WS6 := -KPIC ccLibs_WS6 := -lposix4 -lm -lc -lpthread sl_WS6 := $(cc_WS6) -G -z defs -mt cc := $(cc_$(Compiler)) ccFlags := $(ccFlags_$(Compiler)) ccFlags_SL := $(ccFlags) $(ccFlags_SL_$(Compiler)) ccLibs := $(ccLibs_$(Compiler)) sl = $(sl_$(Compiler))

DL_Linux := -Wl,-Bstatic -ldl -Wl,-Bdynamic DL_SunOS := -ldl
DL := $(DL_$(OS))

/***** END OF unix.mak *****/

/***** START OF vars *****/
OS=`uname -s`
OS_VER=`uname -r`
export OS OS_VER

# Lets default the compiler selection:

case "$OS" in

	"SunOS")
		Compiler=WS6;;
	*)						# Linux
		Compiler=gcc;;

esac
export Compiler

# Set environment for Oracle 8i:

O8=/opt/oracle/8.1.7
LD_LIBRARY_PATH=$O8/lib:$LD_LIBRARY_PATH export O8 LD_LIBRARY_PATH

/***** END OF vars *****/ Received on Thu Oct 04 2001 - 17:12:31 CEST

Original text of this message