Hi friends,

I m experiencing a problem in a pro*c module.
Its a function in a pro*c file which is opening a cursor, and the equivalent of this pro*c code is a block in parse.cpp file line number : 1255 which is
sqlcxt(&ctx1, &sqlctx, &sqlstm, &sqlfpn);

the module got down at this line, and made a core file, and when i saw the core file in gdb, and in backtrace i came to know that its a function named malloc_consolidate() at which the problem came. plz give me any suggesions on what i can do to resolve the problem.
I m sending the backtrace of the core file also

Thanks in Advance.
----------------------------------------------------------------------------------------------------------
Core was generated by `'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1...done.
Loaded symbols for /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
Reading symbols from /lib/tls/libpthread.so.0...done.
Loaded symbols for /lib/tls/libpthread.so.0
Reading symbols from /usr/lib/libcurl.so.2...done.
Loaded symbols for /usr/lib/libcurl.so.2
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libssl.so.4...done.
Loaded symbols for /lib/libssl.so.4
Reading symbols from /lib/libcrypto.so.4...done.
Loaded symbols for /lib/libcrypto.so.4
Reading symbols from /usr/kerberos/lib/libgssapi_krb5.so.2...done.
Loaded symbols for /usr/kerberos/lib/libgssapi_krb5.so.2
Reading symbols from /usr/kerberos/lib/libkrb5.so.3...done.
Loaded symbols for /usr/kerberos/lib/libkrb5.so.3
Reading symbols from /usr/kerberos/lib/libcom_err.so.3...done.
Loaded symbols for /usr/kerberos/lib/libcom_err.so.3
Reading symbols from /usr/kerberos/lib/libk5crypto.so.3...done.
Loaded symbols for /usr/kerberos/lib/libk5crypto.so.3
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /home/oracle/xmlrpc-c-1.06.14/src/.libs/libxmlrpc_client.so.3...done.
Loaded symbols for /home/oracle/xmlrpc-c-1.06.14/src/.libs/libxmlrpc_client.so.3
Reading symbols from /home/oracle/xmlrpc-c-1.06.14/src/.libs/libxmlrpc.so.3...done.
Loaded symbols for /home/oracle/xmlrpc-c-1.06.14/src/.libs/libxmlrpc.so.3
Reading symbols from /home/oracle/xmlrpc-c-1.06.14/lib/libutil/.libs/libxmlrpc_util.so.3...done.
Loaded symbols for /home/oracle/xmlrpc-c-1.06.14/lib/libutil/.libs/libxmlrpc_util.so.3
Reading symbols from /home/oracle/xmlrpc-c-1.06.14/lib/expat/xmlparse/.libs/libxmlrpc_xmlparse.so.3...done.
Loaded symbols for /home/oracle/xmlrpc-c-1.06.14/lib/expat/xmlparse/.libs/libxmlrpc_xmlparse.so.3
Reading symbols from /home/oracle/xmlrpc-c-1.06.14/lib/expat/xmltok/.libs/libxmlrpc_xmltok.so.3...done.
Loaded symbols for /home/oracle/xmlrpc-c-1.06.14/lib/expat/xmltok/.libs/libxmlrpc_xmltok.so.3
Reading symbols from /usr/lib/libstdc++.so.5...done.
Loaded symbols for /usr/lib/libstdc++.so.5
Reading symbols from /lib/tls/libm.so.6...done.
Loaded symbols for /lib/tls/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /home/oracle/product/10.2.0/lib/libnnz10.so...done.
Loaded symbols for /home/oracle/product/10.2.0/lib/libnnz10.so
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/lib/libwwwxml.so.0...done.
Loaded symbols for /usr/lib/libwwwxml.so.0
Reading symbols from /usr/lib/libxmltok.so.0...done.
Loaded symbols for /usr/lib/libxmltok.so.0
Reading symbols from /usr/lib/libxmlparse.so.0...done.
Loaded symbols for /usr/lib/libxmlparse.so.0
Reading symbols from /usr/lib/libwwwzip.so.0...done.
Loaded symbols for /usr/lib/libwwwzip.so.0
Reading symbols from /usr/lib/libwwwinit.so.0...done.
Loaded symbols for /usr/lib/libwwwinit.so.0
Reading symbols from /usr/lib/libwwwapp.so.0...done.
Loaded symbols for /usr/lib/libwwwapp.so.0
Reading symbols from /usr/lib/libwwwhtml.so.0...done.
Loaded symbols for /usr/lib/libwwwhtml.so.0
Reading symbols from /usr/lib/libwwwtelnet.so.0...done.
Loaded symbols for /usr/lib/libwwwtelnet.so.0
Reading symbols from /usr/lib/libwwwnews.so.0...done.
Loaded symbols for /usr/lib/libwwwnews.so.0
Reading symbols from /usr/lib/libwwwhttp.so.0...done.
Loaded symbols for /usr/lib/libwwwhttp.so.0
Reading symbols from /usr/lib/libwwwmime.so.0...done.
Loaded symbols for /usr/lib/libwwwmime.so.0
Reading symbols from /usr/lib/libwwwgopher.so.0...done.
Loaded symbols for /usr/lib/libwwwgopher.so.0
Reading symbols from /usr/lib/libwwwftp.so.0...done.
Loaded symbols for /usr/lib/libwwwftp.so.0
Reading symbols from /usr/lib/libwwwfile.so.0...done.
Loaded symbols for /usr/lib/libwwwfile.so.0
Reading symbols from /usr/lib/libwwwdir.so.0...done.
Loaded symbols for /usr/lib/libwwwdir.so.0
Reading symbols from /usr/lib/libwwwcache.so.0...done.
Loaded symbols for /usr/lib/libwwwcache.so.0
Reading symbols from /usr/lib/libwwwstream.so.0...done.
Loaded symbols for /usr/lib/libwwwstream.so.0
Reading symbols from /usr/lib/libwwwmux.so.0...done.
Loaded symbols for /usr/lib/libwwwmux.so.0
Reading symbols from /usr/lib/libwwwtrans.so.0...done.
Loaded symbols for /usr/lib/libwwwtrans.so.0
Reading symbols from /usr/lib/libwwwcore.so.0...done.
Loaded symbols for /usr/lib/libwwwcore.so.0
Reading symbols from /usr/lib/libwwwutils.so.0...done.
Loaded symbols for /usr/lib/libwwwutils.so.0
Reading symbols from /usr/lib/libmd5.so.0...done.
Loaded symbols for /usr/lib/libmd5.so.0
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
#0 0x005be30e in malloc_consolidate () from /lib/tls/libc.so.6
(gdb) bt
#0 0x005be30e in malloc_consolidate () from /lib/tls/libc.so.6
#1 0x005bdaf9 in _int_malloc () from /lib/tls/libc.so.6
#2 0x005bce9d in malloc () from /lib/tls/libc.so.6
#3 0x00d07ec0 in sktsfMalloc () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#4 0x01065bd3 in kpummapg () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#5 0x00d746f1 in kghgex () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#6 0x00d7699f in kghfnd () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#7 0x00d7866d in kghalo () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#8 0x00d7462d in kghgex () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#9 0x00d7699f in kghfnd () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#10 0x00d7866d in kghalo () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#11 0x00d7462d in kghgex () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#12 0x00d7699f in kghfnd () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#13 0x00d7763d in kghprmalo () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#14 0x00d797d0 in kghalp () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#15 0x0095dd54 in kpuhhalp () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#16 0x0096aad4 in kpuexInitPrevRowBuf () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#17 0x0096afa5 in kpuexInitStmh () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#18 0x0096b641 in kpuexCallback () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#19 0x00ce7efb in ttcdrv () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#20 0x00bdcfc9 in nioqwa () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#21 0x00a413df in upirtrc () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#22 0x009b707e in kpurcsc () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#23 0x0096d69f in kpuexecv8 () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#24 0x0096ea52 in kpuexec () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#25 0x00a45f4a in OCIStmtExecute () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#26 0x00917304 in sqlcucExecute () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#27 0x00909e02 in sqlall () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#28 0x0090edac in sqlatm () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#29 0x008fb58b in sqlnst () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#30 0x008e9336 in sqlcmex () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#31 0x008e982e in sqlcxt () from /home/oracle/product/10.2.0/lib/libclntsh.so.10.1
#32 0x0804c89a in CParse::Parse (this=0xbfff5428)
at /prd/SRC/DatabaseInterface/Parse/Parse.cpp:1255
#33 0x0804a4e6 in CParseMain::ReadAndProcessDB (this=0xbfff5420)
at /prd/SRC/DatabaseInterface/Parse/ParseMain.cpp:190
#34 0x0804b595 in main () at /prd/SRC/DatabaseInterface/Parse/ParseMain.cpp:715
(gdb)

Well if the same kind of memory problems are being exhibited as in the other thread, then I'd say the code still has problems.

The fact that it crashes in some SQL code is mere coincidence. AFAIK, malloc_consolidate() is just an internal function to malloc which joins together adjacent free blocks (to make bigger blocks). But if the memory pool had been trashed by prior buffer overruns, then it's going to fail at any moment.

As this seems to be being run on a Linux system, I would suggest gcc -g prog.c -lefence Linking with the electric fence malloc debug library will trap any out of bound accesses at the point of the error, and not some random time later in some random unrelated part of the code.

Run the executable linked with electric fence inside the debugger, then do a 'bt' at the new segfault location. This will be your first mistake with allocated memory, which you need to fix.

well thanks a lot, Then i will first check my code for any sort of memory leaks.
Thanks for your advice.

This question has already been answered. Start a new discussion instead.