Skip to content

Commit

Permalink
webos: configd=r22 (Logger: fix segfaults with 64bit time_t)
Browse files Browse the repository at this point in the history
:Release Notes:
It was already reported by gcc in log.do_compile:

configd/1.2.0-24/git $ grep Wformat= ../temp/log.do_compile | sort -u
../git/src/common/util/Logger.hpp:238:21: warning: format '%ld' expects
argument of type 'long int', but argument 2 has type '__time64_t' {aka
'long long int'} [-Wformat=]
../git/src/common/util/Logger.hpp:278:46: warning: format '%ld' expects
argument of type 'long int', but argument 4 has type '__time64_t' {aka
'long long int'} [-Wformat=]

but it wasn't fatal for the build, "only" causes segfault in runtime.

:Detailed Notes:
Fixes:
  Program received signal SIGSEGV, Segmentation fault.
  __GI_strlen () at ../sysdeps/i386/i586/strlen.S:93
  warning: Source file is more recent than executable.
  93              movl (%eax), %ecx       /* get word (= 4 bytes) in
question */
  (gdb) bt
  #0  __GI_strlen () at ../sysdeps/i386/i586/strlen.S:93
  #1  0xb78e6b49 in __printf_buffer (buf=0xbffff788, format=0x4710a0
"[%5ld.%09ld] [%-7s] %-15s ", ap=0xbffff880 "\251\031G", mode_flags=2)
at /usr/src/debug/glibc/2.40+git/stdio-common/vfprintf-process-arg.c:435
  #2  0xb790684a in __vsnprintf_internal (string=0x48b828
<Logger::getInstance()::s_logger+520> "[  136.000000000] [",
maxlen=1024, format=0x4710a0 "[%5ld.%09ld] [%-7s] %-15s ",
args=0xbffff874 "\210", mode_flags=2) at vsnprintf.c:96
  #3  0xb79b5aa0 in ___snprintf_chk (s=0x48b828
<Logger::getInstance()::s_logger+520> "[  136.000000000] [",
maxlen=1024, flag=1, slen=4294967295, format=0x4710a0 "[%5ld.%09ld]
[%-7s] %-15s ") at snprintf_chk.c:38
  #4  0x0046f81b in snprintf (__s=0x48b828
<Logger::getInstance()::s_logger+520> "[  136.000000000] [", __n=1024,
__fmt=0x4710a0 "[%5ld.%09ld] [%-7s] %-15s ") at
/usr/include/bits/stdio2.h:68
  #5  Logger::writeFile<char const*, int, char const*, LogLevel,
LogType, char const*, char const*> (this=<optimized out>,
logLevel=0x4719a9 "info", msgid=0x47177d "MAIN",
      format=0x474b9c "(%s, %d) %s : LogLevel(%d) / LogType(%d) /
LogPath(%s) / BootStatus(%s)") at
/usr/src/debug/configd/1.2.0-24/src/common/util/Logger.hpp:278
  #6  Logger::write<char const*, int, char const*, LogLevel, LogType,
char const*, char const*> (this=<optimized out>, level=0x4719a9 "info",
msgid=0x47177d "MAIN",
      format=0x474b9c "(%s, %d) %s : LogLevel(%d) / LogType(%d) /
LogPath(%s) / BootStatus(%s)") at
/usr/src/debug/configd/1.2.0-24/src/common/util/Logger.hpp:212
  #7  Logger::info<char const*, int, char const*, LogLevel, LogType,
char const*, char const*> (msgid=0x47177d "MAIN", format=0x474b9c "(%s,
%d) %s : LogLevel(%d) / LogType(%d) / LogPath(%s) / BootStatus(%s)")
      at /usr/src/debug/configd/1.2.0-24/src/common/util/Logger.hpp:174
  #8  Logger::info<char const*, int, char const*, LogLevel, LogType,
char const*, char const*> (msgid=0x47177d "MAIN", format=0x474b9c "(%s,
%d) %s : LogLevel(%d) / LogType(%d) / LogPath(%s) / BootStatus(%s)")
      at /usr/src/debug/configd/1.2.0-24/src/common/util/Logger.hpp:171
  #9  Setting::printSetting (warning: could not convert
'pbnjson::JValue' from the host encoding (ANSI_X3.4-1968) to UTF-32.
  This normally should not happen, please file a bug report.
  this=0x48bea0 <Setting::getInstance()::_instance>) at
/usr/src/debug/configd/1.2.0-24/src/configd/setting/Setting.cpp:204
  #10 0x0041e84e in main (argc=1, argv=0xbffffa54) at
/usr/src/debug/configd/1.2.0-24/src/configd/setting/Setting.h:42

:Testing Performed:
Build Successful

:QA Notes:
N/A

:Issues Addressed:
[WRQ-33135] CCC: configd=r22 (Logger: fix segfaults with 64bit time_t)
[WRQ-32810] configd segfaults with 64-bit time_t

Cherry-picked-from-commit: af552b6f66a93164284528295b1f622497d872e9
Cherry-picked-from-branch:
  • Loading branch information
shr-project authored and ywbyun0815 committed Oct 26, 2024
1 parent fa4f6aa commit 521b41b
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 2 deletions.
6 changes: 4 additions & 2 deletions meta-webos/recipes-webos/configd/configd.bb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DEPENDS = "luna-service2 pmloglib glib-2.0 libpbnjson gtest"
RDEPENDS:${PN} += "configd-data"

WEBOS_VERSION = "1.2.0-24_b3864ffd57d4c1ffc2bb59cbea014e6338ea5bae"
PR = "r21"
PR = "r22"

inherit webos_component
inherit webos_enhanced_submissions
Expand All @@ -25,7 +25,9 @@ inherit webos_machine_dep
inherit webos_distro_variant_dep
inherit webos_public_repo

SRC_URI = "${WEBOSOSE_GIT_REPO_COMPLETE}"
SRC_URI = "${WEBOSOSE_GIT_REPO_COMPLETE} \
file://0001-Logger-fix-segfaults-with-64bit-time_t.patch \
"
S = "${WORKDIR}/git"

inherit webos_systemd
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
From 8bfe69328d1f84014bc42ec11aadaaf3ce5a4234 Mon Sep 17 00:00:00 2001
From: Martin Jansa <martin2.jansa@lgepartner.com>
Date: Mon, 19 Aug 2024 16:44:52 +0200
Subject: [PATCH] Logger: fix segfaults with 64bit time_t

:Release Notes:
It was already reported by gcc in log.do_compile:

configd/1.2.0-24/git $ grep Wformat= ../temp/log.do_compile | sort -u
../git/src/common/util/Logger.hpp:238:21: warning: format '%ld' expects argument of type 'long int', but argument 2 has type '__time64_t' {aka 'long long int'} [-Wformat=]
../git/src/common/util/Logger.hpp:278:46: warning: format '%ld' expects argument of type 'long int', but argument 4 has type '__time64_t' {aka 'long long int'} [-Wformat=]

but it wasn't fatal for the build, "only" causes segfault in runtime.

:Detailed Notes:
Fixes:
Program received signal SIGSEGV, Segmentation fault.
__GI_strlen () at ../sysdeps/i386/i586/strlen.S:93
warning: Source file is more recent than executable.
93 movl (%eax), %ecx /* get word (= 4 bytes) in question */
(gdb) bt
#0 __GI_strlen () at ../sysdeps/i386/i586/strlen.S:93
#1 0xb78e6b49 in __printf_buffer (buf=0xbffff788, format=0x4710a0 "[%5ld.%09ld] [%-7s] %-15s ", ap=0xbffff880 "\251\031G", mode_flags=2) at /usr/src/debug/glibc/2.40+git/stdio-common/vfprintf-process-arg.c:435
#2 0xb790684a in __vsnprintf_internal (string=0x48b828 <Logger::getInstance()::s_logger+520> "[ 136.000000000] [", maxlen=1024, format=0x4710a0 "[%5ld.%09ld] [%-7s] %-15s ", args=0xbffff874 "\210", mode_flags=2) at vsnprintf.c:96
#3 0xb79b5aa0 in ___snprintf_chk (s=0x48b828 <Logger::getInstance()::s_logger+520> "[ 136.000000000] [", maxlen=1024, flag=1, slen=4294967295, format=0x4710a0 "[%5ld.%09ld] [%-7s] %-15s ") at snprintf_chk.c:38
#4 0x0046f81b in snprintf (__s=0x48b828 <Logger::getInstance()::s_logger+520> "[ 136.000000000] [", __n=1024, __fmt=0x4710a0 "[%5ld.%09ld] [%-7s] %-15s ") at /usr/include/bits/stdio2.h:68
#5 Logger::writeFile<char const*, int, char const*, LogLevel, LogType, char const*, char const*> (this=<optimized out>, logLevel=0x4719a9 "info", msgid=0x47177d "MAIN",
format=0x474b9c "(%s, %d) %s : LogLevel(%d) / LogType(%d) / LogPath(%s) / BootStatus(%s)") at /usr/src/debug/configd/1.2.0-24/src/common/util/Logger.hpp:278
#6 Logger::write<char const*, int, char const*, LogLevel, LogType, char const*, char const*> (this=<optimized out>, level=0x4719a9 "info", msgid=0x47177d "MAIN",
format=0x474b9c "(%s, %d) %s : LogLevel(%d) / LogType(%d) / LogPath(%s) / BootStatus(%s)") at /usr/src/debug/configd/1.2.0-24/src/common/util/Logger.hpp:212
#7 Logger::info<char const*, int, char const*, LogLevel, LogType, char const*, char const*> (msgid=0x47177d "MAIN", format=0x474b9c "(%s, %d) %s : LogLevel(%d) / LogType(%d) / LogPath(%s) / BootStatus(%s)")
at /usr/src/debug/configd/1.2.0-24/src/common/util/Logger.hpp:174
#8 Logger::info<char const*, int, char const*, LogLevel, LogType, char const*, char const*> (msgid=0x47177d "MAIN", format=0x474b9c "(%s, %d) %s : LogLevel(%d) / LogType(%d) / LogPath(%s) / BootStatus(%s)")
at /usr/src/debug/configd/1.2.0-24/src/common/util/Logger.hpp:171
#9 Setting::printSetting (warning: could not convert 'pbnjson::JValue' from the host encoding (ANSI_X3.4-1968) to UTF-32.
This normally should not happen, please file a bug report.
this=0x48bea0 <Setting::getInstance()::_instance>) at /usr/src/debug/configd/1.2.0-24/src/configd/setting/Setting.cpp:204
#10 0x0041e84e in main (argc=1, argv=0xbffffa54) at /usr/src/debug/configd/1.2.0-24/src/configd/setting/Setting.h:42

:Testing Performed:
Build Successful

:QA Notes:
N/A

:Issues Addressed:
[WRQ-32810] configd segfaults with 64-bit time_t

Change-Id: I8d0b9ea01adf41e41f7c09852b4b5fa617dff1ac
---
Upstream-Status: Submitted [http://gpro.lge.com/c/webosose/configd/+/428558 Logger: fix segfaults with 64bit time_t]

src/common/util/Logger.hpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/common/util/Logger.hpp b/src/common/util/Logger.hpp
index 4ea6f3c..f1095db 100644
--- a/src/common/util/Logger.hpp
+++ b/src/common/util/Logger.hpp
@@ -235,7 +235,7 @@ private:
cerr << "Error in clock_gettime" << endl;
}

- printf("[%5ld.%09ld] [%-7s] %-15s ", time.tv_sec, time.tv_nsec, logLevel, msgid);
+ printf("[%5jd.%09jd] [%-7s] %-15s ", (intmax_t) time.tv_sec, (intmax_t) time.tv_nsec, logLevel, msgid);
printf(format, args...);
printf("\n");
return true;
@@ -275,7 +275,7 @@ private:
if (sizeof...(args) == 0) {
m_fileStream << "[" << logLevel << "] " << msgid << " "<< format << endl;
} else {
- cnt = snprintf(m_buf, 1024, "[%5ld.%09ld] [%-7s] %-15s ", time.tv_sec, time.tv_nsec, logLevel, msgid);
+ cnt = snprintf(m_buf, 1024, "[%5jd.%09jd] [%-7s] %-15s ", (intmax_t) time.tv_sec, (intmax_t) time.tv_nsec, logLevel, msgid);
cnt += snprintf(m_buf + strlen(m_buf), 1024 - strlen(m_buf), format, args...);
if (cnt < 0 || cnt > 1024) {
return false;

0 comments on commit 521b41b

Please sign in to comment.