1748180 Members
4058 Online
108759 Solutions
New Discussion юеВ

Re: class issue

 
SOLVED
Go to solution
Alfonso_15
Advisor

class issue

Good Morning:
I have a program in c++ calling a function in OCI oracle (olog). When I call the function from main() conenction made by olog is successfull, but if I try to do the same call from a function member of a class, the olog produce a Memory Fault (coredump) error:

root # ./demo2

Just Before olog
Yes Connected from main()
Just Before olog
sh: 19337 Memory fault(coredump)

The core shows error in a library in Oracle, but this library is stripped, so I can not get any clues. I am attaching the main programm, the class used and the result of gdb. One of you guys could give me any idea how to fix that please. Thanks in advance.
I am attaching
alfonsoarias
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: class issue

This line is very suspect:

memset(hda,'\0',HDA_SIZE/sizeof(ub4));

change it to
memset(hda,'\0',sizeof(hda));

even better and more rigorously typed:

memset((void *) hda,(int) '\0',sizeof(hda));
If it ain't broke, I can fix that.
Alfonso_15
Advisor

Re: class issue

Thanks Clay, i change that statement. But still going to Memory Fault in the class execution. Do you note other thing in the code or in the gdb result?
Thanks
alfonsoarias
A. Clay Stephenson
Acclaimed Contributor

Re: class issue

Okay, I copied your source and split out the header file. I reproduced your error and made these changes in both main and inside your class and all was well.

ub4 hda[HDA_SIZE/sizeof(ub4)];
change to:
ub4 hda[HDA_SIZE];

--------------------------------------
memset(hda,'\0',HDA_SIZE/sizeof(ub4));
change to:
memset((void *) hda,(int) '\0',sizeof(hda));

After doing this I saw your "Yes Connected from main()" and your "Yes Connected from class" probes. And what is this printf stuff doing in C++; it ought to be cout.
If it ain't broke, I can fix that.