Qemu-ppc Memory leak creating threads
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
QEMU |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
When creating c++ threads (with c++ std::thread), the resulting binary has memory leaks when running with qemu-ppc.
Eg the following c++ program, when compiled with gcc, consumes more and more memory while running at qemu-ppc. (does not have memory leaks when compiling for Intel, when running same binary on real powerpc CPU hardware also no memory leaks).
(Note I used function getCurrentRSS to show available memory, see https:/
Compiler: powerpc-
Os: Debian 10.0 ( Buster) (but same problem seen on Debian 9/stetch)
qemu: qemu-ppc version 3.1.50
---
#include <iostream>
#include <thread>
#include <chrono>
using namespace std::chrono_
// Create/run and join a 100 threads.
void Fun100()
{
// auto b4 = getCurrentRSS();
// std::cout << getCurrentRSS() << std::endl;
for(int n = 0; n < 100; n++)
{
std::thread t([]
{
});
// std::cout << n << ' ' << getCurrentRSS() << std::endl;
t.join();
}
std:
// auto after = getCurrentRSS();
std::cout << b4 << ' ' << after << std::endl;
}
int main(int, char **)
{
Fun100();
Fun100(); // memory used keeps increasing
}
tags: | added: ppc |
tags: | added: linux-user |
Changed in qemu: | |
status: | Confirmed → Fix Released |
Forgive my ignorance of the C++ threading semantics but when do these threads end? Inspection shows we do clear-up CPU and thread structures on exit. That said we do have a comment in linux-user that says:
/* TODO: Free new CPU state if thread creation failed. */
So I wonder if thread creation is actually failing and and that is where we start leaking?