<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/61698>61698</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            ASAN report wrong memory leak on MUSL libc OS
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          joyhou-hw
      </td>
    </tr>
</table>

<pre>
    The code use std::Thread create a non return thread.
while the main funciton not join this thread, and return directly. 

Compile with  -fsanitize=address  will report an 8bit  and 48bit leak, that is thread_struct and pointer, on musl linux system.
But will OK on glibc OS。
I am not sure this is an issue in asan or in musl libc.
```
#include <string>
#include <chrono>
#include <thread>
#include <getopt.h>
#include <iostream>
#include <sys/time.h>
#include <unistd.h>
#include <sys/prctl.h>

namespace {
class TestTmp {
public:
    TestTmp() :
        procMsgThread_()
    {
        std::cout << "TestTmp construct: " << std::endl;
    }
    virtual ~TestTmp() {
        std::cout << "TestTmp destruct: " << std::endl;
        if (procMsgThread_.joinable()) {
            procMsgThread_.join();
        }
    }
    void Init() {
        procMsgThread_ = std::thread(&TestTmp::BackgroundWorker, this);
    }
    void BackgroundWorker()
    {
        std::cout << "BackgroundWorker begin." << std::endl;
        static_cast<void>(prctl(PR_SET_NAME, "test_work"));
        while (true) {
            std::this_thread::sleep_for(std::chrono::milliseconds(1000));
        }
    }
    std::thread procMsgThread_;
};

static TestTmp * longTimeObj = new TestTmp();
}


int main(int argc,char *argv[])
{

    std::cout << "Process is started."<< std::endl;
    longTimeObj->Init();
    sleep(5);
    return EXIT_SUCCESS;
}

```


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVk9v6jgQ_zTmMioKDoRw4ECBStVuX58WnnZvyHGmiVvHjuxJWfawn33lJEChRbtvI2Qcz8xv_nsivFeFQZyzyT2brAaiodK6-as9lLa5K_eDzOaH-bZEkDZ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