public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/25859] New: glibc parser for /sys/devices/system/cpu/online is incorrect
@ 2020-04-21  0:37 keno at juliacomputing dot com
  2020-04-24 11:42 ` [Bug libc/25859] " fweimer at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: keno at juliacomputing dot com @ 2020-04-21  0:37 UTC (permalink / raw)
  To: glibc-bugs

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

            Bug ID: 25859
           Summary: glibc parser for /sys/devices/system/cpu/online is
                    incorrect
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: keno at juliacomputing dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

glibc uses /sys/devices/system/cpu/online as one of the ways
(and the first one it checks) to implement sysconf(_SC_NPROCESSORS_ONLN).
However, the parser for this file appears to be incorrect, at least
on modern Linux. E.g., on my machine, the file looks like:

```
# echo 0 > /sys/devices/system/cpu/cpu4/online
# cat /sys/devices/system/cpu/online
0-3,5-39
```

glibc assumes that the entires of this file are whitespace
separated. A simple patch would be:

--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -175,7 +175,7 @@ __get_nprocs (void)
            result += m - n + 1;

            l = endp;
-       while (l < re && isspace (*l))
+     while (l < re && *l == ',')
              ++l;
          }
        while (l < re);

That said, I assume this was tested when written, so perhaps there
are linux versions where these are indeed whitespace separated, in
which case

--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -175,7 +175,7 @@ __get_nprocs (void)
            result += m - n + 1;

            l = endp;
-       while (l < re && isspace (*l))
+     while (l < re && (isspace (*l) || *l == ','))
              ++l;
          }
        while (l < re);

may be appropriate.

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

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

* [Bug libc/25859] glibc parser for /sys/devices/system/cpu/online is incorrect
  2020-04-21  0:37 [Bug libc/25859] New: glibc parser for /sys/devices/system/cpu/online is incorrect keno at juliacomputing dot com
@ 2020-04-24 11:42 ` fweimer at redhat dot com
  2020-12-09 14:33 ` schwab@linux-m68k.org
  2020-12-09 14:35 ` schwab@linux-m68k.org
  2 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2020-04-24 11:42 UTC (permalink / raw)
  To: glibc-bugs

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

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-04-24
           Severity|normal                      |minor
              Flags|                            |security-

--- Comment #1 from Florian Weimer <fweimer at redhat dot com> ---
You are right.  The 2.6.32 and 3.10 kernels I tried all use “,”. On 2.6.18,
there's no “online” file, so fallback to /proc/stat is used.

The /proc/stat fallback is also the reason why this bug is not visible to
users.

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

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

* [Bug libc/25859] glibc parser for /sys/devices/system/cpu/online is incorrect
  2020-04-21  0:37 [Bug libc/25859] New: glibc parser for /sys/devices/system/cpu/online is incorrect keno at juliacomputing dot com
  2020-04-24 11:42 ` [Bug libc/25859] " fweimer at redhat dot com
@ 2020-12-09 14:33 ` schwab@linux-m68k.org
  2020-12-09 14:35 ` schwab@linux-m68k.org
  2 siblings, 0 replies; 4+ messages in thread
From: schwab@linux-m68k.org @ 2020-12-09 14:33 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schwab@linux-m68k.org

--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
*** Bug 27038 has been marked as a duplicate of this bug. ***

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

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

* [Bug libc/25859] glibc parser for /sys/devices/system/cpu/online is incorrect
  2020-04-21  0:37 [Bug libc/25859] New: glibc parser for /sys/devices/system/cpu/online is incorrect keno at juliacomputing dot com
  2020-04-24 11:42 ` [Bug libc/25859] " fweimer at redhat dot com
  2020-12-09 14:33 ` schwab@linux-m68k.org
@ 2020-12-09 14:35 ` schwab@linux-m68k.org
  2 siblings, 0 replies; 4+ messages in thread
From: schwab@linux-m68k.org @ 2020-12-09 14:35 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |2.33
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> ---
Fixed in 2.33.

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

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

end of thread, other threads:[~2020-12-09 14:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21  0:37 [Bug libc/25859] New: glibc parser for /sys/devices/system/cpu/online is incorrect keno at juliacomputing dot com
2020-04-24 11:42 ` [Bug libc/25859] " fweimer at redhat dot com
2020-12-09 14:33 ` schwab@linux-m68k.org
2020-12-09 14:35 ` schwab@linux-m68k.org

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).