ArkaneMoose/BotBot

Invalid regexes lead to crashes

Closed this issue · 0 comments

If a botling is created with an certain type of invalid regular expression (^*$ was observed), it enters a bad state that renders it nonfunctional (thus making removal impossible (at least via the widely-known means)), and prevents shutdown of the entire BotBot.
Scrubbed stacktraces attached.

Stacktrace 1: Botling crashing

Exception in thread Thread-XXX:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "$EUPY/euphoria/room.py", line 120, in run
    if self.connection.receive_data():
  File "$EUPY/euphoria/connection.py", line 142, in receive_data
    self.handle_packet(json.loads(raw))
  File "$EUPY/euphoria/connection.py", line 186, in handle_packet
    i(packet)
  File "$EUPY/euphoria/chat_room.py", line 22, in handle_message
    self.handle_chat(message["data"])
  File "$BOTBOT/botbot/botbotbot.py", line 72, in handle_chat
    self.recv_message(message['content'], message['parent'], message['id'], message['sender']['name'], message['sender']['id'], message['time'], self.room_name)
  File "$BOTBOT/botbot/botbotbot.py", line 171, in recv_message
    for message in messages:
  File "$BOTBOT/botbot/botparser.py", line 71, in get_messages
    regex = re.compile(regex_string, re.IGNORECASE)
  File "/usr/lib/python3.4/re.py", line 223, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.4/re.py", line 294, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.4/sre_compile.py", line 568, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.4/sre_parse.py", line 760, in parse
    p = _parse_sub(source, pattern, 0)
  File "/usr/lib/python3.4/sre_parse.py", line 370, in _parse_sub
    itemsappend(_parse(source, state))
  File "/usr/lib/python3.4/sre_parse.py", line 579, in _parse
    raise error("nothing to repeat")
sre_constants.error: nothing to repeat

Stacktrace 2: BotBot not shutting down

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "$EUPY/euphoria/execgroup.py", line 50, in run
    self.execs[i].thread.join()
  File "/usr/lib/python3.4/threading.py", line 1055, in join
    raise RuntimeError("cannot join thread before it is started")
RuntimeError: cannot join thread before it is started