1752801 Members
5449 Online
108789 Solutions
New Discussion юеВ

Coredump in fread

 
Kalicharan
Occasional Advisor

Coredump in fread

Hi,
I am getting coredump in fread, I am calling the the C routine
conatining fread from COBOL.
One more thing, not every time a get this error, only sometimes, the
file pointer is being corrupted(when printing the %ld, fp-- it gives
two digit values, like 18, 57 etc).

gdb trace-


(gdb) bt
#0 0x60000000deeb8c60:1 in signal_handler_catch () at opsig.c:424
#1
#2 0x60000000deeb8c60:1 in signal_handler_catch () at opsig.c:424
#3
#4 0x60000000c03438e0:1 in fread+0x161 () from /usr/lib/hpux32/libc.so.1
#5 0x2e82600:0 in bltsi_readCharge (i_custInfo=0xea4b3c8, o_chgRec=0x9cc4d50)
at /il_sprdev/home/kalichay/bb/nxtbl/v84_0/tools/src/blts_gsaFee.c:422
#6 0x8a58c0:0 in blts_gsa_smamt+0x20590 ()
#7 0x2e7fc70:0 in blts_verGSAFee (i_dlContext=0x8e96da0,
i_cycContext=0x8e96db0, i_ban=806762781, hierRootId=47774293,
i_groupNo=18, i_chgFile=0x6772ac60, o_outFile=0xee1734c)
at /il_sprdev/home/kalichay/bb/nxtbl/v84_0/tools/src/blts_gsaFee.c:162
#8 0x10d2ef0:0 in execute ()
at /il_sprdev/home/kalichay/bb/nxtbl/v84_0/tools/src/blts_ocVerifyWrapper.cpp:178
#9 0x10d0360:0 in main ()
at /il_sprdev/home/kalichay/bb/nxtbl/v84_0/tools/src/blts_ocVerifyWrapper.cpp:51
Current language: auto; currently c



some more details-
-----------------

(gdb) disas $pc-16*4 $pc+16
Dump of assembler code from 0x60000000deeb8c20:0 to 0x60000000deeb8c70:0:
;;; DOC Line Information: [Line, Column Start, Column End] [Line, Column] [Line]
;;; File: opsig.c
;;; Line: 387
0x60000000deeb8c20:0 :
ld4.s r14=[r34]
0x60000000deeb8c20:1 :
addp4 r9=60,r33
0x60000000deeb8c20:2 :
cmp4.ne.unc p6=r0,r33;;
0x60000000deeb8c30:0 :
ld4.s r11=[r9]
0x60000000deeb8c30:1 :
(p6) chk.s.i r14,signal_handler_catch+0x400
0x60000000deeb8c30:2 :
(p6) cmp4.lt.unc p6=r0,r14;;
0x60000000deeb8c40:0 :
(p6) st2 [r39]=r42
0x60000000deeb8c40:1 :
(p6) chk.s.m r11,signal_handler_catch+0x420
0x60000000deeb8c40:2 :
nop.i 0x0
---Type to continue, or q to quit---
0x60000000deeb8c50:0 :
(p6) st4 [r10]=r11
;;; Line: 424
0x60000000deeb8c50:1 :
nop.m 0x0
0x60000000deeb8c50:2 :
br.many signal_handler_catch+0x140;;
0x60000000deeb8c60:0 :
adds r15=-48,r9;;
0x60000000deeb8c60:1 :
ld4 r14=[r15]
0x60000000deeb8c60:2 :
nop.i 0x0;;
End of assembler dump.



