odygrd / quill

Asynchronous Low Latency C++ Logging Library
MIT License
1.14k stars 130 forks source link

Get SIGABRT in creating directories when having symlink folder path and using gcc 8.3.0- gcc9.4.0 #468

Closed WayneY closed 1 month ago

WayneY commented 1 month ago

I don't know if I am the first one to raise this issue or someone has already mentioned this...

Quill Version I used: v2.9.0

Compiler: gcc8.5.0 (actually the same problem exists from gcc8.3.0 to gcc9.4.0)

Platform: RHEL8

Issue:
Create a file handler with a path of , say, "./log/app.log", and the "./log" is actually a symlink to another folder. Quill will throw an exception of "Not a directory"

The root cause is from gcc 8.3.0 to gcc 9.4.0 the fs::create_directoires(path, ec) uses symlink_status(path,ec) instead of status(path,ec) to do some checking. And symlink_status will not follow the link to the target folder, and fails in the is_directory() but succeeds in exists() and then manually assigns a not_a_direcotry exception to ec.

Proposal solution:

In StreamHandler (in later version StreamSink) constructor before calling fs::create_directories(parent_path, ec) call a fs::status to do a check.

Make it be like:

` auto st = fs::status(parent_path, ec); if( not is_directory(st)) { fs::create_directories(parent_path, ec); ....
}

`

odygrd commented 1 month ago

thanks for reporting this and for the solution 👍