ExistentialAudio/SwiftOSC

OSCServer crashes

Burtan opened this issue · 5 comments

Hi,
when there many messages at once, the OSCServer crashes at line 99.
I tested it with RME TotalMixFX. When enabling the OSC mode for TotalMixFX all data are send at once and the server crashes.

This is the value of data at the crash point:

00100011 01100010 01110101 01101110 01100100 01101100 01100101 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000100 00101111 00110001 00000000 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01101100 01100001 01100010 01100101 01101100 01010011 00110001 00000000 00000000 00101100 01110011 00000000 00000000 01010011 01110101 01100010 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01110011 01101111 01101100 01101111 00101111 00110001 00101111 00110001 00000000 00101100 01100110 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01101100 01100001 01100010 01100101 01101100 01010011 00110010 00000000 00000000 00101100 01110011 00000000 00000000 01010011 01110101 01100010 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01110011 01101111 01101100 01101111 00101111 00110001 00101111 00110010 00000000 00101100 01100110 00000000 00000000 00111111 10000000 00000000 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01101100 01100001 01100010 01100101 01101100 01010011 00110011 00000000 00000000 00101100 01110011 00000000 00000000 01010011 01110101 01100010 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01110011 01101111 01101100 01101111 00101111 00110001 00101111 00110011 00000000 00101100 01100110 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01101100 01100001 01100010 01100101 01101100 01010011 00110100 00000000 00000000 00101100 01110011 00000000 00000000 01010011 01110101 01100010 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01110011 01101111 01101100 01101111 00101111 00110001 00101111 00110100 00000000 00101100 01100110 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01101100 01100001 01100010 01100101 01101100 01010011 00110101 00000000 00000000 00101100 01110011 00000000 00000000 01010011 01110101 01100010 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01110011 01101111 01101100 01101111 00101111 00110001 00101111 00110101 00000000 00101100 01100110 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01101100 01100001 01100010 01100101 01101100 01010011 00110110 00000000 00000000 00101100 01110011 00000000 00000000 01010011 01110101 01100010 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01110011 01101111 01101100 01101111 00101111 00110001 00101111 00110110 00000000 00101100 01100110 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01101100 01100001 01100010 01100101 01101100 01010011 00110111 00000000 00000000 00101100 01110011 00000000 00000000 01010011 01110101 01100010 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01110011 01101111 01101100 01101111 00101111 00110001 00101111 00110111 00000000 00101100 01100110 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01101100 01100001 01100010 01100101 01101100 01010011 00111000 00000000 00000000 00101100 01110011 00000000 00000000 01010011 01110101 01100010 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01110011 01101111 01101100 01101111 00101111 00110001 00101111 00111000 00000000 00101100 01100110 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00010100 00101111 00110001 00101111 01100010 01110101 01110011 01001001 01101110 01110000 01110101 01110100 00000000 00101100 01100110 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00011000 00101111 00110001 00101111 01100010 01110101 01110011 01010000 01101100 01100001 01111001 01100010 01100001 01100011 01101011 00000000 00000000 00101100 01100110 00000000 00000000 00000000 00000000 00000000 00000000

Okay try this hack. Change

             if "#bundle\0".toData() == nextData.subdata(in: Range(0...7)){//matches string #bundle
                    if let newbundle = self.decodeBundle(nextData){
                        bundle?.add(newbundle)
                    } else {
                        bundle = nil
                    }
                } else {
                    
                    if let message = self.decodeMessage(nextData) {
                        bundle?.add(message)
                    } else {
                        bundle = nil
                    }
                }

to

                    if let message = self.decodeMessage(nextData) {
                        bundle?.add(message)
                    } else {
                        bundle = nil
                    }

it's not a proper fix since you can have a bundle in a bundle. But it should work for you in the time being. Hopefully. Let me know the result. I'm pretty sure the issue is because I'm not validating the data properly.

The change prevents the crash yes.

Hi, I had a similar crash with TotalMix.
This fix helped.
It's not your code, I tested with osculator app, which says (not crashing):
"Receive error occurred (OSC UDP Server error: 9902 in #bundle: Invalid bundle received"
There's something fishy on RME's side.