(gdb) info reg
pr0: 0x1
pr1: 0x1
pr2: 0x1
pr3: 0
pr4: 0
pr5: 0
pr6: 0x1
pr7: 0
pr8: 0
pr9: 0
pr10: 0
pr11: 0x1
pr12: 0
pr13: 0
pr14: 0x1
pr15: 0x1
pr16: 0
pr17: 0
pr18: 0
pr19: 0
pr20: 0
pr21: 0
pr22: 0
---Type to continue, or q to quit---
pr23: 0
pr24: 0
pr25: 0
pr26: 0
pr27: 0
pr28: 0
pr29: 0
pr30: 0
pr31: 0
pr32: 0
pr33: 0
pr34: 0
pr35: 0
pr36: 0
pr37: 0
pr38: 0
pr39: 0
pr40: 0
pr41: 0
pr42: 0
pr43: 0
pr44: 0
pr45: 0
---Type to continue, or q to quit---
pr46: 0
pr47: 0
pr48: 0
pr49: 0
pr50: 0
pr51: 0
pr52: 0
pr53: 0
pr54: 0
pr55: 0
pr56: 0
pr57: 0
pr58: 0
pr59: 0
pr60: 0
pr61: 0
pr62: 0
pr63: 0
gr0: 0
gr1: 0x2000000067746738
gr2: 0x9fffffff7f7e7c00
gr3: 0x9fffffff7f7e7c00
gr4: 0
---Type to continue, or q to quit---
gr5: 0xc000000000000408
gr6: 0x60000000c004b4e0
gr7: 0x200000007fff1048
gr8: 0x200000007ffe69f0
gr9: 0x3d
gr10: 0x200000007ffe6a00
gr11: NaT
gr12: 0x200000007ffe69d0
gr13: 0x2000000067437080
gr14: NaT
gr15: 0xd
gr16: 0
gr17: 0
gr18: 0x200000007ffe6a04
gr19: 0x20000000678ff680
gr20: 0x200000007fff0c50
gr21: 0
gr22: 0
gr23: 0x2
gr24: 0x200000007ffe6a08
gr25: 0x200000007ffe6a00
gr26: 0x200000007ffe6a04
gr27: 0
---Type to continue, or q to quit---
gr28: 0x8
gr29: 0
gr30: 0
gr31: 0x200000007ffe69f1
gr32: 0xa
gr33: 0x1
gr34: 0xd
gr35: 0x2000000067746738
gr36: 0xc000000000000085
gr37: 0xe0000001800028e0
gr38: 0xc847
gr39: 0x200000007ffe69f2
gr40: 0x17ffe6c00
gr41: 0x67742ac0
gr42: 0x1
gr43: 0x2000000067738b70
gr44: 0x200000006773b30d
gr45: 0x200000007ffe69f0
gr46: 0x2000000067738b70
gr47: 0x200000007ffe69f0
gr48: 0
gr49: 0x14
gr50: 0x53
---Type to continue, or q to quit---
gr51: 0x1
gr52: 0x710
br0: 0x60000000deeb8b70
br1: 0
br2: 0
br3: 0
br4: 0
br5: 0
br6: 0x60000000c0343780
br7: 0x60000000c01d7340
rsc: 0x1f
bsp: 0x20000000678ff880
bspst: 0x20000000678ff878
rnat: 0
ccv: 0
unat: 0
fpsr: 0x9804c0270033f
pfs: 0xc000000000000795
(sor:0, sol:15, sof:21)
lc: 0
ec: 0
ip: 0x60000000deeb8c60:1
cfm: 0x795
---Type to continue, or q to quit---
(sor:0, sol:15, sof:21)
psr: 0
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: Coredump in fread

>I am getting coredump in fread, I am calling fread from COBOL.

Then you need to look to your COBOL vendor.

>the file pointer is being corrupted (when printing the %ld, fp - it gives two digit values, like 18, 57 etc).

What do you mean? You are printing out the FILE*? If so, you must use %p to print it.

>some more details

Again useless, you need to look at fread's frame.
Kalicharan
Occasional Advisor

Re: Coredump in fread

Hi,
Thanks for replying.
Here is the info for frame 4 (fread frame)-

