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

RecordSet issue since 1.10.0 #4525

Open
petko opened this issue Apr 12, 2024 · 0 comments
Open

RecordSet issue since 1.10.0 #4525

petko opened this issue Apr 12, 2024 · 0 comments
Assignees
Labels

Comments

@petko
Copy link

petko commented Apr 12, 2024

Describe the bug
I get a weird bug with RecordSet when running my tests in debug builds in Visual C++Builder 2019. It works in release builds.

Until Poco 1.9.4 the code using the ExecuteSelectStatementFails function worked properly. Starting with Poco 1.10.0 is shows the following error (currently running Poco 1.12.5p2):

3>minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp(904) : Assertion failed: _CrtIsValidHeapPointer(block)
3>minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp(908) : Assertion failed: is_block_type_valid(header->_block_use)

To Reproduce
I have a simple test in GTest:

#include <Poco/Data/RecordSet.h>
#include <Poco/Data/SessionFactory.h>
#include <Poco/Data/SQLite/Connector.h>

using namespace Poco;
using namespace Poco::Data;
using namespace Poco::Data::Keywords;
using namespace Poco::Data::SQLite;

//-------------------------------------------------------------------------------------------------
RecordSet ExecuteSelectStatementWorks(Session& session, const std::string& sql)
{
    Statement select(session);
    select << sql;
    select.execute();

    // return directly
    return RecordSet(select);
}

//-------------------------------------------------------------------------------------------------
RecordSet ExecuteSelectStatementFails(Session& session, const std::string& sql)
{
    Statement select(session);
    select << sql;
    select.execute();

    // return temp copy
    RecordSet recordSet(select);
    return recordSet;
}

//-------------------------------------------------------------------------------------------------
TEST(PocoSqliteTest, ExecutesSelectStatement)
{
    SQLite::Connector::registerConnector();

    Session session("SQLite", ":memory:");
    
    auto recordSet = ExecuteSelectStatementFails(session, "SELECT sqlite_version()");
       
    ASSERT_TRUE(recordSet.moveFirst());

    SQLite::Connector::unregisterConnector();
}

Expected behavior
I expect calling any of ExecuteSelectStatementWorks and ExecuteSelectStatementFails in the test to work properly.

Please add relevant environment information:
Visual C++ 2019 (latest update) in Windows 10

Additional context
I suspect that the reason is that one is using copy semantics and one is using move semantics and there is a bug in Poco starting with Poco 1.10.0. This version of Poco introduced C++14 support and the move assignment operator for RecordSet.

@petko petko added the bug label Apr 12, 2024
@aleks-f aleks-f self-assigned this May 13, 2024
@aleks-f aleks-f added this to the Release 1.13.4 milestone May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

2 participants