You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
inttest_zip()
{
mz_zip_archive zip;
memset(&zip, 0, sizeof(zip));
if (!mz_zip_writer_init_file(&zip, "/sdcard/hanwang/wordResult/test.zip", 0))
{
LOGI("Failed to initialize zip writer\n");
return -1;
}
if (!mz_zip_writer_finalize_archive(&zip))
{
LOGE("Failed to finalize zip archive\n");
mz_zip_writer_end(&zip);
return -1;
}
for (int i = 0; i < 50; i++)
{
constchar *str = "hello world";
LOGI("%d add string to zip: %s\n", i, str);
if (!mz_zip_add_mem_to_archive_file_in_place(
std::string("/sdcard/hanwang/wordResult/test.zip").c_str(), ("file1.txt" + std::to_string(i)).c_str(),
str, (mz_uint16)strlen(str),
NULL, 0,
MZ_BEST_COMPRESSION))
{
LOGI("Failed to add file1.txt to zip\n");
return -1;
}
// sleep 1s// std::this_thread::sleep_for(std::chrono::seconds(1));
}
return0;
// 关闭 ZIP 文件if (!mz_zip_writer_finalize_archive(&zip))
{
LOGE("Failed to finalize zip archive\n");
mz_zip_writer_end(&zip);
return -1;
}
mz_zip_writer_end(&zip);
LOGE("test_zip() returns 0\n");
return0;
}
The above code will crash if I don't sleep. I found that fdsan is triggered because of repeated reading and writing of the same fd. If I sleep, fdsan will not be triggered.
The text was updated successfully, but these errors were encountered:
My test codes
The above code will crash if I don't sleep. I found that fdsan is triggered because of repeated reading and writing of the same fd. If I sleep, fdsan will not be triggered.
The text was updated successfully, but these errors were encountered: