buildd-manager crashes on ASCII NUL in build logtail

Bug #1831500 reported by Colin Watson on 2019-06-03
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
High
Colin Watson

Bug Description

If a build emits ASCII NUL to its log, then buildd-manager fails the build with this traceback in the log:

Traceback (most recent call last):
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1442, in gotRes

    _inlineCallbacks(r, g, deferred)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1386, in _inlin

    result = g.send(result)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/lib/lp/buildmaster/manager.py", line 486, in scan
    self.behaviour_factory)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1532, in unwind

    return _inlineCallbacks(None, gen, Deferred())
--- <exception caught here> ---
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1386, in _inlin

    result = g.send(result)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/lib/lp/buildmaster/interactor.py", line 549, in updateBuild
    vitals.build_queue.specific_build.updateStatus(
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/lib/lp/services/propertycache.py", line 115, in __get__
    value = self.populate(instance)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/lib/lp/buildmaster/model/buildqueue.py", line 114, in specific_build
    bfj = self._build_farm_job
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/storm/references.py", line 157, in __get__
    self._relation.get_local_variables(local))
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/storm/store.py", line 170, in get
    self.flush()
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/storm/store.py", line 521, in flush
    self._flush_one(obj_info)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/storm/store.py", line 578, in _flush_one
    self._connection.execute(expr, noresult=True)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/storm/databases/postgres.py", line 306, in execu

    return Connection.execute(self, statement, params, noresult)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/storm/database.py", line 241, in execute
    raw_cursor = self.raw_execute(statement, params)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/storm/databases/postgres.py", line 316, in raw_execute
    return Connection.raw_execute(self, statement, params)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/storm/database.py", line 372, in raw_execute
    self._prepare_execution(raw_cursor, params, statement)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/storm/database.py", line 404, in _prepare_execution
    statement, params or ())
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/storm/database.py", line 454, in _check_disconnect
    return function(*args, **kwargs)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/env/local/lib/python2.7/site-packages/storm/tracer.py", line 248, in trace
    attr(*args, **kwargs)
  File "/srv/launchpad.net/codelines/soyuz-production-rev-18968/lib/lp/services/webapp/adapter.py", line 684, in connection_raw_execute
    statement, tuple(connection.to_database(params)))
exceptions.ValueError: A string literal cannot contain NUL (0x00) characters.

As far as I know, PostgreSQL's text type can't hold NUL bytes at all, so this isn't just a question of different escaping. We could migrate buildqueue.logtail to be a binary type instead, but its sole purpose is to be rendered in the web UI so I don't think there's much point in doing that. We should perhaps just remove NUL bytes before storing them instead.

Related branches

Colin Watson (cjwatson) on 2019-06-04
Changed in launchpad:
status: Triaged → In Progress
assignee: nobody → Colin Watson (cjwatson)
Launchpad QA Bot (lpqabot) wrote :
tags: added: qa-needstesting
Changed in launchpad:
status: In Progress → Fix Committed
Colin Watson (cjwatson) on 2019-06-04
tags: added: qa-ok
removed: qa-needstesting
Colin Watson (cjwatson) on 2019-06-05
Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers