English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 24 August 2023, 12:35   #1
damex
Registered User
 
Join Date: Aug 2019
Location: PL
Posts: 15
Debugging illegal memory access

I'm working on a bsdsocket client. I have a problem though because it crashes the system (guru) when executing connect(). The funny thing is that it crashes only if the server I'm trying to connect to is down. If it's up - connect() succeeds without an issue.

I ran Enforcer and got the following hit:
Code:
Alert !! Alert 81000005     TCB: 681B0530     USP: 681B1084
Data: 000005C8 68000010 681B12AC D01B6074 FFFFFFFF 00000001 00000001 81000005
Addr: 68000000 681AFBB8 681AFA38 6800E484 000014B6 681B1278 00001588 --------
Stck: 00F81D38 000000FF 6818103C 00F81D64 00FA71A8 FFFFFFFF 68186D18 6800E484
My suspicion is maybe connect() doesn't have access to SocketBase or some other library? I opened "bsdsocket.library" though and everything works if the server on the other side is up.

Any tips for debugging a situation like this will be appreciated!
damex is offline  
Old 24 August 2023, 12:52   #2
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,997
Trashing memory, seems to be too small allocated memory area than necessary, or you free memory first and later use this memory area.
Don_Adan is offline  
Old 24 August 2023, 15:17   #3
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,243
Quote:
Originally Posted by damex View Post
I'm working on a bsdsocket client. I have a problem though because it crashes the system (guru) when executing connect(). The funny thing is that it crashes only if the server I'm trying to connect to is down. If it's up - connect() succeeds without an issue.

Any tips for debugging a situation like this will be appreciated!

It might then only detect the memory trash when you close the connection again.


In terms of debugging tools, this sounds more like a use case for MuForce + MuGuardianAngel which may also report what was written into the memory, and where it was allocated, but such issues are often resolved by a code review. That is, wait one day, then carefully read the sources again and think about what exactly what each step does.
Thomas Richter is offline  
Old 24 August 2023, 15:25   #4
patrik
Registered User
 
patrik's Avatar
 
Join Date: Jan 2005
Location: UmeƄ
Age: 43
Posts: 926
Calling bsdsocket.library functions can use quite some stack and different amounts depending on what it does.

If you are using the stack to some extent in your code, try increasing the stack size above the standard 4kB and see if it solves the problem, it is a very cheap thing to test.
patrik is offline  
Old 24 August 2023, 17:34   #5
damex
Registered User
 
Join Date: Aug 2019
Location: PL
Posts: 15
Thank you All for your suggestions!

@patrik Increasing the stack was the first thing I tried. No luck though.

@Thomas Thanks to MuForce + MuGuardianAngel (and probably SegTracker) I managed to find out that the problem is caused by another part of my program. I got some warnings about timer.device (which I also use). When I commented out my timer code the problem disappeared. Now on to debug the timer code
damex is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
illegal memory access not working jotd support.WinUAE 7 07 July 2019 21:23
memory access speed question Lord Riton Coders. General 42 27 February 2019 14:26
68040 memory access phx Coders. Asm / Hardware 4 10 June 2017 18:32
Break on Memory Access? Khyron support.WinUAE 3 21 August 2010 00:10
access emulated memory ara support.WinUAE 6 03 April 2010 13:05

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:04.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07745 seconds with 15 queries