Home » Developer & Programmer » Precompilers, OCI & OCCI » Linux, occi, segmentation fault (oracle 10g)
Linux, occi, segmentation fault [message #349674] Mon, 22 September 2008 10:57 Go to next message
yongluouk
Messages: 9
Registered: September 2008
Junior Member
I have a very simple c++ program:
#include <occi.h>
using namespace oracle::occi;
int main() {
Environment *env = Environment::createEnvironment();
Environment::terminateEnvironment(env);
return 0;
}

It compiles but it has Segmentation fault when I run it.

How do I modify the program? If I need to increase pthread stack size, what should I add in the program?
I have little idea about pthread.

Thank you,
Re: Linux, occi, segmentation fault [message #349678 is a reply to message #349674] Mon, 22 September 2008 11:06 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You have to first found why and where it raises the error using a debugger.

Regards
Michel
Re: Linux, occi, segmentation fault [message #349686 is a reply to message #349674] Mon, 22 September 2008 11:59 Go to previous messageGo to next message
vicenzo
Messages: 28
Registered: December 2007
Location: Paris
Junior Member
Hi,

Check that your compiler version is compatible to your occi copy...

Most of the time, segfaults with basic app like yours are linked to compilers version mismatch...

That's why using OCCI is always tricky....
Re: Linux, occi, segmentation fault [message #349835 is a reply to message #349686] Tue, 23 September 2008 04:37 Go to previous messageGo to next message
yongluouk
Messages: 9
Registered: September 2008
Junior Member
This is what I get when I dedug it.

At the step: createEnvironment().

Program received signal SIGSEGV Segmentation fault.
0x000... in OCIPClearMxCtr()
from ....../libclntsh.so.10.1

Thank you,


Re: Linux, occi, segmentation fault [message #357946 is a reply to message #349835] Fri, 07 November 2008 06:03 Go to previous messageGo to next message
seim
Messages: 3
Registered: November 2008
Junior Member
Hi,

there could be two things...

1) (less probable) I know, you said SIGSEGV, just to be sure.. enclose the code into try-catch block

try
{
....
}
catch ( SQLException &e )
{
cout << e.getMessage() << endl;
}


2) if SIGSEGV appears again, it could be this:

Oracle 10g client libraries are statickly linked with libstdc++.so.5 (use ldd to verify it), but the libstdc++.so.6 is currently used in the system (gentoo 2008.0). The compilation of your program runs ok, but... your program will be linked with both versions: v5 and v6. There shoudnt be problem (because the link to specific library code is made as an offset to the library base address), but there is.. Compiler (bot 3.X and 4.1.X versions of gcc) IS NOT ABLE to solve conflicts and it comes out suddenly in runtime as an SIGSEGV.

Solusion is simple: use 11g server + 11g OCCI interface. 11g uses libstdc++.so.6 and is compatible with your system.
Re: Linux, occi, segmentation fault [message #453524 is a reply to message #357946] Thu, 29 April 2010 06:45 Go to previous messageGo to next message
zutikombi
Messages: 2
Registered: April 2010
Location: Split
Junior Member
Hello, have the same problem ...

I have a very simple c++ program:
#include <occi.h>
using namespace oracle::occi;
int main() {
Environment *env = Environment::createEnvironment();
Environment::terminateEnvironment(env);
return 0;
}


When I run my program, I get segmentation fault ...
FedoraCore3, Oracle10g client installation, GCC version 3.4.2

At first I had compilation error, it was about libstdc++.so.6 and libstdc++.so.5 conflict ... I solved it in two ways :

First way is to install Oracle patch for for OCCI, so that it can be compiled with gcc 343 (occi_gcc343_102020.tar)

Second way is to install downgraded version of gcc (323) so when you compile program with downgraded version of gcc where you only need libstdc++.so.5 ...

Anyway, program compiled on 1st or 2nd way gives me segmentation fault ... and when I run it trough debugger, it brakes on Environment::createEnvironment, and says no source available for "OCIPClearMyCtr()" ...

Surrounding with try and catch gives no result whatsoever ...

Please help
Re: Linux, occi, segmentation fault [message #454098 is a reply to message #453524] Tue, 04 May 2010 01:30 Go to previous message
zutikombi
Messages: 2
Registered: April 2010
Location: Split
Junior Member
Problem solved !

I needed to include aditional libraries :
- occiius
- ociei
- occi
- clntsh

, and I needed to include theirs locations directories :
- $ORACLE_HOME/lib
- $ORACLE_HOME/instantclient
- $ORACLE_HOME/instantclient/light

I have made my Oracle installation by oracle universal installer ...
Previous Topic: Precompiler for Fortran
Next Topic: compiling the c file (output of pc file precompialtion)
Goto Forum:
  


Current Time: Fri Mar 29 01:14:18 CDT 2024