if it is a hexdump of a struct I think something has happened when you are copying/transfering the struct... I do hope you know that everything coming over network does not need to be swapped, you are safe in that respect on the amiga... the same goes for sending data on the network, you should not do anything with it before sending the data.
Good to know that i don't need to swap the data. That was a little question in back mind, which got answered now. Will see that i rewrite the network read/write stuff.
I'm starting to really giving up on this. I've rewritten a lot of my code to clean it up and so on. Now it just crashes without any hint what the cause could be. Now it even doesn't relate anymore to an nearby AllocVec call. If I run my current program with debuglevel=20 the crash output looks like this:
[SMB2] DEBUG | ‘start’ | Wait for network and signals 0x80008000
[HAL_DfltTrapHandler] *** Warning: Fatal exception in task 0x6D664900 (Workbench, etask = 0xEFF37CD0) at ip 0x0183AD54
[HAL_Alert] ALERT! 0x80000003
[HAL_SuspendTaskWithUpdate] Suspending 0x6D664900 with state=2, DAR=0x0FDC6932, at IP=0x0183AD54, LR=0x0183AE8C
[HAL_SuspendTaskWithUpdate] Adding to suspend list
[HAL_SuspendTaskWithUpdate] Setting Workbench to crashed
[HAL_SuspendTaskWithUpdate] Context @ 0xEFF21000
kernel 54.30 (1.1.2021) AmigaOne X5000 debug
Machine model: 9 (AmigaOne X5000/20)
Dump of context at 0xEFF21000
Trap type: DSI exception
DSISR: 00800000
DAR: 0FDC6932
No matching page found
Machine State (raw): 0x0002F030
Machine State (verbose): [Critical Ints on] [ExtInt on] [User] [IAT on] [DAT on]
Instruction pointer: in module kernel.debug+0x0003AD54 (0x0183AD54)
Crashed process: Workbench (0x6D664900)
DSI verbose error description: Access to address 0x0FDC6932 not allowed by page protection in user state (protection violation)
Access was a store operation
Exception Syndrome Register: 0x00800000
0: 01868B90 6CF35BC0 00000002 66F1DFDC 66F1DFDC 00000000 00000050 6CF35D28
8: 018417B0 66F1DFDC 0FDC692E 80000001 35933593 0000000D 6FF0756C 02009E34
16: 02010000 02158BD8 02012AFC 02012AE8 01879228 02160000 020107E4 0201084C
24: 00000000 EFFFADC4 020000A0 02160000 01868B90 02160000 66F1D430 66F1DFDC
CR: 55933993 XER: C000006F CTR: 0183AE1C LR: 0183AE8C
Disassembly of crash site:
[_impl_GetInterface] Getting interface mmu of library exec.library
[_impl_GetInterface] Found interface at 0x6FF9F000, checking version
[_impl_GetInterface] Returning interface 0x6FF9F000
[_impl_LockMem] Not all memory was locked
0183AD44: A92A8B98 lha r9,-29800(r10)
[_impl_LockMem] Not all memory was locked
0183AD48: 815E0000 lwz r10,0(r30)
[_impl_LockMem] Not all memory was locked
0183AD4C: 2F890000 cmpwi cr7,r9,0
[_impl_LockMem] Not all memory was locked
0183AD50: 813E0004 lwz r9,4(r30)
[_impl_LockMem] Not all memory was locked
>0183AD54: 912A0004 stw r9,4(r10)
[_impl_LockMem] Not all memory was locked
0183AD58: 40DE0018 bne- cr7,0x183AD70
[_impl_LockMem] Not all memory was locked
0183AD5C: 83E1000C lwz r31,12(r1)
[_impl_LockMem] Not all memory was locked
0183AD60: 7FC3F378 mr r3,r30
[_impl_LockMem] Not all memory was locked
0183AD64: 83C10008 lwz r30,8(r1)
[_impl_LockMem] Not all memory was locked
0183AD68: 38210010 addi r1,r1,16
msr: 0x0002B032
TLB1 (64 entries):
* [ 50]: size=7 tid = 0 TS = 1 epn=0xFE000000 rpn=0x0000000F_FE000000 WIMG=0x5 XXWWRR=0xF protected
* [ 51]: size=6 tid = 0 TS = 1 epn=0x01000000 rpn=0x00000000_01000000 WIMG=0x0 XXWWRR=0x5 protected
* [ 52]: size=6 tid = 0 TS = 1 epn=0x01400000 rpn=0x00000000_01400000 WIMG=0x0 XXWWRR=0x5 protected
* [ 53]: size=6 tid = 0 TS = 1 epn=0x01800000 rpn=0x00000000_01800000 WIMG=0x0 XXWWRR=0x33 protected
* [ 54]: size=6 tid = 0 TS = 1 epn=0x01C00000 rpn=0x00000000_01C00000 WIMG=0x0 XXWWRR=0x33 protected
* [ 55]: size=5 tid = 0 TS = 1 epn=0x02000000 rpn=0x00000000_02000000 WIMG=0x0 XXWWRR=0xF protected
* [ 56]: size=5 tid = 0 TS = 1 epn=0x02100000 rpn=0x00000000_02100000 WIMG=0x0 XXWWRR=0xF protected
* [ 57]: size=5 tid = 0 TS = 1 epn=0x02200000 rpn=0x00000000_02200000 WIMG=0x0 XXWWRR=0xF protected
* [ 58]: size=4 tid = 0 TS = 1 epn=0x02300000 rpn=0x00000000_02300000 WIMG=0x0 XXWWRR=0xF protected
* [ 59]: size=4 tid = 0 TS = 1 epn=0x02340000 rpn=0x00000000_02340000 WIMG=0x0 XXWWRR=0xF protected
* [ 60]: size=3 tid = 0 TS = 1 epn=0x02380000 rpn=0x00000000_02380000 WIMG=0x0 XXWWRR=0xF protected
* [ 61]: size=7 tid = 0 TS = 0 epn=0xFE000000 rpn=0x0000000F_FE000000 WIMG=0x5 XXWWRR=0xF protected
* [ 62]: size=A tid = 0 TS = 0 epn=0x00000000 rpn=0x00000000_00000000 WIMG=0x0 XXWWRR=0x3F protected
* [ 63]: size=A tid = 0 TS = 0 epn=0x40000000 rpn=0x00000000_40000000 WIMG=0x0 XXWWRR=0x3F protected HAL_MaxTLB = 49, HAL_NextTLB = 0
MMUCFG = 0x064809C4
mas0 = 0x103F0000
mas1 = 0xC0000A00
mas2 = 0x40000000
mas3 = 0x4000003F
mas4 = 0x00000100
mas5 = 0x00000000
mas6 = 0x00000001
mas7 = 0x00000000
mas8 = 0x00000000
Kernel command line: serial munge debuglevel=10
Registers pointing to code:
[_impl_OpenLibrary] Trying to open dos.library, version 53
[_impl_OpenLibrary] Found library at 0x6FEA3228
[_impl_OpenLibrary] Calling Open vector of dos.library
[_impl_OpenLibrary] Returned from open vector
[_impl_OpenLibrary] Library node at 0x6FEA3228
[_impl_OpenLibrary] Trying to open elf.library, version 53
[_impl_OpenLibrary] Found library at 0x6FF02154
[_impl_OpenLibrary] Calling Open vector of elf.library
[_impl_OpenLibrary] Returned from open vector
[_impl_OpenLibrary] Library node at 0x6FF02154
[_impl_GetInterface] Getting interface main of library dos.library
[_impl_GetInterface] Found interface at 0x6F86E000, checking version
[_impl_GetInterface] Returning interface 0x6F86E000
[_impl_GetInterface] Getting interface main of library elf.library
[_impl_GetInterface] Found interface at 0x6FFAB780, checking version
[_impl_GetInterface] Returning interface 0x6FFAB780
[SMB2] DEBUG | ‘start’ | Wake up from WaitSelect with 0x00000001 ready descriptors and signals 0x00000000
[SMB2] DEBUG | ‘start’ | Reading from socket request
[SMB2] DEBUG | ‘network’ | NETWORK_processBytes: on socket 0
[SMB2] DEBUG | ‘smbv2’ | SMB2_Decoder: header address 0x66388B10
[SMB2] DEBUG | ‘smbv2’ | SMB2_Decoder: CHECK IT! Frame length is: 81
[SMB2] INFO | ‘smbv2’ | SMB2_Decoder: Decoding SessionSetup Reponse Message ‘SMB2_COMMAND_SESSION_SETUP’ (1)
[SMB2] DEBUG | ‘smbv2’ | decodeSessionSetupResponse: header address 0x66388B10
[SMB2] ERROR | ‘smbv2’ | decodeSessionSetupResponse: Going to allaocte 85 bytes
It looks like the crash is in parallel to the executing of my program and that workbench crashed, and thus my program continues to tun? But interaction is not possible because of the crashed workbench.
Obviously it must be something in my program, which causes the crash. But currently I'm out of ideas.
Anyone any idea how to further track down the cause?
Network programmering is really hard. on amigaos due to the way sockets work, sockets is not shared between threads/processes. Clib2 /newlib is also hiding the Amiga api, and gets in the way.
As for memory corruption, you need slow your program down, you can allocate som large memory blocks, you can just inspect for changes, crc checks. Or try to complete the same code on windows or Linux, bugs often show up other systems with better memory protection.
(NutsAboutAmiga)
Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
If you use a valid share name it can crash because of other circumstances.
Anyway i don't understand why/what on earth the call crashes. I even changed the memory type to MEMF_SHARED from MEMF-PRIVATE, maybe the bsdsocket library requires that?
I think size variable might be 0, try replace with sizeof(struct SMB_Tree_Connect_Response), maybe calloc allocs extra bytes.
Also consider using “new” and “delete”, instead of calloc/malloc/free, and , AllocVec/FreeVec, source code often becomes more readable using classes, and it more likely your code will have less bugs.
(NutsAboutAmiga)
Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.