OSC on iPod Touch 7,1 Assertion Fail

Hello,

I’ve got a strange issue with ofxOSC on an iPod 7,1 (Its brand new I guess). Model A1574. It builds, runs, and operates just fine on another 32gb iPod touch 5th gen Model A1421.

As soon as I send an OSC message with the 7,1, I get a SIGABRT at the section:

assert( sizeof(osc::int32) == 4 ); //Here (Really is 8)
assert( sizeof(osc::uint32) == 4 ); //Here (Really is 8)
assert( sizeof(osc::int64) == 8 );
assert( sizeof(osc::uint64) == 8 );

So I changed both to 8’s, and then it passes that, but then goes on to give me a EXC_BAD_ACCESS at:

uint32 *previousElementSizePtr = reinterpret_cast<uint32*>(data_ + *elementSizePtr_);

I’m at a complete loss as to where the issue lies or why its not working on this iPod vs the other slightly older one. I’m guessing its a bug. I’ve tried using the very latest development branch of the osxOsc and this is using of_v20150707_ios_release. I haven’t had any other issues other then that though.

Anyone have any ideas?

-Ryan

Here are a couple images from screen captures of tracebacks.


If you explicitly set the definitions of osc::int32 in OscTypes.h

/*
	oscpack -- Open Sound Control (OSC) packet manipulation library
    http://www.rossbencina.com/code/oscpack

    Copyright (c) 2004-2013 Ross Bencina <rossb@audiomulch.com>

	Permission is hereby granted, free of charge, to any person obtaining
	a copy of this software and associated documentation files
	(the "Software"), to deal in the Software without restriction,
	including without limitation the rights to use, copy, modify, merge,
	publish, distribute, sublicense, and/or sell copies of the Software,
	and to permit persons to whom the Software is furnished to do so,
	subject to the following conditions:

	The above copyright notice and this permission notice shall be
	included in all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
	IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
	ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
	CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
	WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

/*
	The text above constitutes the entire oscpack license; however, 
	the oscpack developer(s) also make the following non-binding requests:

	Any person wishing to distribute modifications to the Software is
	requested to send the modifications to the original developer so that
	they can be incorporated into the canonical version. It is also 
	requested that these non-binding requests be included whenever the
	above license is reproduced.
*/
#ifndef INCLUDED_OSCPACK_OSCTYPES_H
#define INCLUDED_OSCPACK_OSCTYPES_H

#include <cstdint>

namespace osc{

// basic types

#if defined(__BORLANDC__) || defined(_MSC_VER)

typedef __int64 int64;
typedef unsigned __int64 uint64;

#elif defined(__x86_64__) || defined(_M_X64)

typedef long int64;
typedef unsigned long uint64;

#else

typedef long long int64;
typedef unsigned long long uint64;

#endif



#if defined(__x86_64__) || defined(_M_X64)

typedef int32_t int32;
typedef uint32_t uint32;

#else

typedef int32_t int32;
typedef uint32_t uint32;

#endif


enum ValueTypeSizes{
    OSC_SIZEOF_INT32 = 4,
    OSC_SIZEOF_UINT32 = 4,
    OSC_SIZEOF_INT64 = 8,
    OSC_SIZEOF_UINT64 = 8,
};
...

does that work?

Basically an “int” is not always guaranteed to be 32 bits … but oscpack requires that (which could be something oscpack needs to fix).

Also, note there is a comment right about those asserts that says:

        // sanity check integer types declared in OscTypes.h 
        // you'll need to fix OscTypes.h if any of these asserts fail

which is what I did. For a more permanent fix, we should probably try to get all of those types defined using standard <cstdint> upstream. Problem is that those standard types are part of c++11.

http://en.cppreference.com/w/cpp/types/integer

Also, using c++11 static_assert will give you these failures at compile time rather than run-time, which can be nice:

        // sanity check integer types declared in OscTypes.h 
        // you'll need to fix OscTypes.h if any of these asserts fail
        static_assert( sizeof(osc::int32) == 4 );
        static_assert( sizeof(osc::uint32) == 4 );
        static_assert( sizeof(osc::int64) == 8 );
        static_assert( sizeof(osc::uint64) == 8 );

Thanks for the assistance! The above worked however I had to also comment out the following since it was giving me an error saying that they were redefining. It now compiles on both types of iPod. I haven’t tried that on any of the other devices, just these two iPods I have for a particular event.

OscOutboundPacketStream.h:

    #if !(defined(__x86_64__) || defined(_M_X64))
    OutboundPacketStream& operator<<( int rhs )
            { *this << (int32)rhs; return *this; }
#endif

OscReceivedElements.h:

#if !(defined(__x86_64__) || defined(_M_X64))
    ReceivedPacket( const char *contents, int size )
        : contents_( contents )
        , size_( ValidateSize( (osc_bundle_element_size_t)size ) ) {}
#endif
1 Like

I’m having this issue on a Microsoft Surface tablet using MSYS2 and MINGW64. It builds ok but the program stops on

static_assert( sizeof(osc::int64) == 8 );
static_assert( sizeof(osc::uint64) == 8 );

The only solution I could figure out so far is to delete the asserts, then it works fine.

What would be the right solution? I couldn’t figure it out based on the replies above. I tried changing OscTypes.h to various values but none fixed it.

Thank you :slight_smile: