Hi All,
An memory exception occurred while executing the function memPartFree, the stack trace after the exception is as follows.
0x002918F0 in (0x0029171c) exceptionHdlr
0x000223D0 in (0x0002191c) excExcHandle
0x000EEAD0 in (0x000eeaa8) wdbDbgDataAccessStub
0x00000300 no symbol found for pc
0x00097EE4 in (0x00097e00) memPartFreeX
0x002A4AFC in (0x002a4598) memPartFree
0x002A4F08 in (0x002a4eec) free
Here the memPartFree is the function written by us and memPartFreeX is the alias to memPartFree (The standard function). we had written memPartFree a wrapper above the standard function to check some memory related errors such as
1. NULL pointer check.
2. Valid pointer within the Heap
3. Double memory check
4. Invalid memory free (Which means the pointer is within the heap but the memory is not allocated to that pointer using the malloc)
etc.
The registers content after the exception is as follows.
EXCEPTION Vector: 0x300 - DSI Exception
Stack Pointer Reg: 0x065F9130
Vector Offset: 0x00000300
errno: 0x064D0050
Data Address Reg: 0x0C7B27C8
Data Storage IS Reg: 0x42000000
FP CS Reg: 0x002A44EC
Program Counter: 0x000980C4
Condition Reg: 0x48042045
Machine State Reg: 0x0000B032
Link Reg: 0x000980AC
Count Reg: 0x00000000
Fixed Point Exc Reg: 0x00000000
R0: 0x063D93E8 R1: 0x065F9130 R2: 0x00000000 R3: 0x0710C0B8
R4: 0x063D9E28 R5: 0x00000000 R6: 0x0000B032 R7: 0x00000008
R8: 0x0018F718 R9: 0x000030DF R10: 0x00000001 R11: 0x00D4A958
R12: 0x48000045 R13: 0x00000000 R14: 0x00000000 R15: 0x00000000
R16: 0x00000000 R17: 0x00000000 R18: 0x00000000 R19: 0x00000000
R20: 0x00000000 R21: 0x00000001 R22: 0x00000001 R23: 0x063D9DD0
R24: 0x0710C0AC R25: 0x00000000 R26: 0x063D93F0 R27: 0x070B0000
R28: 0x0710C0B8 R29: 0x00000518 R30: 0x0710C0AC R31: 0x063D93E0
From the above register content we can notice that, the Program counter is pointing to address: 0x000980C4, and while trying to access the address (Data Address Reg:) 0x0C7B27C8, an DSI (0x300) exception occurred.
When i did the objdumppc for the .abs file the following was displayed. (objdumpppc xxx.abs -S -D -l --start-address=0x98060 --stop-address=0x980ec)
memPartDestroy():
98060: 38 7e 00 04 addi r3,r30,4
98064: 90 1f 00 04 stw r0,4(r31)
98068: 38 80 00 00 li r4,0
9806c: 38 bf 00 08 addi r5,r31,8
98070: 4b fd bf 65 bl 73fd4
98074: 81 3f 00 04 lwz r9,4(r31)
98078: 55 2b f8 7e rlwinm r11,r9,31,1,31
9807c: 7c 0b 5a 14 add r0,r11,r11
98080: 7c 9f 02 14 add r4,r31,r0
98084: 80 04 00 04 lwz r0,4(r4)
98088: 70 0a 00 01 andi. r10,r0,1
9808c: 41 82 00 20 beq 980ac
98090: 54 00 f8 7e rlwinm r0,r0,31,1,31
98094: 38 84 00 08 addi r4,r4,8
98098: 7c 0b 02 14 add r0,r11,r0
9809c: 38 7e 00 04 addi r3,r30,4
980a0: 50 09 08 3c rlwimi r9,r0,1,0,30
980a4: 91 3f 00 04 stw r9,4(r31)
980a8: 4b fd bf 91 bl 74038
980ac: 80 1f 00 04 lwz r0,4(r31)
980b0: 7f 83 e3 78 mr r3,r28
980b4: 81 3e 00 40 lwz r9,64(r30)
980b8: 81 7e 00 44 lwz r11,68(r30)
980bc: 54 00 00 3c rlwinm r0,r0,0,0,30
980c0: 39 29 ff ff addi r9,r9,-1
980c4: 7f ff 01 2e stwx r31,r31,r0 -> Exception occured here
980c8: 7d 7d 58 50 subf r11,r29,r11
980cc: 91 3e 00 40 stw r9,64(r30)
980d0: 91 7e 00 44 stw r11,68(r30)
980d4: 48 02 af f1 bl c30c4
980d8: 38 60 00 00 li r3,0
980dc: 80 01 00 24 lwz r0,36(r1)
980e0: 7c 08 03 a6 mtlr r0
980e4: 83 81 00 10 lwz r28,16(r1)
980e8: 83 a1 00 14 lwz r29,20(r1)
Initially i thought it was a double memory free and I tried to reproduce the issue, but this scenario did not arise because a check was put in the wrapper function that we had written. Here it is trying to access the address at 0x0C7B27C8, but my total RAM size is 128MB only.( ie the memory starts at 0x00000000 and ends at 0x08000000) but the address it is trying to access is beyond the address scope of 128MB. The function which is trying to access is a dllRemove() function which is a standard vxworks library function. I wanted to know what may be the reason for this corruption. Can anyone help me on this. Thank you in advance.