moonlight-stream / moonlight-common-c

Core implementation of Nvidia's GameStream protocol
GNU General Public License v3.0
458 stars 167 forks source link

PS Vita crashes with Sunshine AMD on Linux #90

Closed MetalfaceScout closed 9 months ago

MetalfaceScout commented 9 months ago

First I'll let everyone know that I'm a junior dev at best, and I'm still in school. For the most part I don't really know what's going on, so expect some ignorance and such.

I've been trying to fix my Vita crashing when I stream from my computer, and so I forked vita-moonlight (right here) and I managed to get it to build.

To get it to build, I had to add -DNO_MSGAPI to the C flags as CMSG_FIRSTHDR and CMSG_NXTHDR don't seem to exist in the vita sdk.

From here, I can parse coredumps but that's about it. Here's the Dissasembly around a few:

=== THREAD "ControlRecv" <0x4001019b> CRASHED (Data abort exception) ===

DISASSEMBLY AROUND PC: 0x8103c71c (ARM):

8102f70c <enet_protocol_dispatch_incoming_commands+0xf8>:

if (! enet_list_empty (& peer -> dispatchedCommands))
{
peer -> flags |= ENET_PEER_FLAG_NEEDS_DISPATCH;

enet_list_insert (enet_list_end (& host -> dispatchQueue), & peer -> dispatchList);
8102f70c:       4611            mov     r1, r2
8102f70e:       4618            mov     r0, r3
8102f710:       f7fe fbf0       bl      8102def4 <enet_list_insert>
}

return 1;
8102f714:       2301            movs    r3, #1
8102f716:       e009            b.n     8102f72c <enet_protocol_dispatch_incoming_commands+0x118>

default:
break;
8102f718:       bf00            nop
while (! enet_list_empty (& host -> dispatchQueue))
8102f71a:       687b            ldr     r3, [r7, #4]
!!!             f8d3 20b8       ldr.w   r2, [r3, #184]  ; 0xb8 !!!
8102f720:       687b            ldr     r3, [r7, #4]
8102f722:       33b8            adds    r3, #184        ; 0xb8
8102f724:       429a            cmp     r2, r3
8102f726:       f47f af7b       bne.w   8102f620 <enet_protocol_dispatch_incoming_commands+0xc>
}
}

return 0;
8102f72a:       2300            movs    r3, #0

coredump1.txt

Dump2:

DISASSEMBLY AROUND PC: 0x8123a2ec (ARM):

8121c2dc <_vfprintf_r+0x24>:
8121c2dc:       f1b9 0f00       cmp.w   r9, #0
8121c2e0:       d004            beq.n   8121c2ec <_vfprintf_r+0x34>
8121c2e2:       f8d9 3038       ldr.w   r3, [r9, #56]   ; 0x38
8121c2e6:       2b00            cmp     r3, #0
8121c2e8:       f000 81d5       beq.w   8121c696 <_vfprintf_r+0x3de>
!!!             f9bb 300c       ldrsh.w r3, [fp, #12] !!!
8121c2f0:       049e            lsls    r6, r3, #18
8121c2f2:       b29a            uxth    r2, r3
8121c2f4:       d40a            bmi.n   8121c30c <_vfprintf_r+0x54>
8121c2f6:       f443 5300       orr.w   r3, r3, #8192   ; 0x2000
8121c2fa:       b29a            uxth    r2, r3

coredump2.txt

Dump3:

=== THREAD "AudioRecv" <0x400101ad> CRASHED (Data abort exception) ===

DISASSEMBLY AROUND PC: 0x8104a6a4 (ARM):

81017694 <AudioReceiveThreadProc+0xac>:
ListenerCallbacks.connectionTerminated(-1);
break;
}
}

packet->header.size = recvUdpSocket(rtpSocket, &packet->data[0], MAX_PACKET_SIZE, useSelect);
81017694:       693c            ldr     r4, [r7, #16]
81017696:       f897 3027       ldrb.w  r3, [r7, #39]   ; 0x27
8101769a:       f44f 62af       mov.w   r2, #1400       ; 0x578
8101769e:       f009 fccb       bl      81021038 <recvUdpSocket>
810176a2:       4603            mov     r3, r0
!!!             60e3            str     r3, [r4, #12] !!!
if (packet->header.size < 0) {
810176a6:       693b            ldr     r3, [r7, #16]
810176a8:       68db            ldr     r3, [r3, #12]
810176aa:       2b00            cmp     r3, #0
810176ac:       da2a            bge.n   81017704 <AudioReceiveThreadProc+0x11c>
Limelog("Audio Receive: recvUdpSocket() failed: %d\n", (int)LastSocketError());
810176ae:       f64f 23a4       movw    r3, #64164      ; 0xfaa4
810176b2:       Address 0x00000000810176b2 is out of bounds.

coredump3.txt

I apologize for the long post but I wanted to include as much information as I could. I'll provide anything else that's needed.

MetalfaceScout commented 9 months ago

I was able to fix it by using the vita pthread library instead of native calls. I could do a pr if requested.