simfactory's core detection code fails catastrophically for LANG=zh_CN.utf8

Issue #2152 resolved
Roland Haas created an issue

There is a report on the ET mailing list (http://lists.einsteintoolkit.org/pipermail/users/2018-May/006250.html) about simfactory failing. This can be worked around by setting LANG=C LC_ALL=C (or an English locale for that matter).

Naturally the code in simfactory only works for English locales since it parses the field names and looks for only English names of the field so eg:

$ LANG=de_DE.utf8 simfactory/bin/sim setup-silent
Unknown machine name ekohaes8.ncsa.illinois.edu
Warning: Cannot find Number of Cores per CPU, using default 1

which is expected. However setting LANG to a Chinese locale gives an error that aborts the code:

LANG=zh_CN.utf8 simfactory/bin/sim setup-silent                     Unknown machine name ekohaes8.ncsa.illinois.edu


Here we will define some necessary Simulation Factory defaults.


Determining local machine name: ekohaes8.ncsa.illinois.edu
Traceback (most recent call last):
  File "simfactory/bin/../lib/sim.py", line 148, in <module>
    main()
  File "simfactory/bin/../lib/sim.py", line 144, in main
    CommandDispatch()
  File "simfactory/bin/../lib/sim.py", line 106, in CommandDispatch
    module.main()
  File "/data/rhaas/postdoc/gr/cactus/ET_trunk/repos/simfactory2/lib/sim-util.py", line 266, in main
    CommandDispatch()
  File "/data/rhaas/postdoc/gr/cactus/ET_trunk/repos/simfactory2/lib/sim-util.py", line 51, in CommandDispatch
    exec("command_%s()" % command)
  File "<string>", line 1, in <module>
  File "/data/rhaas/postdoc/gr/cactus/ET_trunk/repos/simfactory2/lib/sim-util.py", line 100, in command_setup_silent
    dt.begin()
  File "/data/rhaas/postdoc/gr/cactus/ET_trunk/repos/simfactory2/lib/simdt.py", line 135, in begin
    self.action(dd)
  File "/data/rhaas/postdoc/gr/cactus/ET_trunk/repos/simfactory2/lib/simdt.py", line 186, in action
    results = eval("self.macro_%s" % action)
  File "<string>", line 1, in <module>
  File "/data/rhaas/postdoc/gr/cactus/ET_trunk/repos/simfactory2/lib/simdt.py", line 471, in macro_CREATE_MACHINE
    cpu_info[l[0]] = l[1].strip('.\n ').strip('kB')
IndexError: list index out of range

which should not happen. No matter the error, simfactory must at worst revert to "1 core per cpu" settings since it is the very first thing that people execute when using the ET.

The issue ends up being that the Chinese locale uses a different ":" symbol that looks visually similar but (seems to) has the same width as a Chinese character and not that of a Latin one:

架构:           x86_64

where the difference is between ":" and ":".

A simple fix may be to try and call lscpu with the "C" locale which must always exist (see https://www.gnu.org/software/libc/manual/html_node/Choosing-Locale.html).

A similar issue may exist in other places where we parse command output.

Keyword: GetComponents

Comments (3)

  1. Log in to comment