<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 154: builtin implementation of snprintf doesn't work</title><link>https://sourceforge.net/p/log4cpp/bugs/154/</link><description>Recent changes to 154: builtin implementation of snprintf doesn't work</description><atom:link href="https://sourceforge.net/p/log4cpp/bugs/154/feed.rss" rel="self"/><language>en</language><lastBuildDate>Wed, 18 Mar 2026 08:52:12 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/log4cpp/bugs/154/feed.rss" rel="self" type="application/rss+xml"/><item><title>#154 builtin implementation of snprintf doesn't work</title><link>https://sourceforge.net/p/log4cpp/bugs/154/?limit=50#da08</link><description>&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;logs using the %d format specifier were truncated too early&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thanks, will keep in mind that there is an issue with implementation of internally shipped snprintf().&lt;/p&gt;
&lt;p&gt;As for cross-compilation for a specific target architecture and relying on the standard snprintf() implementation, I assume that running ./configure with preset variable as shown above is an appropriate solution.&lt;br/&gt;
In common cross-compilation scenario, there is no reliable way to verify whether standard  snprintf() runs correctly on the target platform when building solely on the host system. &lt;br/&gt;
Therefore, assuming that standard snprintf() works as expected on &lt;em&gt;any&lt;/em&gt;  target architecture may be somewhat riskier than using a fallback, even though the fallback has limitations.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexander Perepelkin</dc:creator><pubDate>Wed, 18 Mar 2026 08:52:12 -0000</pubDate><guid>https://sourceforge.netbcaded23e7d2fa8cdd34c9c457b3186991b55e88</guid></item><item><title>#154 builtin implementation of snprintf doesn't work</title><link>https://sourceforge.net/p/log4cpp/bugs/154/?limit=25#e4af</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Unfortunately we didn't keep many more details about the problem, and I don't remember. If I read our internal ticket from back then correctly, logs using the %d format specifier were truncated too early, despite having sufficient space in the output buffer for snprintf (maybe only with "large" numbers).&lt;/p&gt;
&lt;p&gt;Since then, the project has switched to another logging library. So I'm not even able to easily do a build with unpatched log4cpp to check for the exact problem again.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Adrien Destugues</dc:creator><pubDate>Wed, 18 Mar 2026 07:39:45 -0000</pubDate><guid>https://sourceforge.netbed96ec83b356c9059a72051867f91f63b36de9d</guid></item><item><title>#154 builtin implementation of snprintf doesn't work</title><link>https://sourceforge.net/p/log4cpp/bugs/154/?limit=50#06a6</link><description>&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;I'm not sure why the check was set up in the way it is. Does it really need to detect broken implementations of snprintf that return an incorrect value, or could a compile only check be enough?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Here is an answer to why:&lt;br/&gt;
&lt;a href="https://www.gnu.org/software/autoconf/manual/autoconf-2.71/autoconf.html" rel="nofollow"&gt;https://www.gnu.org/software/autoconf/manual/autoconf-2.71/autoconf.html&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;snprintf&lt;/p&gt;
&lt;p&gt;In C99 and later, if the output array isn’t big enough and if no other errors occur, snprintf and vsnprintf truncate the output and return the number of bytes that ought to have been produced. Some older systems return the truncated length (e.g., GNU C Library 2.0.x or IRIX 6.5), some a negative value (e.g., earlier GNU C Library versions), and some the buffer length without truncation (e.g., 32-bit Solaris 7). Also, some buggy older systems ignore the length and overrun the buffer (e.g., 64-bit Solaris 7).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;One possible (though still out-of-library) way to overcome that is to alter your build script. If you know for sure that target system for which you cross-compile actually provides valid snprintf, then:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gh"&gt;#&lt;/span&gt; run customized ./configure
ac_cv_func_snprintf=yes ./configure
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;As a result it uses an internal implementation of snprintf, unfortunately, that's broken, and logs are not correctly formatted.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Internally shipped fallback is taken from &lt;a href="http://www.ijs.si/software/snprintf/" rel="nofollow"&gt;http://www.ijs.si/software/snprintf/&lt;/a&gt; which is not complete replacement for standard snprintf() function.&lt;br/&gt;
Was it totally unusable? Perhaps there are some logs samples left.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexander Perepelkin</dc:creator><pubDate>Tue, 17 Mar 2026 22:31:38 -0000</pubDate><guid>https://sourceforge.net13e4fab60fff95bb9f017353c1f3439038247960</guid></item><item><title>#154 builtin implementation of snprintf doesn't work</title><link>https://sourceforge.net/p/log4cpp/bugs/154/?limit=25#ad2a</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;This was cross-compiling from (if I remember correctly) Debian 11 x86_64, using Yocto to build an arm64 Linux system.&lt;br/&gt;
It is not possible in this configuration for AC_TRY_RUN to actually run the code, as documented in autoconf manual:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/html_node/Runtime.html" rel="nofollow"&gt;https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/html_node/Runtime.html&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Avoid running test programs if possible, because this prevents people from configuring your package for cross-compiling.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;(AC_TRY_RUN is renamed to AC_RUN_IFELSE in current autoconf versions, but it does the same thing, and older version of the documentation had the same warning).&lt;/p&gt;
&lt;p&gt;I'm not sure why the check was set up in the way it is. Does it really need to detect broken implementations of snprintf that return an incorrect value, or could a compile only check be enough?&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Adrien Destugues</dc:creator><pubDate>Tue, 17 Mar 2026 20:46:16 -0000</pubDate><guid>https://sourceforge.net73b43b5d2896be754cb7ff44b04b74429bad2309</guid></item><item><title>#154 builtin implementation of snprintf doesn't work</title><link>https://sourceforge.net/p/log4cpp/bugs/154/?limit=50#b2a7</link><description>&lt;div class="markdown_content"&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;: open --&amp;gt; pending&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alexander Perepelkin</dc:creator><pubDate>Tue, 17 Mar 2026 19:44:53 -0000</pubDate><guid>https://sourceforge.net2298b8b945b441712d6c4cb4c7f5cfd184b4f81c</guid></item><item><title>builtin implementation of snprintf doesn't work</title><link>https://sourceforge.net/p/log4cpp/bugs/154/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;When cross-compiling log4cpp, the detection of snprintf by the autotools macro does not work and by default assumes that snprintf is not available.&lt;br/&gt;
As a result it uses an internal implementation of snprintf, unfortunately, that's broken, and logs are not correctly formatted.&lt;/p&gt;
&lt;p&gt;Her is a suggested fix for the cross compiling case. It assumes that snprintf is always available in this case, which may not be how you want to fix this:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gh"&gt;diff --git a/m4/AC_FUNC_SNPRINTF.m4 b/m4/AC_FUNC_SNPRINTF.m4&lt;/span&gt;
&lt;span class="gh"&gt;index 08af521..e2bfc51 100644&lt;/span&gt;
&lt;span class="gd"&gt;--- a/m4/AC_FUNC_SNPRINTF.m4&lt;/span&gt;
&lt;span class="gi"&gt;+++ b/m4/AC_FUNC_SNPRINTF.m4&lt;/span&gt;
&lt;span class="gu"&gt;@@ -15,7 +15,7 @@ AC_DEFUN([AC_FUNC_SNPRINTF],&lt;/span&gt;
 [AC_TRY_RUN([#include &amp;lt;stdio.h&amp;gt;
 int main () { int l = snprintf(NULL,0,"%d",100); exit (!((3 &amp;lt;= l) || (-1 == l))); }
 ], ac_cv_func_snprintf=yes, ac_cv_func_snprintf=no,
&lt;span class="gd"&gt;-ac_cv_func_snprintf=no)])&lt;/span&gt;
&lt;span class="gi"&gt;+ac_cv_func_snprintf=yes)])&lt;/span&gt;
 if test $ac_cv_func_snprintf = yes; then
   AC_DEFINE(HAVE_SNPRINTF,,[define if the C library has snprintf])
 fi
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Adrien Destugues</dc:creator><pubDate>Thu, 25 Mar 2021 15:31:25 -0000</pubDate><guid>https://sourceforge.netb46b7e995f89148f79ec012aceea651f59456cfe</guid></item><item><title>builtin implementation of snprintf doesn't work</title><link>https://sourceforge.net/p/log4cpp/bugs/154/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Ticket 154 has been modified: builtin implementation of snprintf doesn't work&lt;br/&gt;
Edited By: Alexander Perepelkin (sanchouss_)&lt;br/&gt;
Status updated: 'open' =&amp;gt; 'pending'&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Adrien Destugues</dc:creator><pubDate>Thu, 25 Mar 2021 15:31:25 -0000</pubDate><guid>https://sourceforge.net4577451084e3e5aff9bcf3aea2a5aa31caf18e3f</guid></item></channel></rss>