So I'm trying to integrate libuv into Pixie, and all was going well, but I'm hitting a bit of a snag when it comes to opening files. I've tried several things, but my latest iteration is this:

https://github.com/pixie-lang/pixie/blob/async-io-file/pixie/vm/libs/uv_file.py#L104

When running this in CPython it crashes on the call to uv_fs_read with the CPython error "Fatal Python error: GC object already tracked". From what I can tell,  this means something has overwritten Python's memory somehow. The odd thing is, I'm sure I have the signature of the file correct:

UV_EXTERN int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file,
    void* buf, size_t length, int64_t offset, uv_fs_cb cb);

And this doesn't seem to be a problem from libuv, because this is my stacktrace from the crash:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib         0x00007fff8e83c866 __pthread_kill + 10
1   libsystem_pthread.dylib       0x00007fff88f2835c pthread_kill + 92
2   libsystem_c.dylib             0x00007fff9019cb1a abort + 125
3   org.python.python             0x0000000100c73ec1 Py_FatalError + 49
4   org.python.python             0x0000000100bfc523 PyFrame_New + 598
5   org.python.python             0x0000000100c55a74 PyEval_EvalCodeEx + 74
6   org.python.python             0x0000000100bfd796 0x100bd6000 + 161686
7   org.python.python             0x0000000100bdff72 PyObject_Call + 101
8   org.python.python             0x0000000100bea9a7 0x100bd6000 + 84391
9   org.python.python             0x0000000100bdff72 PyObject_Call + 101
10  org.python.python             0x0000000100c281b4 0x100bd6000 + 336308
11  org.python.python             0x0000000100c25091 0x100bd6000 + 323729
12  org.python.python             0x0000000100c0f308 PyObject_RichCompare + 129
13  org.python.python             0x0000000100c5694e PyEval_EvalFrameEx + 1937
14  org.python.python             0x0000000100c5c864 0x100bd6000 + 551012
15  org.python.python             0x0000000100c594d4 PyEval_EvalFrameEx + 13079
16  org.python.python             0x0000000100c56093 PyEval_EvalCodeEx + 1641
17  org.python.python             0x0000000100bfd796 0x100bd6000 + 161686


Anyone have any ideas? 

Thanks,

Timothy