saghul/aiodns

.onion pseudo TLD leads to segmentation fault

0x3c3e opened this issue · 3 comments

I have stumbled with an issue, pseudo .onion TLD leads to segmentation fault. Code is simple as:

import asyncio
import aiodns

loop = asyncio.get_event_loop()
resolver = aiodns.DNSResolver(loop=loop)

async def query(name, query_type):
    return await resolver.query(name, query_type)

coro = query('something.onion', 'NS') # actually any DNS record (e.g. A, CNAME, MX)
result = loop.run_until_complete(coro)

Let me know if it's expected behaviour.

A segmentation fault should never be expected behavior :-O Do you have a backtrace? I'll try to look into this soon.

Hi again @saghul, here it is:

  • test.py:
import asyncio
import aiodns
import faulthandler

faulthandler.enable()

loop = asyncio.get_event_loop()
resolver = aiodns.DNSResolver(loop=loop)

async def query(name, query_type):
    return await resolver.query(name, query_type)

coro = query('something.onion', 'NS') # actually any DNS record (e.g. A, CNAME, MX)
result = loop.run_until_complete(coro)
  • segmentation fault:
Fatal Python error: Segmentation fault

Current thread 0x{addr} (most recent call first):
  File "/home/{user}/.pyenv/versions/{env}/lib/python3.7/site-packages/pycares/__init__.py", line 519 in _do_query
  File "/home/{user}/.pyenv/versions/{env}/lib/python3.7/site-packages/pycares/__init__.py", line 505 in query
  File "/home/{user}/.pyenv/versions/{env}/lib/python3.7/site-packages/aiodns/__init__.py", line 79 in query
  File "test.py", line 11 in query
  File "/home/{user}/.pyenv/versions/3.7.4/lib/python3.7/asyncio/events.py", line 88 in _run
  File "/home/{user}/.pyenv/versions/3.7.4/lib/python3.7/asyncio/base_events.py", line 1771 in _run_once
  File "/home/{user}/.pyenv/versions/3.7.4/lib/python3.7/asyncio/base_events.py", line 534 in run_forever
  File "/home/{user}/.pyenv/versions/3.7.4/lib/python3.7/asyncio/base_events.py", line 566 in run_until_complete
  File "test.py", line 14 in <module>
Segmentation fault (core dumped)

This should fix it: saghul/pycares#101