Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-148508

lscpu -J produce an invalid JSON

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • rhel-10.3
    • rhel-10.2
    • util-linux
    • None
    • Yes
    • None
    • rhel-base-utils-core
    • 0
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      What were you trying to do that didn't work?

      lscpu -J produce an invalid JSON for no NUMA machines

      What is the impact of this issue to you?

      fail kernel-qe test when do json.loads

      Please provide the package NVR for which the bug is seen:

      1. rpm -qf /usr/bin/lscpu
        util-linux-2.40.2-13.el10.aarch64
      2. uname -r
        6.12.0-176.qcom.el10iv.aarch64

        How reproducible is this bug?:

      100%

      Steps to reproduce

      1. on a machine without numa, check 'lscpu -J'

       

      # cat /sys/devices/soc0/machine  
      SA8775P
      # numactl --hardware
      No NUMA available on this system   # lscpu -J -b -e=cpu,core,node
      {
         "cpus": [
            {
               "cpu": 0,
               "core": 0,
               "node": -
        ...
            },{
               "cpu": 7,
               "core": 7,
               "node": -
            }
         ]
      }
      

      2. try jq for this cmd:

       

       

      # lscpu -J -b -e=cpu,core,node|jq
      jq: parse error: Invalid numeric literal at line 7, column 0
       

      3. try json.load in our test:

       

       

      cputopo_json_str, return_code = runcmd("lscpu -J -b -e=cpu,core,node")
      cputopo_orignal_dict = json.loads(cputopo_json_str)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib64/python3.12/json/__init__.py", line 346, in loads
          return _default_decoder.decode(s)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib64/python3.12/json/decoder.py", line 338, in decode
          obj, end = self.raw_decode(s, idx=_w(s, 0).end())
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib64/python3.12/json/decoder.py", line 356, in raw_decode
          raise JSONDecodeError("Expecting value", s, err.value) from None
      json.decoder.JSONDecodeError: Expecting value: line 6 column 18 (char 79) 

       

       

      Expected results

      Should be able to parse as json, expected: "node": "-".

      Actual results

      There is a missing quotation in node:
      broken: "node": -
       
      Additional info:
      1. test case worked before on rhivos(should be rhivos1.0+kernel_el9).
      2. As consulted info from rskvaril@, this is probably issue https://github.com/util-linux/util-linux/issues/3430, fixed in https://github.com/util-linux/util-linux/pull/3431/commits/049901c63ea7ad8a1e0ba4feeaf7360dbf4bdc2f 
      but we do not have a fix in RHEL-10 (working in RHEL-9). 
       

              rhn-engineering-kzak Karel Zak
              yanqzhan1@redhat.com Yanqiu Zhang
              Karel Zak Karel Zak
              Radka Brychtova Radka Brychtova
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: