Closed
Bug 1434765
Opened 6 years ago
Closed 6 years ago
The preprocessor should reject #idef clauses with expressions
Categories
(Firefox Build System :: General, enhancement)
Firefox Build System
General
Tracking
(firefox60 fixed)
RESOLVED
FIXED
mozilla60
Tracking | Status | |
---|---|---|
firefox60 | --- | fixed |
People
(Reporter: past, Assigned: glandium)
References
Details
Attachments
(1 file, 1 obsolete file)
Bug 1434761 is a case where this came up and dumb copying and pasting could have made this bug proliferate. In bug 1432310 comment 13 glandium suggests we can do better.
Comment hidden (mozreview-request) |
Comment 2•6 years ago
|
||
mozreview-review |
Comment on attachment 8947328 [details] Bug 1434765 - Properly reject invalid variables in #if{,n}def. https://reviewboard.mozilla.org/r/217050/#review222890 ::: python/mozbuild/mozbuild/test/test_preprocessor.py:651 (Diff revision 1) > + with MockedOpen({'dummy': '#ifdef FOO BAR\nPASS\n#endif'}): > + with self.assertRaises(Preprocessor.Error) as e: > + self.pp.do_include('dummy') > + self.assertEqual(e.exception.key, 'INVALID_VAR') > + > + with MockedOpen({'dummy': '#ifndef FOO BAR\nPASS\n#endif'}): Bravo for writing tests, too. Do you want to include a test for `FOO == BAR`, which motivated this bug?
Attachment #8947328 -
Flags: review+
Updated•6 years ago
|
Attachment #8947328 -
Flags: review?(core-build-config-reviews) → review+
Updated•6 years ago
|
Assignee: nobody → mh+mozilla
Comment hidden (mozreview-request) |
Assignee | ||
Updated•6 years ago
|
Attachment #8947328 -
Flags: review?(core-build-config-reviews)
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Updated•6 years ago
|
Attachment #8947328 -
Flags: review?(core-build-config-reviews)
Assignee | ||
Comment 6•6 years ago
|
||
Bwarf, the printing tests that were not happening because of the malformed preprocessor clause are actually busted. They might have been busted since day one, but nobody knew.
Comment hidden (mozreview-request) |
Assignee | ||
Updated•6 years ago
|
Attachment #8947344 -
Attachment is obsolete: true
Attachment #8947344 -
Flags: review?(core-build-config-reviews)
Assignee | ||
Updated•6 years ago
|
Attachment #8947328 -
Flags: review?(core-build-config-reviews)
Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/d4582a286d6a Properly reject invalid variables in #if{,n}def. r=froydnj
Comment 9•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/d4582a286d6a
Status: NEW → RESOLVED
Closed: 6 years ago
status-firefox60:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
Comment 10•6 years ago
|
||
Backed out for breaking build of Catalan language pack due to altered output: https://hg.mozilla.org/mozilla-central/rev/bda9adefe73902685d6689a205e7114ae9df7f83 Push with broken Catalan Firefox for Android nightlies (desktop hasn't run yet): https://treeherder.mozilla.org/#/jobs?repo=mozilla-central&revision=a23212941fcd1d8ecc2862cc139dfcbb7f029aa2&filter-resultStatus=testfailed&filter-resultStatus=busted&filter-resultStatus=exception&filter-resultStatus=retry&filter-resultStatus=usercancel&filter-resultStatus=runnable Build log: https://treeherder.mozilla.org/logviewer.html#?job_id=159919431&repo=mozilla-central [task 2018-02-01T19:13:04.490Z] 19:13:04 INFO - make[1]: Entering directory '/builds/worker/workspace/build/src/obj-firefox/mobile/android/locales' [task 2018-02-01T19:13:04.491Z] 19:13:04 INFO - /builds/worker/workspace/build/src/obj-firefox/_virtualenv/bin/python /builds/worker/workspace/build/src/config/nsinstall.py -D ../../../dist/android-arm/xpi/ [task 2018-02-01T19:13:04.526Z] 19:13:04 INFO - /builds/worker/workspace/build/src/obj-firefox/_virtualenv/bin/python -m mozbuild.action.langpack_manifest --locales ca --min-app-ver 60.0a1 --max-app-ver 60.0a1 --app-name "Firefox Nightly" --l10n-basedir "/builds/worker/workspace/build/l10n-central" --defines /builds/worker/workspace/build/l10n-central/ca/toolkit/defines.inc /builds/worker/workspace/build/l10n-central/ca/mobile/android/defines.inc --input ../../../dist/xpi-stage/locale-ca [task 2018-02-01T19:13:04.962Z] 19:13:04 ERROR - Traceback (most recent call last): [task 2018-02-01T19:13:04.963Z] 19:13:04 INFO - File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main [task 2018-02-01T19:13:04.969Z] 19:13:04 INFO - "__main__", fname, loader, pkg_name) [task 2018-02-01T19:13:04.970Z] 19:13:04 INFO - File "/usr/lib/python2.7/runpy.py", line 72, in _run_code [task 2018-02-01T19:13:04.970Z] 19:13:04 INFO - exec code in run_globals [task 2018-02-01T19:13:04.970Z] 19:13:04 INFO - File "/builds/worker/workspace/build/src/python/mozbuild/mozbuild/action/langpack_manifest.py", line 450, in <module> [task 2018-02-01T19:13:04.970Z] 19:13:04 INFO - main(sys.argv[1:]) [task 2018-02-01T19:13:04.970Z] 19:13:04 INFO - File "/builds/worker/workspace/build/src/python/mozbuild/mozbuild/action/langpack_manifest.py", line 444, in main [task 2018-02-01T19:13:04.971Z] 19:13:04 INFO - chrome_entries [task 2018-02-01T19:13:04.971Z] 19:13:04 INFO - File "/builds/worker/workspace/build/src/python/mozbuild/mozbuild/action/langpack_manifest.py", line 409, in create_webmanifest [task 2018-02-01T19:13:04.971Z] 19:13:04 INFO - return json.dumps(manifest, indent=2, ensure_ascii=False, encoding='utf8') [task 2018-02-01T19:13:04.971Z] 19:13:04 INFO - File "/usr/lib/python2.7/json/__init__.py", line 251, in dumps [task 2018-02-01T19:13:04.971Z] 19:13:04 INFO - sort_keys=sort_keys, **kw).encode(obj) [task 2018-02-01T19:13:04.972Z] 19:13:04 INFO - File "/usr/lib/python2.7/json/encoder.py", line 209, in encode [task 2018-02-01T19:13:04.972Z] 19:13:04 INFO - chunks = list(chunks) [task 2018-02-01T19:13:04.972Z] 19:13:04 INFO - File "/usr/lib/python2.7/json/encoder.py", line 434, in _iterencode [task 2018-02-01T19:13:04.972Z] 19:13:04 INFO - for chunk in _iterencode_dict(o, _current_indent_level): [task 2018-02-01T19:13:04.972Z] 19:13:04 INFO - File "/usr/lib/python2.7/json/encoder.py", line 390, in _iterencode_dict [task 2018-02-01T19:13:04.973Z] 19:13:04 INFO - yield _encoder(value) [task 2018-02-01T19:13:04.973Z] 19:13:04 INFO - File "/usr/lib/python2.7/json/encoder.py", line 233, in _encoder [task 2018-02-01T19:13:04.973Z] 19:13:04 INFO - o = o.decode(_encoding) [task 2018-02-01T19:13:04.973Z] 19:13:04 INFO - File "/builds/worker/workspace/build/src/obj-firefox/_virtualenv/lib/python2.7/encodings/utf_8.py", line 16, in decode [task 2018-02-01T19:13:04.973Z] 19:13:04 INFO - return codecs.utf_8_decode(input, errors, True) [task 2018-02-01T19:13:04.973Z] 19:13:04 INFO - UnicodeDecodeError: 'utf8' codec can't decode byte 0xc3 in position 5: invalid continuation byte gandalf found the difference: without the patch pp.context is: {'MOZ_LANGPACK_CONTRIBUTORS': '<em:contributor>Softcatal\xc3\xa0</em:contributor>', 'MOZ_LANGPACK_CREATOR': 'Mozilla.org / Softcatal\xc3\xa0', 'MOZ_LANG_TITLE': 'Catal\xc3\xa0', 'FILE': '', 'DIRECTORY': '/home/zbraniecki/projects/mozilla-unified/obj-x86_64-pc-linux-gnu-opt/browser/locales', 'LINE': 0} with: {'MOZ_LANGPACK_CONTRIBUTORS': '<em:contributor>Softcatal\xc3\xa0</em:contributor>', 'MOZ_LANGPACK_CREATOR': 'Mozilla.org / Softcatal\xc3', 'MOZ_LANG_TITLE': 'Catal\xc3', 'FILE': '', 'DIRECTORY': '/home/zbraniecki/projects/mozilla-unified/obj-x86_64-pc-linux-gnu-opt/browser/locales', 'LINE': 0}
Status: RESOLVED → REOPENED
status-firefox60:
fixed → ---
Flags: needinfo?(mh+mozilla)
Resolution: FIXED → ---
Target Milestone: mozilla60 → ---
Assignee | ||
Comment 11•6 years ago
|
||
So here's why this is happening: That defines.inc contains: #define MOZ_LANGPACK_CREATOR mozilla.org / Softcatalà That à, is encoded as 0xc3 0xa0. Guess what 0xa0 is in iso-8859-1? . So the \s* that strips whitespaces removes it... The core problem is that lines are being treated as strs, not unicodes. There may be legitimate cases for supporting preprocessing raw bytes, but it seems we should at least try to use unicode when the input is valid utf-8.
Flags: needinfo?(mh+mozilla)
Assignee | ||
Comment 12•6 years ago
|
||
However, this happens to be a rabbit hole. Many things in the preprocessor are coercing values to str. Making it unicode aware seems like much more work than I'm ready to put at the moment. I think a reasonable way out here is to get rid of re.U.
Comment hidden (mozreview-request) |
Assignee | ||
Comment 14•6 years ago
|
||
Filed bug 1435087
Comment 15•6 years ago
|
||
mozreview-review |
Comment on attachment 8947328 [details] Bug 1434765 - Properly reject invalid variables in #if{,n}def. https://reviewboard.mozilla.org/r/217050/#review224382 Let's try again! Yay, Catalan!
Attachment #8947328 -
Flags: review+
Comment 16•6 years ago
|
||
mozreview-review |
Comment on attachment 8947328 [details] Bug 1434765 - Properly reject invalid variables in #if{,n}def. https://reviewboard.mozilla.org/r/217050/#review224384
Updated•6 years ago
|
Attachment #8947328 -
Flags: review?(core-build-config-reviews)
Comment 17•6 years ago
|
||
Pushed by mh@glandium.org: https://hg.mozilla.org/integration/autoland/rev/fd087947d886 Properly reject invalid variables in #if{,n}def. r=froydnj,nalexander
Comment 18•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/fd087947d886
Status: REOPENED → RESOLVED
Closed: 6 years ago → 6 years ago
status-firefox60:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
Updated•6 years ago
|
Product: Core → Firefox Build System
You need to log in
before you can comment on or make changes to this bug.
Description
•