Closed Bug 1603557 Opened 5 years ago Closed 5 years ago

TypeError: environment can only contain strings

Categories

(Testing :: XPCShell Harness, defect, P3)

Version 3
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1608091

People

(Reporter: mossop, Assigned: mossop)

References

Details

Attachments

(1 file, 1 obsolete file)

I periodically hit this error when running xpcshell tests. This case was on windows though I think I've seen it on other platforms. Normally just running the tests again works fine.

Error running mach:

    ['test', 'browser/components/ssb/']

The error occurred in code that was called by the mach command. This is either
a bug in the called code itself or in the way that mach is calling it.
You can invoke |./mach busted| to check if this issue is already on file. If it
isn't, please use |./mach busted file| to report it. If |./mach busted| is
misbehaving, you can also inspect the dependencies of bug 1543241.

If filing a bug, please include the full output of mach, including this error
message.

The details of the failure are as follows:

TypeError: environment can only contain strings

  File "c:\mozilla\source\trunk\testing/mach_commands.py", line 387, in test
    argv=extra_args, test_objects=tests, **kwargs)
  File "c:\mozilla\source\trunk\python/mach\mach\registrar.py", line 152, in dispatch
    return self._run_command_handler(handler, context=context, **kwargs)
  File "c:\mozilla\source\trunk\python/mach\mach\registrar.py", line 109, in _run_command_handler
    result = fn(**kwargs)
  File "c:\mozilla\source\trunk\testing/xpcshell/mach_commands.py", line 261, in run_xpcshell_test
    return xpcshell.run_test(**params)
  File "c:\mozilla\source\trunk\testing/xpcshell/mach_commands.py", line 60, in run_test
    return self.run_suite(**kwargs)
  File "c:\mozilla\source\trunk\testing/xpcshell/mach_commands.py", line 46, in run_suite
    return self._run_xpcshell_harness(**kwargs)
  File "c:\mozilla\source\trunk\testing/xpcshell/mach_commands.py", line 136, in _run_xpcshell_harness
    result = xpcshell.runTests(filtered_args)
  File "c:\mozilla\source\trunk\testing/xpcshell\runxpcshelltests.py", line 1357, in runTests
    self.trySetupNode()
  File "c:\mozilla\source\trunk\testing/xpcshell\runxpcshelltests.py", line 1162, in trySetupNode
    startServer('moz-http2', os.path.join(myDir, 'moz-http2', 'moz-http2.js'))
  File "c:\mozilla\source\trunk\testing/xpcshell\runxpcshelltests.py", line 1144, in startServer
    stderr=PIPE, env=self.env, cwd=os.getcwd())
  File "c:\mozilla-build\python\lib\subprocess.py", line 394, in __init__
    errread, errwrite)
  File "c:\mozilla-build\python\lib\subprocess.py", line 644, in _execute_child
    startupinfo)

