Re: [capnproto] How can a server return an interface and still own it?

2019-04-21 Thread 'Kenton Varda' via Cap'n Proto
Hi Joe, Well, this is a use-after-free problem. We could in theory add code to detect various cases of use-after-free, if we see places where it happens commonly, but there's no good way for us to detect all cases. I recommend instead running your code under valgrind, which is extremely good at ca

Re: [capnproto] How can a server return an interface and still own it?

2019-04-20 Thread Joe Ludwig
That's exactly what it was. The main interface was being freed after the client that it came from. An exception in an IOCP promise is a confusing way to find out that I messed up cleaning up some objects. Is there some way to tell if an event loop (or in my case EzRpcClient since I'm not using

Re: [capnproto] How can a server return an interface and still own it?

2019-04-20 Thread 'Kenton Varda' via Cap'n Proto
Hi Joe, Hmm, I'm not sure. It's helpful to read the comments that you removed, which can be found here: https://github.com/capnproto/capnproto/blob/d68cffe544e8479f3cb01a88d8a547eff8782d71/c++/src/kj/async-win32.c++#L57-L91 IoPromiseAdapter is waiting for a specific event to complete. The comple

Re: [capnproto] How can a server return an interface and still own it?

2019-04-20 Thread Joe Ludwig
Hi Kenton, I think I may be running into some of the cleanup complication you're implying. During that, I think I'm seeing a straight-up bug, though. The snippet of code below is from async-win32.c++, just with the comment blocks removed. Win32IocpEventPort::~IoPromiseAdapter() { if (han

Re: [capnproto] How can a server return an interface and still own it?

2019-04-19 Thread 'Kenton Varda' via Cap'n Proto
Hi Joe, Take a look at the doc comments for thisCap(): inline Capability::Client thisCap(); // Get a capability pointing to this object, much like the `this` keyword. // // The effect of this method is undefined if: // - No capability client has been created pointing to this object. (Th

[capnproto] How can a server return an interface and still own it?

2019-04-18 Thread Joe Ludwig
I have a really simple RPC protocol: interface AvServer { createApp @0 ( name: Text ) -> ( app: AvApp ); } interface AvApp { name @0 () -> ( name: Text ); destroy @1 (); } I implement that on the server with two concrete classes: class AvServerImpl final : public AvServer::Server class