Skip to content

Commit 1709e24

Browse files
committed
Update glog dependency.
This should address a weird segmentation fault issue we have seen during logging shutdown with older versions of the glog library. I'm also disabling symlinks with SetLogSymlink(), to prevent the duplicate "UNKNOWN.INFO" logfile. Doing so also helps with FreeBSD, because there was an issue with std::filesystem::remove_all (used in our unit test) which was fixed only recently, causing it to error out due to the dangling symlinks: llvm/llvm-project#79540 Bug: b/352597329 Change-Id: Ie4faf2740e8eabc7f9dda9127f571084f1a510b3
1 parent ec932ac commit 1709e24

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

WORKSPACE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ http_archive(
5454
)
5555

5656
http_archive(
57-
name = "com_github_google_glog", # 2020-02-16
58-
sha256 = "6fc352c434018b11ad312cd3b56be3597b4c6b88480f7bd4e18b3a3b2cf961aa",
59-
strip_prefix = "glog-3ba8976592274bc1f907c402ce22558011d6fc5e",
60-
url = "https://github.com/google/glog/archive/3ba8976592274bc1f907c402ce22558011d6fc5e.tar.gz",
57+
name = "com_github_google_glog", # v0.7.1 / 2024-06-08
58+
sha256 = "00e4a87e87b7e7612f519a41e491f16623b12423620006f59f5688bfd8d13b08",
59+
strip_prefix = "glog-0.7.1",
60+
url = "https://github.com/google/glog/archive/refs/tags/v0.7.1.tar.gz",
6161
)
6262

6363
http_archive(

kmsp11/util/logging.cc

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void GrpcLog(gpr_log_func_args* args) {
3636
// Map gRPC severities to glog severities.
3737
// gRPC severities: ERROR, INFO, DEBUG
3838
// glog severities: FATAL, ERROR, WARNING, INFO
39-
int severity;
39+
google::LogSeverity severity;
4040
switch (args->severity) {
4141
// gRPC ERROR -> glog WARNING. gRPC errors aren't necessarily errors for
4242
// us; see e.g. https://github.com/grpc/grpc/issues/22613. We should emit
@@ -61,7 +61,7 @@ void GrpcLog(gpr_log_func_args* args) {
6161
class GlogSink : public absl::LogSink {
6262
public:
6363
virtual void Send(const absl::LogEntry& entry) override {
64-
int severity;
64+
google::LogSeverity severity;
6565
switch (entry.log_severity()) {
6666
case absl::LogSeverity::kError:
6767
severity = google::GLOG_ERROR;
@@ -108,25 +108,33 @@ absl::Status InitializeLogging(std::string_view output_directory,
108108
{google::GLOG_INFO, google::GLOG_WARNING, google::GLOG_ERROR,
109109
google::GLOG_FATAL}) {
110110
google::SetLogDestination(severity, "");
111+
google::SetLogSymlink(severity, "");
111112
}
112113
} else {
113114
// FATAL logs crash the program; emit these to standard error as well.
114115
google::SetStderrLogging(google::GLOG_FATAL);
115116

116-
google::SetLogDestination(
117-
google::GLOG_INFO,
118-
absl::StrCat(output_directory, "/libkmsp11.log-").c_str());
117+
if (!output_filename_suffix.empty()) {
118+
google::SetLogDestination(
119+
google::GLOG_INFO, absl::StrCat(output_directory, "/libkmsp11.log-",
120+
output_filename_suffix, "-")
121+
.c_str());
122+
} else {
123+
google::SetLogDestination(
124+
google::GLOG_INFO,
125+
absl::StrCat(output_directory, "/libkmsp11.log-").c_str());
126+
}
127+
128+
// Disable symlink creation, which causes removal issues on FreeBSD.
129+
// https://www.mail-archive.com/[email protected]/msg79713.html
130+
google::SetLogSymlink(google::GLOG_INFO, "");
119131

120132
// Disable discrete log files for all levels but INFO -- they all still
121133
// get logged to the INFO logfile.
122134
for (google::LogSeverity severity :
123135
{google::GLOG_WARNING, google::GLOG_ERROR, google::GLOG_FATAL}) {
124136
google::SetLogDestination(severity, "");
125-
}
126-
127-
if (!output_filename_suffix.empty()) {
128-
google::SetLogFilenameExtension(
129-
absl::StrCat(output_filename_suffix, "-").c_str());
137+
google::SetLogSymlink(severity, "");
130138
}
131139
}
132140

0 commit comments

Comments
 (0)