I have a class, that owns the RSocket object, manages the connection (connect, disconnect etc) and that issues writes on the socket.
And I have another class, that just reads from the socket.
Both classes derive from CActive.
When I want to close the connection the following code is to be executed in the Writer/Manager class:
iListener->Cancel(); // iListener is the Reader object
iSocket.Close(); // close the socket after the Reader's outstanding read request has been cancelled.
But when the Reader's Cancel() method is executed the application panics: "KERN-EXEC 3". The Symbian documentation tells something about unhandled exceptions, but what exception are being thrown here, and how can they be caught?
I have no idea what the mistake is, the code is mostly copied from an example application...
the KERN-EXEC 3 is memory violation. Basically means using a pointer that is invalid. There are basically two main causes to this error:
1. Trying to use pointer that has NULL value (i.e. not pointing to any object)
2. Using a pointer that is pointing to a memory location that does not have object in it. Usually trying to use object that was deleted previously.
The beast way to prevent this error is to check pointers before using them. Basically just checking that they are something else than NULL. And making sure that every single object when deleted is set to NULL strait in a next line.
Well, I have been trying to check the pointer, that might cause the panic. However, the pointer should be ok. I implemented a Test method into the class, that the pointer is pointing at, and I tried to run that method using the pointer. Works!
Anyways, I am just instantiating that particular class with the NewL/NewLC construct, putting a pointer on the object. So I cannot find anything that might screw up the pointer or the memory that it's pointing at.
So the problem why the program panics must be on calling the Cancel() method. But why? Cancel just means to cancel any outstanding requests, doesn't it? Why does it crash then?