My Oracle Support Banner

Caution When Declaring Variables and Routines Named 'connect' in a Pro*C or OCI Program (Doc ID 158581.1)

Last updated on AUGUST 04, 2018

Applies to:

Oracle Database - Enterprise Edition - Version and later
Precompilers - Version and later
Linux x86
Oracle Solaris on x86 (32-bit)
Oracle Solaris on SPARC (64-bit)
Oracle Solaris on SPARC (32-bit)
***Checked for relevance on 22-Oct-2013***


Declaring a global variable 'connect' in a Pro*C or OCI program fools the linker on some platforms, as Solaris (Intel and Sparc), Linux, and Tru64, and causes a core dump if a remote tns connection is to be made.

e.g. test.pc:

#include <stdio.h>
#include <sqlca.h>

int connect;

char *username = "SCOTT";
char *password = "TIGER";

int main() {
puts("\nConnected to Oracle.\n");

set TWO_TASK to a valid destination

on Solaris Sparc, this abends with:
Illegal Instruction (core dumped)

gdb produced the stack:
#0 0x20f68 in connect ()
#1 0xef2fb9a8 in nttcni ()
#2 0xef2fcdd0 in nttcon ()
#3 0xef2286ec in ntconn ()
#4 0xef21199c in nsopen ()
#5 0xef1fc280 in nscall1 ()
#6 0xef1fb7b4 in nscall ()
#7 0xef28938c in niotns ()
#8 0xef282eb0 in nigcall ()
#9 0xef1f487c in osncon ()
#10 0xef0fc4e0 in kpuadef ()
#11 0xef1109f8 in upiini ()
#12 0xef1017d4 in upiah0 ()
#13 0xef111458 in kpuatch ()
#14 0xef16ee44 in OCIServerAttach ()
#15 0xef0d310c in sqlv8c ()
#16 0xef0d38a8 in sqllam ()
#17 0xef0b3f30 in sqllo3t ()
#18 0xef0b0ce0 in sqlcnt ()
#19 0xef0b31d8 in sqlexp ()
#20 0xef0aaf38 in sqlcmex ()
#21 0xef0ab584 in sqlcxt ()
#22 0x10ab0 in main ()

Other debuggers do not mention connect() as top of the stack

Also, defining a function, as in

#include <stdio.h>
#include <sqlca.h>
#include <sys/socket.h>

int connect()
puts("\n from my_connect\n");
return 1;

char *username = "SCOTT";
char *password = "TIGER";

int main() {
puts("\nConnected to Oracle.\n");

might let the linker complain about redefinition of connect(), or just pass and produce the output:

from my_connect
Connected to Oracle.


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.