mailing list of musl libc
 help / color / mirror / code / Atom feed
From: =?gb18030?B?ODQ3NTY3MTYx?= <847567161@qq.com>
To: =?gb18030?B?bXVzbA==?= <musl@lists.openwall.com>
Subject: Re: [musl] Question: Why vfprintf call twice printf_core?
Date: Sat, 6 May 2023 13:24:15 +0800	[thread overview]
Message-ID: <tencent_C646F14F79601B2671CCC1CDC21CCF4B7008@qq.com> (raw)
In-Reply-To: <ZFXPREkU6s3xeo04@voyager>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 2832 bytes --]

Thanks for your reply.


1¡¢ Could you tell us what the format string is in your case?
--------------
        snprintf(buf, sizeof(buf), "this is a more typical error message with detail: %s", "No such file or directory");         



2¡¢First call to printf_core() checks to see if there are any major&nbsp;problems with the format string
--------------
Maybe the second call can also checks the format error£¿


3¡¢if the string is using positional arguments (e.g. "%2$d"), also establishes the types of these arguments and writes them into an array.
--------------
I use above format string£¬I think it's a&nbsp;typical error message, I found the first printf_core do string traversal and cost some time showed in perf.


If we remove the first function call when we don't use ("%2$d"), is there any problem£¿Or do you have some advice for impove the vfprintf performance in common scenarios£¿


Regards&nbsp;


Chuang Yin


------------------&nbsp;Original&nbsp;------------------
From:                                                                                                                        "musl"                                                                                    <nullplan@gmx.net&gt;;
Date:&nbsp;Sat, May 6, 2023 11:53 AM
To:&nbsp;"musl"<musl@lists.openwall.com&gt;;

Subject:&nbsp;Re: [musl] Question: Why vfprintf call twice printf_core?



Am Sat, May 06, 2023 at 11:29:36AM +0800 schrieb 847567161:
&gt; Hello,
&gt;&nbsp;&nbsp;&nbsp;&nbsp; I'm analyzing vfprintf performance, I don't know why musl call
&gt;&nbsp;&nbsp;&nbsp;&nbsp; "printf_core(0, fmt, &amp;amp;ap2, nl_arg, nl_type)" here. Could you
&gt;&nbsp;&nbsp;&nbsp;&nbsp; tell me the reason?
&gt;&nbsp;&nbsp;&nbsp;&nbsp; https://gitee.com/openharmony/third_party_musl/blob/master/src/stdio/vfprintf.c#L668
&gt;&nbsp;&nbsp;&nbsp;&nbsp; More info:&nbsp;&nbsp;&nbsp; I use gdb to debug vfprintf , I found it return
&gt;&nbsp;&nbsp;&nbsp;&nbsp; directly when calling printf_core firstly which file parameter is
&gt;&nbsp;&nbsp;&nbsp;&nbsp; 0.
&gt;&nbsp;&nbsp;&nbsp;&nbsp; https://gitee.com/openharmony/third_party_musl/blob/master/src/stdio/vfprintf.c#L526
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Best Regards Chuang Yin

First call to printf_core() checks to see if there are any major
problems with the format string, and if the string is using positional
arguments (e.g. "%2$d"), also establishes the types of these arguments
and writes them into an array. Second call does the actual work.

The shortcut after the first printf_core() call is an error exit. That
means the format string is invalid. Could you tell us what the format
string is in your case?

Additionally, there is something weird with your mail client; it is
writing HTML entities into the plain text.

Ciao,
Markus

[-- Attachment #2: Type: text/html, Size: 4879 bytes --]

  reply	other threads:[~2023-05-06  5:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-06  3:29 847567161
2023-05-06  3:53 ` Markus Wichmann
2023-05-06  5:24   ` =?gb18030?B?ODQ3NTY3MTYx?= [this message]
2023-05-06  6:25     ` Markus Wichmann
2023-05-06 17:55       ` NRK
2023-05-07  1:17       ` Rich Felker
2023-05-07  1:44         ` [musl] =?gb18030?B?u9i4tKO6IFttdXNsXSBRdWVzdGlvbjogV2h5IHZmcHJpbnRmIGNhbGwgdHdpY2UgcHJpbnRmX2NvcmU/?= =?gb18030?B?ODQ3NTY3MTYx?=

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_C646F14F79601B2671CCC1CDC21CCF4B7008@qq.com \
    --to=847567161@qq.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).