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

Create issue
Issue #2152 closed
Roland Haas created an issue

There is a report on the ET mailing list ( 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
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

Here we will define some necessary Simulation Factory defaults.

Determining local machine name:
Traceback (most recent call last):
  File "simfactory/bin/../lib/", line 148, in <module>
  File "simfactory/bin/../lib/", line 144, in main
  File "simfactory/bin/../lib/", line 106, in CommandDispatch
  File "/data/rhaas/postdoc/gr/cactus/ET_trunk/repos/simfactory2/lib/", line 266, in main
  File "/data/rhaas/postdoc/gr/cactus/ET_trunk/repos/simfactory2/lib/", 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/", line 100, in command_setup_silent
  File "/data/rhaas/postdoc/gr/cactus/ET_trunk/repos/simfactory2/lib/", line 135, in begin
  File "/data/rhaas/postdoc/gr/cactus/ET_trunk/repos/simfactory2/lib/", 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/", 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

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

Keyword: GetComponents

Comments (4)

  1. Log in to comment