taopq icon indicating copy to clipboard operation
taopq copied to clipboard

std::vector<std::byte> segfaults with gcc-15

Open anders-wind opened this issue 2 months ago • 0 comments

First of all thanks for the Library! I unfortunately do not have the time to come up with a reproducible build, but ill try to be as precise as possible

but In our project we insert a std::vectorstd::byte using a table writer insert

auto ReceivedPacketDB::write(tao::pq::table_writer& tw) const -> void
{
    tw.insert(this->local_trading_date, // absl::CivilDay with custom bind
                   this->local_timestamp, // absl::Time with custom bind
                   this->multicast_address, // std::string
                   this->multicast_port, // uint16_t
                   this->packet); // std::vector<std::byte>
}

If we try to retreive the values afterwards

       writer.push(db::rows::ReceivedPacketDB {
            .local_trading_date = local_trading_date,
            .local_timestamp = time,
            .multicast_address = "213.121.124.15",
            .multicast_port = 12345,
            .packet = std::vector {std::byte {0x12}, std::byte {0xC1}},
        });
        const auto received_packets =
            db_conn->execute(fmt::format("SELECT * FROM {}", db::rows::ReceivedPacketDB::table_name));
        REQUIRE_EQ(received_packets.columns(), db::rows::ReceivedPacketDB::columns.size());
        REQUIRE_EQ(received_packets.size(), 1);

        CHECK_EQ(received_packets[0]["local_trading_date"].as<absl::CivilDay>(), local_trading_date);
        CHECK_EQ(received_packets[0]["local_timestamp"].as<absl::Time>(), time.unwrap<ReceivedTimestamp>());
        CHECK_EQ(received_packets[0]["multicast_address"].as<std::string>(), "213.121.124.15");
        CHECK_EQ(received_packets[0]["multicast_port"].as<uint16_t>(), 12345);
        CHECK_EQ(received_packets[0]["packet"].as<std::vector<std::byte>>(),
                 std::vector {std::byte {0x12}, std::byte {0xC1}});

The code halts on the CHECK_EQ(received_packets[0]["packet"].as<std::vector<std::byte>>(), std::vector {std::byte {0x12}, std::byte {0xC1}}); line and after some time it segfaults

I can see that the data ends up in the database from running psql to access my local postgres docker db

 local_trading_date |   local_timestamp   | multicast_address | multicast_port | packet 
--------------------+---------------------+-------------------+----------------+--------
 2025-10-24         | 1761309915103126351 | 213.121.124.15    |          12345 | \x12c1

Most importantly this does not occur on gcc-13, gcc-14, clang-19, clang-20 or clang-21. The error also does not occur in debug builds.

We build from HEAD which should be from around 2025-07-11.

anders-wind avatar Oct 24 '25 12:10 anders-wind