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
When trying to gzip some file in a separate thread it leads to segfault on GC call when it tries to release file handle.
It works with old vibe-d:core.
vibe-core: 1.6.0 vibe-d: 0.8.5-beta.1 os: fedora linux x86_64
Testcase
#!/usr/bin/env dub/+ dub.sdl: name "gzipseg" dependency "vibe-d:stream" version="~>0.8.5-beta.1"+/importcore.thread;
importstd.stdio;
import vibe.core.file : FileMode, openFile;
import vibe.stream.wrapper : pipe;
import vibe.stream.zlib : createGzipOutputStream;
enum fname = "foo.txt";
voidmain()
{
auto th = newThread(
{
"foo".toFile(fname);
auto fin = openFile(fname);
auto fout = openFile(fname ~".gz", FileMode.append);
auto gz = createGzipOutputStream(fout);
fin.pipe(gz);
gz.finalize();
fin.close();
fout.close();
}
);
th.start();
th.join();
}
The problem that happens here is that the FileStream is freed by the GC at program exit, because the GZipOutputStream is GC allocated. However, the owning thread has already terminated, so the handle cannot be freed there anymore (which is needed for eventcore's current threading model).
There are three fixes for this that should all be implemented:
Detect that the owner thread is terminated and leak the handle instead of crashing
Switch ZlibStream to an RC struct
Let ZlibStream.finalize clear the underlying stream handle
When trying to gzip some file in a separate thread it leads to segfault on GC call when it tries to release file handle.
It works with old
vibe-d:core
.vibe-core: 1.6.0
vibe-d: 0.8.5-beta.1
os: fedora linux x86_64
Testcase
Leads to:
The text was updated successfully, but these errors were encountered: