Fr0sT.Brutal 900 Posted July 1, 2019 (edited) Hi all, spent some time just now on investigating a weird bug, it happened to be a memory AV that wasn't reported or caught by my exception handlers. Finally I came to see TCustomWSocket.ASyncReceive which appeared to just silently swallow any exceptions that happen in TriggerDataAvailable. I suppose it should have HandleBackGroundException(E) shouldn't it? Ver.: 8.58 File: OverbyteIcsWSocket.pas Line: 8427 Edited July 1, 2019 by Fr0sT.Brutal addition Share this post Link to post
Angus Robertson 574 Posted July 1, 2019 Does seem strange the code eats errors on OnDataAvailable silently while some other events do raise an exception. I've updated my version to trigger a background exception, but this change is not absolutely backward compatible, applications that don't have OnBgException assigned will now shut down with an exception window, rather than perhaps continuing to ignore the error, maybe good, maybe bad. This won't go into SVN for a few days, until I've rebuilt and tested all my applications. Angus Share this post Link to post
FPiette 383 Posted July 1, 2019 Why not put a try/except in you OnDataAvailable event handler? Share this post Link to post
Fr0sT.Brutal 900 Posted July 2, 2019 Francois, of course this will do the trick but this means client code must meet some requirements which doesn't seem reliable to me. Angus, well, have exceptions raised and shown could sound bad but it's really much better than have them swallowed silently IMHO. Unawareness of errors could cause mysterious AVs and other non-relative errors in random places. And all systems that claim to be robust should have bg exceptions handler already ¯\_(ツ)_/¯ Share this post Link to post
Angus Robertson 574 Posted July 19, 2019 The change to report exceptions rather than hide them is now in SVN. Angus 1 Share this post Link to post
Fr0sT.Brutal 900 Posted October 7, 2019 Angus, just found that `bMore := FALSE` is still necessary... HandleBackGroundException calls OnException and stuff, then Abort is called, then socket is closed and then all these nested calls finish and... "while bMore do" loop continues :))) Share this post Link to post
Angus Robertson 574 Posted October 7, 2019 Yes, should not have taken that out, we do need to break the loop, I'll put it back. However even that may not stop TriggerDataAvailable being called again since there may still be received data buffered, Much nicer if there was no exception in the first place. Angus Share this post Link to post
Fr0sT.Brutal 900 Posted October 8, 2019 Well, it's always better if no exceptions happen at all but the world isn't perfect ))) Share this post Link to post