Here's the relevant lldb trace code from return of 'fdes' to point at which
it makes an illegal memory access:
-> 360 return fdes; // ret has a pointer to the FD, needs to be
tracked by the caller
361 }
362
363
(lldb) n
Process 44382 stopped
* thread #1: tid = 0x4a7c3a, 0x000000010004260a node9`lj_vm_ffi_call + 132,
queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010004260a node9`lj_vm_ffi_call + 132
node9`lj_vm_ffi_call + 132:
-> 0x10004260a: movq %rax, 0x90(%rbx)
0x100042611: movaps %xmm0, 0x10(%rbx)
0x100042615: movq %rdx, 0x98(%rbx)
0x10004261c: movaps %xmm1, 0x20(%rbx)
(lldb) n
Process 44382 stopped
* thread #1: tid = 0x4a7c3a, 0x0000000100042611 node9`lj_vm_ffi_call + 139,
queue = 'com.apple.main-thread', stop reason = instruction step over
frame #0: 0x0000000100042611 node9`lj_vm_ffi_call + 139
node9`lj_vm_ffi_call + 139:
-> 0x100042611: movaps %xmm0, 0x10(%rbx)
0x100042615: movq %rdx, 0x98(%rbx)
0x10004261c: movaps %xmm1, 0x20(%rbx)
0x100042620: movq -0x8(%rbp), %rbx
(lldb) n
Process 44382 stopped
* thread #1: tid = 0x4a7c3a, 0x0000000100042615 node9`lj_vm_ffi_call + 143,
queue = 'com.apple.main-thread', stop reason = instruction step over
frame #0: 0x0000000100042615 node9`lj_vm_ffi_call + 143
node9`lj_vm_ffi_call + 143:
-> 0x100042615: movq %rdx, 0x98(%rbx)
0x10004261c: movaps %xmm1, 0x20(%rbx)
0x100042620: movq -0x8(%rbp), %rbx
0x100042624: leave
(lldb) n
Process 44382 stopped
* thread #1: tid = 0x4a7c3a, 0x000000010004261c node9`lj_vm_ffi_call + 150,
queue = 'com.apple.main-thread', stop reason = instruction step over
frame #0: 0x000000010004261c node9`lj_vm_ffi_call + 150
node9`lj_vm_ffi_call + 150:
-> 0x10004261c: movaps %xmm1, 0x20(%rbx)
0x100042620: movq -0x8(%rbp), %rbx
0x100042624: leave
0x100042625: ret
(lldb) n
Process 44382 stopped
* thread #1: tid = 0x4a7c3a, 0x0000000100042620 node9`lj_vm_ffi_call + 154,
queue = 'com.apple.main-thread', stop reason = instruction step over
frame #0: 0x0000000100042620 node9`lj_vm_ffi_call + 154
node9`lj_vm_ffi_call + 154:
-> 0x100042620: movq -0x8(%rbp), %rbx
0x100042624: leave
0x100042625: ret
0x100042626: nop
(lldb) n
Process 44382 stopped
* thread #1: tid = 0x4a7c3a, 0x0000000100042624 node9`lj_vm_ffi_call + 158,
queue = 'com.apple.main-thread', stop reason = instruction step over
frame #0: 0x0000000100042624 node9`lj_vm_ffi_call + 158
node9`lj_vm_ffi_call + 158:
-> 0x100042624: leave
0x100042625: ret
0x100042626: nop
0x100042627: nop
(lldb) n
warning: failed to set breakpoint site at 0x100000000c6 for breakpoint
-30.1: Unable to read memory at breakpoint address.
Process 44382 stopped
* thread #1: tid = 0x4a7c3a, 0x00000001000827ea node9`lj_cconv_ct_ct +
1338, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x0)
frame #0: 0x00000001000827ea node9`lj_cconv_ct_ct + 1338
node9`lj_cconv_ct_ct + 1338:
-> 0x1000827ea: movl (%r14), %eax
0x1000827ed: testl $0x800000, %r12d
0x1000827f4: je 0x100082888 ; lj_cconv_ct_ct + 1496
0x1000827fa: movl %eax, %eax
(lldb)
Post by Jim Burnesstruct Sys_FD
{
int fd;
};
Sys_FD* sys_open_result();
--
local fd = node9.sys_open_result()
print("sys.open(" .. path .. ") returned with value",fd)
if fd then
return ffi.gc(fd, node9.free_fd)
else
return nil
end
--
Sys_FD*
sys_open_result()
{
hproc_t* hp = (hproc_t*) up;
// detach the node at the head of the reply queue
QUEUE* q = QUEUE_HEAD(&hp->repq);
QUEUE_REMOVE(q);
N9SysReq* scall = QUEUE_DATA(q, N9SysReq, req.node);
Sys_FD* fdes = scall->open.ret;
if (fdes != NULL) {
fdes);
}
else {
trace(TRACE_WARN, "sys_open: fdes is null, open failed");
}
// release the system call structure
free(scall);
return fdes;
}
Post by Jim BurnesI can provide much more information if necessary.
Some example code would greatly help.
--
Sincerely,
Alex Parrill