self.env is setup in buildEnvironment(), which begins by copying os.environ: There may be something in your local OS environment that is triggering this failure. (But I can't think of why running again would be okay...)

I think buildEnvironment() should be updated to filter out any non-string env variables to avoid this sort of trouble.

Priority: -- → P3
Attached file env.py

I managed to dump self.env at the point that we call into subprocess for a case that failed. It doesn't look like there is anything odd in there. There are a pair of unicode strings but from the python source it looks like the test that is failing is PyUnicode_Check so I wouldn't expect that to be a problem. I guess it is possible that when dumping to the console some bad characters got dropped.

And again without any changes, running the same exact command in the same console window where it just failed succeeded.

Oh, google searches say that it is in fact those unicode strings. And we've fixed this before in various parts of the code and have a helper to solve it: https://searchfox.org/mozilla-central/rev/6305f6935f496b3a302c7afcc579399a4217729c/python/mozbuild/mozbuild/util.py#1436

See Also: → 1607121
Assignee: nobody → dtownsend
Status: NEW → ASSIGNED
Pushed by dtownsend@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f55ac343844f Sanitize the environment before running xpcshell tests. r=firefox-build-system-reviewers,chmanchester

Backed out changeset f55ac343844f (bug 1603557) for xpcshell failures for No module named mozbuild.util

Backout: https://hg.mozilla.org/integration/autoland/rev/81574cb9c92496048cfa80db878d41e329f3471c

Failure push: https://treeherder.mozilla.org/#/jobs?repo=autoland&revision=f55ac343844fd7fc7be1499527fbbab5ff4508b4

Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=285127810&repo=autoland&lineNumber=1289

task 2020-01-16T01:07:50.158Z] 01:07:50 INFO - INFO - File linux64-minidump_stackwalk retrieved from local cache /builds/worker/tooltool-cache
[task 2020-01-16T01:07:50.185Z] 01:07:50 INFO - Return code: 0
[task 2020-01-16T01:07:50.185Z] 01:07:50 INFO - Chmoding /builds/worker/workspace/build/linux64-minidump_stackwalk to 0755
[task 2020-01-16T01:07:50.187Z] 01:07:50 INFO - Running the command /builds/worker/workspace/build/venv/bin/python -u /builds/worker/workspace/build/tests/xpcshell/remotexpcshelltests.py --xre-path=/builds/worker/workspace/build/hostutils/host-utils-71.0a1.en-US.linux-x86_64 --testing-modules-dir=/builds/worker/workspace/build/tests/modules --apk=/builds/worker/workspace/build/geckoview-androidTest.apk --no-logfiles --symbols-path=https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/A_VibfEURTuG-n6dGqpkOw/artifacts/public/build/target.crashreporter-symbols.zip --manifest=tests/xpcshell.ini --log-raw=/builds/worker/workspace/build/blobber_upload_dir/xpcshell_raw.log --log-raw-level=info --log-errorsummary=/builds/worker/workspace/build/blobber_upload_dir/xpcshell_errorsummary.log --log-tbpl-level=info --test-plugin-path=none --deviceSerial=emulator-5554 --setpref=media.peerconnection.mtransport_process=false --setpref=network.process.enabled=false browser/components/aboutlogins/tests/unit/xpcshell.ini browser/components/migration/tests/unit/xpcshell.ini browser/components/search/test/unit/xpcshell.ini browser/components/syncedtabs/test/xpcshell/xpcshell.ini browser/components/urlbar/tests/unit/xpcshell.ini browser/modules/test/unit/xpcshell.ini devtools/client/aboutdebugging/test/unit/xpcshell.ini devtools/client/inspector/changes/test/unit/xpcshell.ini devtools/client/memory/test/unit/xpcshell.ini devtools/client/performance/test/unit/xpcshell.ini devtools/client/shared/remote-debugging/test/unit/xpcshell.ini devtools/platform/tests/unit/xpcshell.ini devtools/shared/adb/test/xpcshell.ini devtools/shared/performance/test/xpcshell.ini devtools/shared/security/tests/unit/xpcshell.ini devtools/shared/transport/tests/unit/xpcshell.ini docshell/test/unit/xpcshell.ini dom/abort/tests/unit/xpcshell.ini dom/base/test/unit_ipc/xpcshell.ini dom/indexedDB/test/unit/xpcshell-child-process.ini dom/notification/test/unit/xpcshell.ini dom/quota/test/unit/telemetry/xpcshell.ini dom/quota/test/unit/upgrades/xpcshell.ini dom/quota/test/unit/xpcshell.ini extensions/pref/autoconfig/test/unit/xpcshell.ini image/test/unit/xpcshell.ini intl/strres/tests/unit/xpcshell.ini js/ductwork/debugger/tests/xpcshell.ini modules/libmar/tests/unit/xpcshell.ini modules/libpref/test/unit/xpcshell.ini parser/xml/test/unit/xpcshell.ini remote/test/unit/xpcshell.ini security/manager/ssl/tests/unit/xpcshell.ini services/settings/test/unit/xpcshell.ini services/sync/tests/unit/xpcshell.ini testing/marionette/test/unit/xpcshell.ini testing/modules/tests/xpcshell/xpcshell.ini toolkit/components/captivedetect/test/unit/xpcshell.ini toolkit/components/cloudstorage/tests/unit/xpcshell.ini toolkit/components/commandlines/test/unit_win/xpcshell.ini toolkit/components/crashmonitor/test/unit/xpcshell.ini toolkit/components/enterprisepolicies/tests/xpcshell/xpcshell.ini toolkit/components/mediasniffer/test/unit/xpcshell.ini toolkit/components/places/tests/expiration/xpcshell.ini toolkit/components/places/tests/legacy/xpcshell.ini toolkit/components/places/tests/queries/xpcshell.ini toolkit/components/places/tests/unit/xpcshell.ini toolkit/components/satchel/test/unit/xpcshell.ini toolkit/components/search/tests/xpcshell/searchconfigs/xpcshell-3.ini toolkit/components/search/tests/xpcshell/xpcshell.ini toolkit/components/telemetry/tests/unit/xpcshell.ini toolkit/components/url-classifier/tests/unit/xpcshell.ini toolkit/components/utils/test/unit/xpcshell.ini toolkit/crashreporter/test/unit/xpcshell-phc.ini toolkit/crashreporter/test/unit_ipc/xpcshell.ini toolkit/modules/tests/xpcshell/xpcshell.ini toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/xpcshell.ini toolkit/mozapps/update/tests/unit_aus_update/xpcshell.ini toolkit/profile/xpcshell/xpcshell.ini tools/profiler/tests/xpcshell/xpcshell.ini widget/tests/unit/xpcshell.ini xpcom/tests/unit/xpcshell.ini
[task 2020-01-16T01:07:50.187Z] 01:07:50 INFO - ##### xpcshell log begins
[task 2020-01-16T01:07:50.187Z] 01:07:50 INFO - Running command: ['/builds/worker/workspace/build/venv/bin/python', '-u', '/builds/worker/workspace/build/tests/xpcshell/remotexpcshelltests.py', '--xre-path=/builds/worker/workspace/build/hostutils/host-utils-71.0a1.en-US.linux-x86_64', '--testing-modules-dir=/builds/worker/workspace/build/tests/modules', u'--apk=/builds/worker/workspace/build/geckoview-androidTest.apk', '--no-logfiles', u'--symbols-path=https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/A_VibfEURTuG-n6dGqpkOw/artifacts/public/build/target.crashreporter-symbols.zip', '--manifest=tests/xpcshell.ini', '--log-raw=/builds/worker/workspace/build/blobber_upload_dir/xpcshell_raw.log', '--log-raw-level=info', '--log-errorsummary=/builds/worker/workspace/build/blobber_upload_dir/xpcshell_errorsummary.log', '--log-tbpl-level=info', '--test-plugin-path=none', '--deviceSerial=emulator-5554', '--setpref=media.peerconnection.mtransport_process=false', '--setpref=network.process.enabled=false', u'browser/components/aboutlogins/tests/unit/xpcshell.ini', u'browser/components/migration/tests/unit/xpcshell.ini', u'browser/components/search/test/unit/xpcshell.ini', u'browser/components/syncedtabs/test/xpcshell/xpcshell.ini', u'browser/components/urlbar/tests/unit/xpcshell.ini', u'browser/modules/test/unit/xpcshell.ini', u'devtools/client/aboutdebugging/test/unit/xpcshell.ini', u'devtools/client/inspector/changes/test/unit/xpcshell.ini', u'devtools/client/memory/test/unit/xpcshell.ini', u'devtools/client/performance/test/unit/xpcshell.ini', u'devtools/client/shared/remote-debugging/test/unit/xpcshell.ini', u'devtools/platform/tests/unit/xpcshell.ini', u'devtools/shared/adb/test/xpcshell.ini', u'devtools/shared/performance/test/xpcshell.ini', u'devtools/shared/security/tests/unit/xpcshell.ini', u'devtools/shared/transport/tests/unit/xpcshell.ini', u'docshell/test/unit/xpcshell.ini', u'dom/abort/tests/unit/xpcshell.ini', u'dom/base/test/unit_ipc/xpcshell.ini', u'dom/indexedDB/test/unit/xpcshell-child-process.ini', u'dom/notification/test/unit/xpcshell.ini', u'dom/quota/test/unit/telemetry/xpcshell.ini', u'dom/quota/test/unit/upgrades/xpcshell.ini', u'dom/quota/test/unit/xpcshell.ini', u'extensions/pref/autoconfig/test/unit/xpcshell.ini', u'image/test/unit/xpcshell.ini', u'intl/strres/tests/unit/xpcshell.ini', u'js/ductwork/debugger/tests/xpcshell.ini', u'modules/libmar/tests/unit/xpcshell.ini', u'modules/libpref/test/unit/xpcshell.ini', u'parser/xml/test/unit/xpcshell.ini', u'remote/test/unit/xpcshell.ini', u'security/manager/ssl/tests/unit/xpcshell.ini', u'services/settings/test/unit/xpcshell.ini', u'services/sync/tests/unit/xpcshell.ini', u'testing/marionette/test/unit/xpcshell.ini', u'testing/modules/tests/xpcshell/xpcshell.ini', u'toolkit/components/captivedetect/test/unit/xpcshell.ini', u'toolkit/components/cloudstorage/tests/unit/xpcshell.ini', u'toolkit/components/commandlines/test/unit_win/xpcshell.ini', u'toolkit/components/crashmonitor/test/unit/xpcshell.ini', u'toolkit/components/enterprisepolicies/tests/xpcshell/xpcshell.ini', u'toolkit/components/mediasniffer/test/unit/xpcshell.ini', u'toolkit/components/places/tests/expiration/xpcshell.ini', u'toolkit/components/places/tests/legacy/xpcshell.ini', u'toolkit/components/places/tests/queries/xpcshell.ini', u'toolkit/components/places/tests/unit/xpcshell.ini', u'toolkit/components/satchel/test/unit/xpcshell.ini', u'toolkit/components/search/tests/xpcshell/searchconfigs/xpcshell-3.ini', u'toolkit/components/search/tests/xpcshell/xpcshell.ini', u'toolkit/components/telemetry/tests/unit/xpcshell.ini', u'toolkit/components/url-classifier/tests/unit/xpcshell.ini', u'toolkit/components/utils/test/unit/xpcshell.ini', u'toolkit/crashreporter/test/unit/xpcshell-phc.ini', u'toolkit/crashreporter/test/unit_ipc/xpcshell.ini', u'toolkit/modules/tests/xpcshell/xpcshell.ini', u'toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/xpcshell.ini', u'toolkit/mozapps/update/tests/unit_aus_update/xpcshell.ini', u'toolkit/profile/xpcshell/xpcshell.ini', u'tools/profiler/tests/xpcshell/xpcshell.ini', u'widget/tests/unit/xpcshell.ini', u'xpcom/tests/unit/xpcshell.ini'] in /builds/worker/workspace/build/tests/xpcshell
[task 2020-01-16T01:07:50.189Z] 01:07:50 INFO - Copy/paste: /builds/worker/workspace/build/venv/bin/python -u /builds/worker/workspace/build/tests/xpcshell/remotexpcshelltests.py --xre-path=/builds/worker/workspace/build/hostutils/host-utils-71.0a1.en-US.linux-x86_64 --testing-modules-dir=/builds/worker/workspace/build/tests/modules --apk=/builds/worker/workspace/build/geckoview-androidTest.apk --no-logfiles --symbols-path=https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/A_VibfEURTuG-n6dGqpkOw/artifacts/public/build/target.crashreporter-symbols.zip --manifest=tests/xpcshell.ini --log-raw=/builds/worker/workspace/build/blobber_upload_dir/xpcshell_raw.log --log-raw-level=info --log-errorsummary=/builds/worker/workspace/build/blobber_upload_dir/xpcshell_errorsummary.log --log-tbpl-level=info --test-plugin-path=none --deviceSerial=emulator-5554 --setpref=media.peerconnection.mtransport_process=false --setpref=network.process.enabled=false browser/components/aboutlogins/tests/unit/xpcshell.ini browser/components/migration/tests/unit/xpcshell.ini browser/components/search/test/unit/xpcshell.ini browser/components/syncedtabs/test/xpcshell/xpcshell.ini browser/components/urlbar/tests/unit/xpcshell.ini browser/modules/test/unit/xpcshell.ini devtools/client/aboutdebugging/test/unit/xpcshell.ini devtools/client/inspector/changes/test/unit/xpcshell.ini devtools/client/memory/test/unit/xpcshell.ini devtools/client/performance/test/unit/xpcshell.ini devtools/client/shared/remote-debugging/test/unit/xpcshell.ini devtools/platform/tests/unit/xpcshell.ini devtools/shared/adb/test/xpcshell.ini devtools/shared/performance/test/xpcshell.ini devtools/shared/security/tests/unit/xpcshell.ini devtools/shared/transport/tests/unit/xpcshell.ini docshell/test/unit/xpcshell.ini dom/abort/tests/unit/xpcshell.ini dom/base/test/unit_ipc/xpcshell.ini dom/indexedDB/test/unit/xpcshell-child-process.ini dom/notification/test/unit/xpcshell.ini dom/quota/test/unit/telemetry/xpcshell.ini dom/quota/test/unit/upgrades/xpcshell.ini dom/quota/test/unit/xpcshell.ini extensions/pref/autoconfig/test/unit/xpcshell.ini image/test/unit/xpcshell.ini intl/strres/tests/unit/xpcshell.ini js/ductwork/debugger/tests/xpcshell.ini modules/libmar/tests/unit/xpcshell.ini modules/libpref/test/unit/xpcshell.ini parser/xml/test/unit/xpcshell.ini remote/test/unit/xpcshell.ini security/manager/ssl/tests/unit/xpcshell.ini services/settings/test/unit/xpcshell.ini services/sync/tests/unit/xpcshell.ini testing/marionette/test/unit/xpcshell.ini testing/modules/tests/xpcshell/xpcshell.ini toolkit/components/captivedetect/test/unit/xpcshell.ini toolkit/components/cloudstorage/tests/unit/xpcshell.ini toolkit/components/commandlines/test/unit_win/xpcshell.ini toolkit/components/crashmonitor/test/unit/xpcshell.ini toolkit/components/enterprisepolicies/tests/xpcshell/xpcshell.ini toolkit/components/mediasniffer/test/unit/xpcshell.ini toolkit/components/places/tests/expiration/xpcshell.ini toolkit/components/places/tests/legacy/xpcshell.ini toolkit/components/places/tests/queries/xpcshell.ini toolkit/components/places/tests/unit/xpcshell.ini toolkit/components/satchel/test/unit/xpcshell.ini toolkit/components/search/tests/xpcshell/searchconfigs/xpcshell-3.ini toolkit/components/search/tests/xpcshell/xpcshell.ini toolkit/components/telemetry/tests/unit/xpcshell.ini toolkit/components/url-classifier/tests/unit/xpcshell.ini toolkit/components/utils/test/unit/xpcshell.ini toolkit/crashreporter/test/unit/xpcshell-phc.ini toolkit/crashreporter/test/unit_ipc/xpcshell.ini toolkit/modules/tests/xpcshell/xpcshell.ini toolkit/mozapps/extensions/test/xpcshell/xml-blocklist/xpcshell.ini toolkit/mozapps/update/tests/unit_aus_update/xpcshell.ini toolkit/profile/xpcshell/xpcshell.ini tools/profiler/tests/xpcshell/xpcshell.ini widget/tests/unit/xpcshell.ini xpcom/tests/unit/xpcshell.ini
[task 2020-01-16T01:07:50.189Z] 01:07:50 INFO - Using env: (same as previous command)
[task 2020-01-16T01:07:50.458Z] 01:07:50 INFO - Traceback (most recent call last):
[task 2020-01-16T01:07:50.458Z] 01:07:50 INFO - File "/builds/worker/workspace/build/tests/xpcshell/remotexpcshelltests.py", line 15, in <module>
[task 2020-01-16T01:07:50.458Z] 01:07:50 INFO - import runxpcshelltests as xpcshell
[task 2020-01-16T01:07:50.458Z] 01:07:50 INFO - File "/builds/worker/workspace/build/tests/xpcshell/runxpcshelltests.py", line 83, in <module>
[task 2020-01-16T01:07:50.458Z] 01:07:50 INFO - from mozbuild.util import ensure_subprocess_env
[task 2020-01-16T01:07:50.458Z] 01:07:50 INFO - ImportError: No module named mozbuild.util
[task 2020-01-16T01:07:50.476Z] 01:07:50 ERROR - Return code: 1
[task 2020-01-16T01:07:50.477Z] 01:07:50 ERROR - No tests run or test summary not found
[task 2020-01-16T01:07:50.477Z] 01:07:50 INFO - TinderboxPrint: xpcshell<br/><em class="testfail">T-FAIL</em>
[task 2020-01-16T01:07:50.477Z] 01:07:50 INFO - ##### xpcshell log ends
[task 2020-01-16T01:07:50.477Z] 01:07:50 WARNING - # TBPL WARNING #

Flags: needinfo?(dtownsend)

I think this is a dupe of bug 1608091 where I fixed this with a different way.

Flags: needinfo?(dtownsend)

There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:mossop, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(dtownsend)
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Flags: needinfo?(dtownsend)
Resolution: --- → DUPLICATE
Attachment #9121166 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: