Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGSEV and callback errors #48

Open
nicko2n opened this issue Oct 25, 2016 · 0 comments
Open

SIGSEV and callback errors #48

nicko2n opened this issue Oct 25, 2016 · 0 comments

Comments

@nicko2n
Copy link
Contributor

nicko2n commented Oct 25, 2016

Hi,

I noticed a few random crashes of the Python interpreter while using the GetDNS Python bindings. I've been able to reproduce the problem in Python 2.7 and 3.5 but with a different error.

I am using the latest library (c84ff93) and Python bindings (98f635f) on Ubuntu 14.04.

The issue happens infrequently while performing 'normal' lookups but I've been able to trigger it reliably with the attached script, which resolves 199.181.132.250 multiple times asynchronously. The odd bit about this IP is the number of PTR entries (500+), which might be triggering a race condition.

The crash doesn't happen every time - typically every other time.

1 Normal run, using 8.8.4.4 as the IP being resolved:
2016-10-25 21:18:02,312 INFO: submitting ip query: 8.8.4.4
2016-10-25 21:18:02,313 INFO: submitting ip query: 8.8.4.4
2016-10-25 21:18:02,313 INFO: submitting ip query: 8.8.4.4
2016-10-25 21:18:02,313 INFO: submitting ip query: 8.8.4.4
2016-10-25 21:18:02,319 INFO: callback 8.8.4.4:900
2016-10-25 21:18:02,344 INFO: callback 8.8.4.4:900
2016-10-25 21:18:02,346 INFO: callback 8.8.4.4:900
2016-10-25 21:18:02,347 INFO: callback 8.8.4.4:900
2016-10-25 21:18:02,348 INFO: Done

2 Python 2.7
2016-10-25 20:56:30,968 INFO: submitting ip query: 199.181.132.250
2016-10-25 20:56:30,968 INFO: submitting ip query: 199.181.132.250
2016-10-25 20:56:30,968 INFO: submitting ip query: 199.181.132.250
2016-10-25 20:56:30,969 INFO: submitting ip query: 199.181.132.250
2016-10-25 20:56:31,182 INFO: callback 199.181.132.250:900
2016-10-25 20:56:31,195 INFO: callback 199.181.132.250:900
/usr/lib/python2.7/threading.py:1160: RuntimeWarning: tp_compare didn't return -1 or -2 for exception
return _active[_get_ident()]
Traceback (most recent call last):
File "/srv/async.py", line 62, in
main()
File "/srv/async.py", line 58, in main
ASYNC_RESOLVER.resolve()
File "/srv/async.py", line 52, in resolve
logging.info('Done')
File "/usr/lib/python2.7/logging/init.py", line 1614, in info
root.info(msg, _args, *_kwargs)
File "/usr/lib/python2.7/logging/init.py", line 1152, in info
self._log(INFO, msg, args, **kwargs)
File "/usr/lib/python2.7/logging/init.py", line 1270, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/usr/lib/python2.7/logging/init.py", line 1244, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
File "/usr/lib/python2.7/logging/init.py", line 284, in init
self.threadName = threading.current_thread().name
File "/usr/lib/python2.7/threading.py", line 1160, in currentThread
return _active[_get_ident()]
TypeError: callback() takes exactly 4 arguments (1 given)

3 Python 3.5
(ven35)root@developmentsrv:/srv/getdns-python-bindings# python /srv/async.py
2016-10-25 20:18:47,036 INFO: submitting ip query: 199.181.132.250
2016-10-25 20:18:47,037 INFO: submitting ip query: 199.181.132.250
2016-10-25 20:18:47,037 INFO: submitting ip query: 199.181.132.250
2016-10-25 20:18:47,037 INFO: submitting ip query: 199.181.132.250
2016-10-25 20:18:47,079 INFO: callback 199.181.132.250:900
2016-10-25 20:18:47,260 INFO: callback 199.181.132.250:900
2016-10-25 20:18:47,274 INFO: callback 199.181.132.250:900
TypeError: callback() missing 3 required positional arguments: 'result', 'userarg', and 'tid'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/srv/async.py", line 94, in
main()
File "/srv/async.py", line 90, in main
ASYNC_RESOLVER.resolve()
File "/srv/async.py", line 83, in resolve
self.ctx.run()
SystemError: <built-in method run of getdns.Context object at 0x7f8e77abc918> returned a result with an error set

4 Python 3.5 - self and result_dict are 0x0 in the stack trace
2016-10-25 21:13:39,821 INFO: submitting ip query: 199.181.132.250
2016-10-25 21:13:39,822 INFO: submitting ip query: 199.181.132.250
2016-10-25 21:13:39,822 INFO: submitting ip query: 199.181.132.250
2016-10-25 21:13:39,822 INFO: submitting ip query: 199.181.132.250
2016-10-25 21:13:39,958 INFO: callback 199.181.132.250:900
2016-10-25 21:13:39,976 INFO: callback 199.181.132.250:900
Segmentation fault (core dumped)

$ gdb python3.5 core
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f40f33b4127 in result_init (self=self@entry=0x0, result_dict=result_dict@entry=0x0) at result.c:50

50 if ((self->replies_full = gdict_to_pdict(result_dict)) == NULL) {
(gdb) where
#0 0x00007f40f33b4127 in result_init (self=self@entry=0x0, result_dict=result_dict@entry=0x0) at result.c:50
#1 0x00007f40f33b43f5 in result_create (resp=resp@entry=0x0) at result.c:196
#2 0x00007f40f33b406a in callback_shim (context=context@entry=0x217f920, type=type@entry=GETDNS_CALLBACK_ERROR, response=response@entry=0x0, userarg=userarg@entry=0x21a0db0, tid=tid@entry=18043064835844998925) at context_util.c:96
#3 0x00007f40f316bd05 in _getdns_call_user_callback (dns_req=0x21a2dc0, response=0x0) at ./general.c:77
#4 0x00007f40f317655b in upstream_erred (upstream=) at ./stub.c:535
#5 upstream_read_cb (userarg=0x2191db8) at ./stub.c:1430
#6 0x00007f40f3181eff in default_read_cb (fd=7, event=, event=) at ./extension/default_eventloop.c:160
#7 default_eventloop_run_once (loop=loop@entry=0x2180aa8, blocking=blocking@entry=1) at ./extension/default_eventloop.c:235
#8 0x00007f40f3181fad in default_eventloop_run (loop=0x2180aa8) at ./extension/default_eventloop.c:267
#9 0x00007f40f33b31a2 in context_run (self=, args=, keywds=) at context.c:1284
#10 0x0000000000498dc9 in PyCFunction_Call ()
#11 0x000000000054e64c in PyEval_EvalFrameEx ()
#12 0x000000000054e3a3 in PyEval_EvalFrameEx ()
#13 0x000000000054e3a3 in PyEval_EvalFrameEx ()
#14 0x00000000005461de in ?? ()
#15 0x000000000054e96d in PyEval_EvalCode ()
#16 0x000000000042c384 in ?? ()
#17 0x000000000059d95d in PyRun_FileExFlags ()
#18 0x000000000059db0d in PyRun_SimpleFileExFlags ()
#19 0x00000000005a0c2b in Py_Main ()
#20 0x000000000041fa5f in main ()

Script:
async.py.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant