https://bugs.kde.org/show_bug.cgi?id=398569
Bug ID: 398569 Summary: invalid reads reported in libarmmem memcmp when using strings Product: valgrind Version: 3.13.0 Platform: unspecified OS: unspecified Status: UNCONFIRMED Severity: normal Priority: NOR Component: memcheck Assignee: jsew...@acm.org Reporter: bjorn.vant...@gmail.com Target Milestone: --- Created attachment 114928 --> https://bugs.kde.org/attachment.cgi?id=114928&action=edit Valgrind log Uname -a : Linux raspPDS5 4.14.34-v7+ #1110 SMP Mon Apr 16 15:18:51 BST 2018 armv7l GNU/Linux Valgrind running on a raspberry pi 3 reporting invalid reads of size 8 in the library libarmmem.so. Some investigation later it is revealed that it is in the function memcpy. It happens on concatenating of two strings. Link to stack overflow question https://stackoverflow.com/questions/52270106/valgrind-reporting-invalid-read-with-stdstring. Some code where it happens: /** log message */ void Book::record(std::string file, const int line, const unsigned int level, Identifier id, const std::string message, const std::chrono::high_resolution_clock::time_point timeStamp) { if (!(fileLevels & level) && !(consoleLevels & level)) { return; } auto now = Time::keeper->now(); auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(timeStamp - Time::globalEpoch); //generate message auto entry = std::make_unique<Entry>(level); // Time since startup addField(entry, 0, std::to_string(duration.count())); //UTC Time addField(entry, 1, now.dateTime()); // File std::string stringFile; if (!file.empty()) { stringFile = URL{file}.lastPathComponent(); } addField(entry, 2, stringFile); //Line number addField(entry, 3, std::to_string(line)); //ID addField(entry, 4, id); //Message std::string stringMessage; if(!message.empty()) { addField(entry, 5, message); //this is line LogBook.cpp:87 } else { addField(entry, 5, " empty message."); } *entry << ";"; //queue message this->append(std::move(entry)); } void Book::addField(std::unique_ptr<Entry> &entry, unsigned int index, const std::string &text) { std::string textOutput; if ((spacings.at(index) != 0) && (text.length() > (spacings.at(index) - 1))) { spacings.at(index) = (uint8_t) (text.length() + 2); } entry->setWidth(spacings.at(index)); if(entry->empty()) textOutput = text; else textOutput = ";" + text; //This is line LogBook.cpp:149 if(!textOutput.empty()) (*entry) << textOutput; } -- You are receiving this mail because: You are watching all bug changes.