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

[C++] operator<< for schema version X can't print messages with schema version Y #839

Closed
lukeocamden opened this issue Mar 9, 2021 · 0 comments

Comments

@lukeocamden
Copy link

lukeocamden commented Mar 9, 2021

From CppGenerator.java:

            "template<typename CharT, typename Traits>\n" +
            "friend std::basic_ostream<CharT, Traits> & operator << (\n" +
            "    std::basic_ostream<CharT, Traits> &builder, %1$s _writer)\n" +
            "{\n" +
            "    %1$s writer(_writer.m_buffer, _writer.m_offset,\n" +
            "        _writer.m_bufferLength, _writer.sbeBlockLength(), _writer.m_actingVersion);\n" +

I think the problem here is use of sbeBlockLength which is the decoder's block length and not the message's block length, which means if the block length has changed between the two versions then we will misinterpret the message. In contrast, we use the message's schema version via m_actingVersion, instead of the decoder's schema version.

Is there a simple way to fix this? Or - if by design - at least to compare m_actingVersion against sbeSchemaVersion to detect misuse of operator<<?

Thanks!

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

2 participants