(gdb) frame 4
#4 0x60000000c03438e0:1 in fread+0x161 () from /usr/lib/hpux32/libc.so.1
(gdb) disas $pc-16*4 $pc+16
Dump of assembler code from 0x60000000c03438a0:0 to 0x60000000c03438f0:0:
0x60000000c03438a0:0 : (p1) ld4 r54=[r37]
0x60000000c03438a0:1 : nop.i 0x0
0x60000000c03438a0:2 : nop.i 0x0;;
0x60000000c03438b0:0 : ld2 r14=[r36]
0x60000000c03438b0:1 :
addl r8=0xffffffffffffe760,r1
0x60000000c03438b0:2 :
addl r9=0xffffffffffffad60,r1;;
0x60000000c03438c0:0 : or r11=0x20,r14
0x60000000c03438c0:1 : sub r10=r35,r8
0x60000000c03438c0:2 : tbit.z.unc p6=r14,8
0x60000000c03438d0:0 : adds r8=8,r9;;
0x60000000c03438d0:1 : nop.m 0x0
0x60000000c03438d0:2 : (p6) tbit.z.unc p6=r14,0
0x60000000c03438e0:0 : mov r14=r53;;
0x60000000c03438e0:1 : (p6) st2 [r36]=r11
0x60000000c03438e0:2 : nop.i 0x0
End of assembler dump.
(gdb) info reg
pr0: 0x1
pr1: 0x1
pr2: 0x1
pr3: 0
pr4: 0
pr5: 0
pr6: 0x1
pr7: 0
pr8: 0x1
pr9: 0
pr10: 0
pr11: 0
pr12: 0
pr13: 0
pr14: 0
pr15: 0
pr16: 0
pr17: 0
pr18: 0
pr19: 0
pr20: 0
pr21: 0
pr22: 0
---Type to continue, or q to quit---
pr23: 0
pr24: 0
pr25: 0
pr26: 0
pr27: 0
pr28: 0
pr29: 0
pr30: 0
pr31: 0
pr32: 0
pr33: 0
pr34: 0
pr35: 0
pr36: 0
pr37: 0
pr38: 0
pr39: 0
pr40: 0
pr41: 0
pr42: 0
pr43: 0
pr44: 0
pr45: 0
---Type to continue, or q to quit---
pr46: 0
pr47: 0
pr48: 0
pr49: 0
pr50: 0
pr51: 0
pr52: 0
pr53: 0
pr54: 0
pr55: 0
pr56: 0
pr57: 0
pr58: 0
pr59: 0
pr60: 0
pr61: 0
pr62: 0
pr63: 0
gr0: 0
gr1: 0x200000006772c4b0
gr2: 0x9fffffff7f7e7c00
gr3: 0x9fffffff7f7e7c00
gr4: 0
---Type to continue, or q to quit---
gr5: 0xc000000000000408
gr6: 0x60000000c004b4e0
gr7: 0x200000007fff1048
gr8: 0x2000000067727218
gr9: 0x2000000067727210
gr10: 0xdfffffff988d5400
gr11: 0x20
gr12: 0x200000007fff0c60
gr13: 0x2000000067437080
gr14: 0x200000006772c4b0
gr15: 0x1
gr16: 0x678
gr17: 0x9cc6d80
gr18: 0
gr19: 0x20000000678ff680
gr20: 0x200000007fff0c50
gr21: 0
gr22: 0x9fffffff7f7e8880
gr23: 0x2d
gr24: 0
gr25: 0x60000000c0360b30
gr26: 0
gr27: 0
---Type to continue, or q to quit---
gr28: 0
gr29: 0
gr30: 0
gr31: 0x710
gr32: 0x9cc6d80
gr33: 0x678
gr34: 0x1
gr35: 0x10
gr36: 0x1c
gr37: 0x2000000067730774
gr38: 0xc000000000000288
gr39: 0x60000000c0321520
gr40: 0xc000000000000590
gr41: 0x2e83cc0
gr42: 0
gr43: 0x147
gr44: 0x200000007fff0c70
gr45: 0x200000006772ac24
gr46: 0x2000000067726820
gr47: 0
gr48: 0x200000006772c4b0
gr49: 0
gr50: 0x678
---Type to continue, or q to quit---
gr51: 0x2000000067726820
gr52: 0x2000000067727588
gr53: 0x200000006772c4b0
gr54: 0
gr55: 0xc000000000000894
gr56: 0x60000000c0321b60
gr57: 0x145
gr58: 0x200000006772ac2c
gr59: 0
gr60: 0xeed5b84
br0: 0x2e83cc0
br1: 0
br2: 0
br3: 0
br4: 0
br5: 0
br6: 0x60000000c0343780
br7: 0xe0000001800006c0
rsc: 0x1f
bsp: 0x20000000678ff880
bspst: 0x20000000678ff6d8
rnat: 0
ccv: 0
---Type to continue, or q to quit---
unat: 0
fpsr: 0x9804c9a74433f
pfs: 0xc000000000000590
(sor:0, sol:11, sof:16)
lc: 0
ec: 0
ip: 0x60000000c03438e0:1
cfm: 0x4d1d
(sor:1, sol:26, sof:29)
psr: 0
Kalicharan
Occasional Advisor

Re: Coredump in fread

Also the fread instruction is within a C fuction. ( I am calling the C function from Cobol) and the file pointer is static variable. I am not doing anything with file pointer in COBOL.
Dennis Handly
Acclaimed Contributor

Re: Coredump in fread

>Here is the info for frame 4 (fread)

0x60000000c03438e0:1 : (p6) st2 [r36]=r11
gr32: 0x9cc6d80 ptr
gr33: 0x678 size
gr34: 0x1 nitems
gr35: 0x10 stream
gr36: 0x1c

>the file pointer is static variable.

You are reading 0x678 bytes. Your FILE* is bad, 0x10. Was the file ever opened? You could set a hardware watchpoint on the variable and see who modifies it.