Operating System - HP-UX
1752790 Members
6468 Online
108789 Solutions
New Discussion юеВ

urgent, need help about pro*c

 
jiangyi_1
Advisor

urgent, need help about pro*c

hello everyone, I have problem with pro*c on hpux11.0 and oracle 9.2.0.the problem is , the same code can connect to oracle database in a parent process , but when i use the same code in a child process, the program crashed when connect to oracle.I don't know how to find what is the flaw of the code, please help me! please see the db.pc in the attchment.
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor

Re: urgent, need help about pro*c

This code is not complete enough to determine the problem. If I take you at your word then I suspect is that the environment variables are different between the parent and child. Since I don't know how you fork()'ed and exec()'ed and how you did the putenv()'s, it's not possible to answer.

I do see one thing that could result in possible errors: your use of snprintf() without a proper format string.

For example,
_passwd.len = snprintf((char *)_passwd.arr,sizeof(_passwd.arr),(char*)passwd);

Now consider what might happen if the passwd were something like: "yu%d4F". Snprintf would interpret the "%d" sequence as an integer format and look on the stack for additional variables. This is DANGEROUS code and all your snprintf should be properly coded by adding a format string.

passwd.len = snprintf((char *)_passwd.arr,sizeof(_passwd.arr),"%s",(char*)passwd);

Your use of snprintf, as opposed to sprintf, was a wise choice to prevent overflows but without a format string your wise choice became less than wise. This may not be your problem at the moment (I still suspect missing environment variables) but it is bad code.


If it ain't broke, I can fix that.
jiangyi_1
Advisor

Re: urgent, need help about pro*c

I do fork() but do not exec().I think the environment of child is identical to its parent.I have printed the environ from child process,the env is list below,I have ORACLE_BASE,ORACLE_HOME,ORACLE_SID,and NLS_LANG setted and the oracle bin dir is also in PATH, does those env variable enough to run pro*c application?I have changed the snprintf ,thank you :)_=/home/jy/tmp/3/supernoc/mea/meaMANPATH=/usr/share/man/%L:/usr/share/man:/usr/contrib/man/%L:/usr/contrib/man:/usr/local/man/%L:/usr/local/man:/opt/upgrade/share/man/%L:/opt/upgrade/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/usr/dt/share/man:/opt/graphics/phigs/share/man:/opt/videoout/share/man:/opt/resmon/share/man:/opt/hparray/share/man/%L:/opt/hparray/share/man:/opt/ignite/share/man/%L:/opt/ignite/share/man://opt/perl/man:/opt/aCC/share/man/%L:/opt/aCC/share/man:/opt/audio/share/man:/opt/ansic/share/man/%L:/opt/ansic/share/man:/opt/langtools/share/man/%L:/opt/langtools/share/man:/opt/image/share/man:/opt/pascal/share/man:/opt/softbench/share/man/%L:/opt/softbench/share/man:/opt/imake/man:/opt/networker/man:/opt/OV/manSHLIB_PATH=/opt/oracle/product/9.2.0/lib32PATH=/opt/softbench/bin:/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/opt/ansic/bin:/opt/nettladm/bin:/opt/fc/bin:/opt/fcms/bin:/opt/upgrade/bin:/usr/bin/X11:/usr/contrib/bin/X11:/opt/pd/bin:/opt/graphics/phigs/bin:/opt/resmon/bin:/usr/sbin/diag/contrib:/opt/hparray/bin://opt/perl/bin:/opt/aCC/bin:/opt/pascal/bin:/opt/langtools/bin:/opt/imake/bin:/opt/networker/bin:/opt/OV/bin/OpC:/opt/OV/bin:.:/usr/local/bin:/opt/oracle/product/9.2.0/binOLDPWD=/home/jy/tmp/3/supernocNLS_LANG=american_america.WE8ISO8859P15COLUMNS=86ORACLE_BASE=/opt/oracleEDITOR=viLOGNAME=jyORACLE_SID=openviewERASE=^HSHLVL=1DISPLAY=hpoltp:0CVSROOT=:pserver:jiangyi@192.168.1.135:/cvsSHELL=/usr/bin/shORACLE_TERM=hpXFILESEARCHPATH=/etc/opt/langtools/wdb/%T/%L/%N%S:/opt/langtools/wdb/%T/%L/%N%S:/etc/opt/langtools/wdb/%T/%N%S:/opt/langtools/wdb/%T/%N%S:/usr/lib/X11/%L/%T/%N%S:/usr/lib/X11/%l/%T/%N%S:/usr/lib/X11/%T/%N%SHOME=/home/jyTERM=dttermORACLE_HOME=/opt/oracle/product/9.2.0PWD=/home/jy/tmp/3/supernoc/meaTZ=EAT-8LINES=25
jiangyi_1
Advisor

Re: urgent, need help about pro*c

I do fork() but do not exec().I think the environment of child is identical to its parent.I have printed the environ from child process,the env is list below,I have ORACLE_BASE,ORACLE_HOME,ORACLE_SID,and NLS_LANG setted and the oracle bin dir is also in PATH, does those env variable enough to run pro*c application?I have changed the snprintf ,thank youthe environment variable printed by child process listed in the attachment.
jiangyi_1
Advisor

Re: urgent, need help about pro*c

when I step into my program, I find that the program exit immediately when call sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);what's the problem?
A. Clay Stephenson
Acclaimed Contributor

Re: urgent, need help about pro*c

You probably need to search for your problem at Oracle's MetaLink. I suspect that you are not quite playing by rules after your fork. Man 2 fork and pay attention to the section about executing async-signal safe functions until an exec is done. I suspect that if you do a fork() and exec() your problems will disappear.

The problem CAN'T be as simple as parent works child fails because, after all, even your parent process is the child of still another process.
If it ain't broke, I can fix that.