Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop in RmtesBufferImpl.cpp #5

Closed
steve16351 opened this issue Sep 15, 2015 · 3 comments
Closed

Infinite loop in RmtesBufferImpl.cpp #5

steve16351 opened this issue Sep 15, 2015 · 3 comments

Comments

@steve16351
Copy link

Hi,

I'm having a problem using the EMA API when processing an update on field 1352 with an RmtesEnum type. I can reproduce the issue with the Consumer200 example by adding this to the decode method:

case DataType::RmtesEnum:           
    cout << fe.getRmtes().toString();
break;

And registering an ongoing interest in BOL.ST and ALFA.ST.

When an update is received on field 1352, sometimes it will loop infinitely in RmtesBufferImpl.cpp in this while loop if it is entered:

RsslRet retCode = rsslRMTESApplyToCache( &_rsslBuffer, &_rsslCacheBuffer );
while ( RSSL_RET_BUFFER_TOO_SMALL == retCode )
    {
        free( _rsslCacheBuffer.data );

        _rsslCacheBuffer.length += _rsslCacheBuffer.length;

        _rsslCacheBuffer.data = (char*)malloc( _rsslCacheBuffer.allocatedLength );
        if ( !_rsslCacheBuffer.data )
        {
            throwMeeException( "Failed to allocate memory in RmtesBufferImpl::apply( const char* , UInt32 )" );
            return;
        }
    }

Is this something you can help with?

Thanks

@seba5
Copy link
Contributor

seba5 commented Sep 15, 2015

Hi,

this appears to be a bug in our code. Inside the while there should be code that calls the
retCode = rsslRMTESApplyToCache
method after allocating a bigger buffer.

@MitchellKato
Copy link
Contributor

Also, make sure you're incrementing the rsslCacheBuffer's allocatedLength, not the length.

rsslRMTESApplyToCache uses that the allocatedLength to determine the buffer length. rsslCacheBuffer.length is used to determine the total amount of memory used by the buffer.

@seba5
Copy link
Contributor

seba5 commented Sep 16, 2015

Submitted a fix for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants