public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/14267] New: fprintf() function is multithread-unsafe
@ 2012-06-20  5:32 penght at cn dot fujitsu.com
  2012-06-20 15:23 ` [Bug libc/14267] " carlos_odonell at mentor dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: penght at cn dot fujitsu.com @ 2012-06-20  5:32 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14267

             Bug #: 14267
           Summary: fprintf() function is multithread-unsafe
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: penght@cn.fujitsu.com
                CC: carlos@systemhalted.org, drepper.fsp@gmail.com
    Classification: Unclassified


Created attachment 6460
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6460
The Patch can make fprintf() function to multithread-safe

fprintf() uses static variables __printf_function_table and
__printf_va_arg_table indirectly, which are not protected. It is
not safe in multithread circumstance.

When call fprintf() and register_printf_specifier() simultaneously
in multithread circumstance, the following case will cause unsafe.
The case has two threads: A and B.

a. thread B call register_printf_specifier('W', print_widget,
print_widget_arginfo)
b. thread A call fprintf (stdout, "|%W|\n", &mywidget), when judge
   __printf_function_table is not NULL, but not output &mywidget
c. thread B call register_printf_specifier('W', NULL, NULL)
d. thread A output &mywidget when __printf_function_table is NULL
e. programme will Segmentation fault

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libc/14267] fprintf() function is multithread-unsafe
  2012-06-20  5:32 [Bug libc/14267] New: fprintf() function is multithread-unsafe penght at cn dot fujitsu.com
@ 2012-06-20 15:23 ` carlos_odonell at mentor dot com
  2012-12-03 22:12 ` davem at davemloft dot net
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: carlos_odonell at mentor dot com @ 2012-06-20 15:23 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14267

Carlos O'Donell <carlos_odonell at mentor dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carlos_odonell at mentor
                   |                            |dot com
   Target Milestone|---                         |2.17

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libc/14267] fprintf() function is multithread-unsafe
  2012-06-20  5:32 [Bug libc/14267] New: fprintf() function is multithread-unsafe penght at cn dot fujitsu.com
  2012-06-20 15:23 ` [Bug libc/14267] " carlos_odonell at mentor dot com
@ 2012-12-03 22:12 ` davem at davemloft dot net
  2012-12-03 23:59 ` carlos at systemhalted dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: davem at davemloft dot net @ 2012-12-03 22:12 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14267

David S. Miller <davem at davemloft dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |davem at davemloft dot net
   Target Milestone|2.17                        |2.18

--- Comment #1 from David S. Miller <davem at davemloft dot net> 2012-12-03 22:12:33 UTC ---
This change should be rearranged such that we only take the lock if the feature
in question is used, rather than unconditionally.  Otherwise non-users of the
feature take a performance hit, and that's undesirable.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libc/14267] fprintf() function is multithread-unsafe
  2012-06-20  5:32 [Bug libc/14267] New: fprintf() function is multithread-unsafe penght at cn dot fujitsu.com
  2012-06-20 15:23 ` [Bug libc/14267] " carlos_odonell at mentor dot com
  2012-12-03 22:12 ` davem at davemloft dot net
@ 2012-12-03 23:59 ` carlos at systemhalted dot org
  2013-05-22  9:34 ` ondra at iuuk dot mff.cuni.cz
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: carlos at systemhalted dot org @ 2012-12-03 23:59 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14267

Carlos O'Donell <carlos at systemhalted dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|carlos_odonell at mentor    |
                   |dot com                     |

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libc/14267] fprintf() function is multithread-unsafe
  2012-06-20  5:32 [Bug libc/14267] New: fprintf() function is multithread-unsafe penght at cn dot fujitsu.com
                   ` (2 preceding siblings ...)
  2012-12-03 23:59 ` carlos at systemhalted dot org
@ 2013-05-22  9:34 ` ondra at iuuk dot mff.cuni.cz
  2013-05-22 14:54 ` carlos at redhat dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ondra at iuuk dot mff.cuni.cz @ 2013-05-22  9:34 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14267

OndrejBilka <ondra at iuuk dot mff.cuni.cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING
                 CC|                            |ondra at iuuk dot
                   |                            |mff.cuni.cz

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libc/14267] fprintf() function is multithread-unsafe
  2012-06-20  5:32 [Bug libc/14267] New: fprintf() function is multithread-unsafe penght at cn dot fujitsu.com
                   ` (3 preceding siblings ...)
  2013-05-22  9:34 ` ondra at iuuk dot mff.cuni.cz
@ 2013-05-22 14:54 ` carlos at redhat dot com
  2014-02-07  3:27 ` [Bug stdio/14267] " jsm28 at gcc dot gnu.org
  2014-06-25 10:54 ` fweimer at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: carlos at redhat dot com @ 2013-05-22 14:54 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14267

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aoliva at redhat dot com

--- Comment #2 from Carlos O'Donell <carlos at redhat dot com> 2013-05-22 14:54:19 UTC ---
Peng,

I agree with David, these changes need to be considered carefully because
fprintf() is a function that everyone uses. Simply adding a lock here is going
to impact performance for everyone.

I suggest you follow Alex's posted patches and the discussion threads here:
http://sourceware.org/ml/libc-alpha/2013-03/msg00581.html
http://sourceware.org/ml/libc-alpha/2013-04/msg00023.html
http://sourceware.org/ml/libc-alpha/2013-05/msg00120.html

The first step is going to be to document the exact contract we want to have
with our users, including possibly declaring that register_printf_specifier()
is MT-unsafe, but that fprintf() *IS* MT-safe with exceptions (don't call
register_printf_specifier).

I encourage you to review Alex's work and provide feedback and help submit bugs
where appropriate.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug stdio/14267] fprintf() function is multithread-unsafe
  2012-06-20  5:32 [Bug libc/14267] New: fprintf() function is multithread-unsafe penght at cn dot fujitsu.com
                   ` (4 preceding siblings ...)
  2013-05-22 14:54 ` carlos at redhat dot com
@ 2014-02-07  3:27 ` jsm28 at gcc dot gnu.org
  2014-06-25 10:54 ` fweimer at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2014-02-07  3:27 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=14267

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libc                        |stdio

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug stdio/14267] fprintf() function is multithread-unsafe
  2012-06-20  5:32 [Bug libc/14267] New: fprintf() function is multithread-unsafe penght at cn dot fujitsu.com
                   ` (5 preceding siblings ...)
  2014-02-07  3:27 ` [Bug stdio/14267] " jsm28 at gcc dot gnu.org
@ 2014-06-25 10:54 ` fweimer at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: fweimer at redhat dot com @ 2014-06-25 10:54 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=14267

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-25 10:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-20  5:32 [Bug libc/14267] New: fprintf() function is multithread-unsafe penght at cn dot fujitsu.com
2012-06-20 15:23 ` [Bug libc/14267] " carlos_odonell at mentor dot com
2012-12-03 22:12 ` davem at davemloft dot net
2012-12-03 23:59 ` carlos at systemhalted dot org
2013-05-22  9:34 ` ondra at iuuk dot mff.cuni.cz
2013-05-22 14:54 ` carlos at redhat dot com
2014-02-07  3:27 ` [Bug stdio/14267] " jsm28 at gcc dot gnu.org
2014-06-25 10:54 ` fweimer at redhat dot com

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 read-only IMAP folder(s) and NNTP newsgroup(s).