Bug 1230 - pythonmod crashed when running repeatly unbound-control reload
pythonmod crashed when running repeatly unbound-control reload
Status: RESOLVED FIXED
Product: unbound
Classification: Unclassified
Component: server
1.6.1
x86_64 Linux
: P5 critical
Assigned To: unbound team
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-03-06 03:54 CET by Yunwei Dai
Modified: 2017-03-07 11:42 CET (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yunwei Dai 2017-03-06 03:54:24 CET
Please forgive me for my pool english. I've got "Program received signal SIGSEGV, Segmentation fault." error when execute unbound-control reload command twice. here is my enviroment:

OS: CentOS release 6.6 (Final)
Python: Python 2.6.6
unbound configure params: ./configure --enable-debug --with-pythonmodule
log.py: unbound-1.6.1\pythonmod\examples\log.py. (source code comes from unbound-1.6.1.tar.gz )
--------------------------------------------------
test-log.conf:
# Example configuration file for log.py
server:
	verbosity: 1
	interface: 0.0.0.0
	do-daemonize: no
	access-control: 0.0.0.0/0 allow
	chroot: ""
	username: ""
	directory: ""
	logfile: ""
	pidfile: "unbound.pid"
	module-config: "validator python iterator"

# Python config section
python:
	# Script file to load
	python-script: "./examples/log.py"

remote-control:
    control-enable: yes
    control-use-cert: no
-------------------------------------------------------

then i use gdb /usr/local/sbin/unbound and got the following message:
---------------------------------------------------------
(gdb) r -d -c ./test-log.conf 
Starting program: /usr/local/sbin/unbound -d -c ./test-log.conf
[Thread debugging using libthread_db enabled]
[1488768108] unbound[30098:0] warning: did not exit gracefully last time (20081)
[1488768108] unbound[30098:0] notice: init module 0: validator
[1488768108] unbound[30098:0] notice: init module 1: python
[1488768108] unbound[30098:0] info: pythonmod: init called, module id is 1 port: 53 script: ./examples/log.py
[1488768108] unbound[30098:0] notice: init module 2: iterator
[1488768108] unbound[30098:0] info: start of service (unbound 1.6.1).


[1488768110] unbound[30098:0] info: service stopped (unbound 1.6.1).
[1488768110] unbound[30098:0] info: server stats for thread 0: 0 queries, 0 answers from cache, 0 recursions, 0 prefetch, 0 rejected by ip ratelimiting
[1488768110] unbound[30098:0] info: server stats for thread 0: requestlist max 0 avg 0 exceeded 0 jostled 0
[1488768110] unbound[30098:0] notice: Restart of unbound 1.6.1.
[1488768110] unbound[30098:0] info: pythonmod: deinit called, module id is 1
[1488768110] unbound[30098:0] notice: init module 0: validator
[1488768110] unbound[30098:0] notice: init module 1: python
[1488768110] unbound[30098:0] info: pythonmod: init called, module id is 1 port: 53 script: ./examples/log.py
[1488768110] unbound[30098:0] notice: init module 2: iterator
[1488768110] unbound[30098:0] info: start of service (unbound 1.6.1).



[1488768112] unbound[30098:0] info: service stopped (unbound 1.6.1).
[1488768112] unbound[30098:0] info: server stats for thread 0: 0 queries, 0 answers from cache, 0 recursions, 0 prefetch, 0 rejected by ip ratelimiting
[1488768112] unbound[30098:0] info: server stats for thread 0: requestlist max 0 avg 0 exceeded 0 jostled 0
[1488768112] unbound[30098:0] notice: Restart of unbound 1.6.1.
[1488768112] unbound[30098:0] info: pythonmod: deinit called, module id is 1
[1488768112] unbound[30098:0] notice: init module 0: validator
[1488768112] unbound[30098:0] notice: init module 1: python

Program received signal SIGSEGV, Segmentation fault.
0x00000037f1a80026 in PyObject_Malloc () from /usr/lib64/libpython2.6.so.1.0
Missing separate debuginfos, use: debuginfo-install keyutils-libs-1.4-5.el6.x86_64 krb5-libs-1.10.3-42.el6.x86_64 libcom_err-1.41.12-22.el6.x86_64 libselinux-2.0.94-5.8.el6.x86_64 openssl-1.0.1e-48.el6_8.4.x86_64 python-libs-2.6.6-66.el6_8.x86_64 zlib-1.2.3-29.el6.x86_64
--------------------------------------------------------------------

the below is bracktrace:
---------------------------------------------------------------------
(gdb) bt
#0  0x00000037f1a80026 in PyObject_Malloc () from /usr/lib64/libpython2.6.so.1.0
#1  0x00000037f1a7fd1d in _PyObject_New () from /usr/lib64/libpython2.6.so.1.0
#2  0x00000037f1aa2746 in ?? () from /usr/lib64/libpython2.6.so.1.0
#3  0x00000037f1aaa5e7 in PyUnicodeUCS4_DecodeUTF8Stateful () from /usr/lib64/libpython2.6.so.1.0
#4  0x00000037f1aeb81b in ?? () from /usr/lib64/libpython2.6.so.1.0
#5  0x00000037f1aeb35d in ?? () from /usr/lib64/libpython2.6.so.1.0
#6  0x00000037f1aeb35d in ?? () from /usr/lib64/libpython2.6.so.1.0
#7  0x00000037f1aeb51c in ?? () from /usr/lib64/libpython2.6.so.1.0
#8  0x00000037f1aeb35d in ?? () from /usr/lib64/libpython2.6.so.1.0
#9  0x00000037f1aeb51c in ?? () from /usr/lib64/libpython2.6.so.1.0
#10 0x00000037f1aebc58 in PyMarshal_ReadObjectFromString () from /usr/lib64/libpython2.6.so.1.0
#11 0x00000037f1aed626 in PyMarshal_ReadLastObjectFromFile () from /usr/lib64/libpython2.6.so.1.0
#12 0x00000037f1ae57a9 in ?? () from /usr/lib64/libpython2.6.so.1.0
#13 0x00000037f1ae72ad in ?? () from /usr/lib64/libpython2.6.so.1.0
#14 0x00000037f1ae8895 in ?? () from /usr/lib64/libpython2.6.so.1.0
#15 0x00000037f1ae8b14 in ?? () from /usr/lib64/libpython2.6.so.1.0
#16 0x00000037f1ae916d in ?? () from /usr/lib64/libpython2.6.so.1.0
#17 0x00000037f1ae9ed4 in PyImport_ImportModuleLevel () from /usr/lib64/libpython2.6.so.1.0
#18 0x00000037f1acf70f in ?? () from /usr/lib64/libpython2.6.so.1.0
#19 0x00000037f1a43c63 in PyObject_Call () from /usr/lib64/libpython2.6.so.1.0
#20 0x00000037f1acfc83 in PyEval_CallObjectWithKeywords () from /usr/lib64/libpython2.6.so.1.0
#21 0x00000037f1ad332f in PyEval_EvalFrameEx () from /usr/lib64/libpython2.6.so.1.0
#22 0x00000037f1ad7647 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.6.so.1.0
#23 0x00000037f1ad7722 in PyEval_EvalCode () from /usr/lib64/libpython2.6.so.1.0
#24 0x00000037f1ae6ec2 in PyImport_ExecCodeModuleEx () from /usr/lib64/libpython2.6.so.1.0
#25 0x00000037f1ae73a6 in ?? () from /usr/lib64/libpython2.6.so.1.0
#26 0x00000037f1ae8895 in ?? () from /usr/lib64/libpython2.6.so.1.0
#27 0x00000037f1ae8b55 in ?? () from /usr/lib64/libpython2.6.so.1.0
#28 0x00000037f1ae916d in ?? () from /usr/lib64/libpython2.6.so.1.0
#29 0x00000037f1ae9ed4 in PyImport_ImportModuleLevel () from /usr/lib64/libpython2.6.so.1.0
#30 0x00000037f1acf70f in ?? () from /usr/lib64/libpython2.6.so.1.0
#31 0x00000037f1a43c63 in PyObject_Call () from /usr/lib64/libpython2.6.so.1.0
#32 0x00000037f1acfc83 in PyEval_CallObjectWithKeywords () from /usr/lib64/libpython2.6.so.1.0
#33 0x00000037f1ad332f in PyEval_EvalFrameEx () from /usr/lib64/libpython2.6.so.1.0
#34 0x00000037f1ad7647 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.6.so.1.0
#35 0x00000037f1ad7722 in PyEval_EvalCode () from /usr/lib64/libpython2.6.so.1.0
#36 0x00000037f1ae6ec2 in PyImport_ExecCodeModuleEx () from /usr/lib64/libpython2.6.so.1.0
#37 0x00000037f1ae73a6 in ?? () from /usr/lib64/libpython2.6.so.1.0
#38 0x00000037f1ae8895 in ?? () from /usr/lib64/libpython2.6.so.1.0
#39 0x00000037f1ae8b14 in ?? () from /usr/lib64/libpython2.6.so.1.0
#40 0x00000037f1ae91b0 in ?? () from /usr/lib64/libpython2.6.so.1.0
#41 0x00000037f1ae9ed4 in PyImport_ImportModuleLevel () from /usr/lib64/libpython2.6.so.1.0
#42 0x00000037f1acf70f in ?? () from /usr/lib64/libpython2.6.so.1.0
#43 0x00000037f1a43c63 in PyObject_Call () from /usr/lib64/libpython2.6.so.1.0
#44 0x00000037f1acfc83 in PyEval_CallObjectWithKeywords () from /usr/lib64/libpython2.6.so.1.0
#45 0x00000037f1ad332f in PyEval_EvalFrameEx () from /usr/lib64/libpython2.6.so.1.0
#46 0x00000037f1ad7647 in PyEval_EvalCodeEx () from /usr/lib64/libpython2.6.so.1.0
#47 0x00000037f1ad7722 in PyEval_EvalCode () from /usr/lib64/libpython2.6.so.1.0
#48 0x00000037f1af1b9c in ?? () from /usr/lib64/libpython2.6.so.1.0
#49 0x00000037f1af1daa in PyRun_StringFlags () from /usr/lib64/libpython2.6.so.1.0
#50 0x00000037f1af3010 in PyRun_SimpleStringFlags () from /usr/lib64/libpython2.6.so.1.0
#51 0x000000000048ecec in pythonmod_init (env=0x727960, id=1) at pythonmod/pythonmod.c:168
---Type <return> to continue, or q <return> to quit---
#52 0x00000000004395b9 in modstack_setup (stack=0x7090f0, module_conf=<value optimized out>, env=0x727960) at services/modstack.c:193
#53 0x000000000040d1ec in daemon_setup_modules (daemon=0x709010) at daemon/daemon.c:365
#54 daemon_fork (daemon=0x709010) at daemon/daemon.c:580
#55 0x0000000000414fdb in run_daemon (argc=<value optimized out>, argv=<value optimized out>) at daemon/unbound.c:643
#56 main (argc=<value optimized out>, argv=<value optimized out>) at daemon/unbound.c:735
(gdb) f 51
#51 0x000000000048ecec in pythonmod_init (env=0x727960, id=1) at pythonmod/pythonmod.c:168
168	   PyRun_SimpleString("import distutils.sysconfig \n");
(gdb) 
---------------------------------------------------------------------------

Could anyone help me on this?
Comment 1 George Thessalonikefs 2017-03-06 14:18:58 CET
Hello Yunwei,

We can reproduce the problem only when using Python 2.6.
According to https://www.python.org/download/releases/2.6.9/ support for Python 2.6 officially ended on October 2013.
You could update to Python 2.7 and let us know if you still get the error.

Best regards,
George
Comment 2 George Thessalonikefs 2017-03-06 17:12:47 CET
Hello Yunwei,

Although Python 2.6 is not supported any more, and I still advise to update, upon more testing it seems that the segmentation fault is caused by swig 1.3.
You haven't mentioned your swig version number but based on your system and your Python version I guess it is somewhere in the 1.3 release.

I tested with swig 1.3.40 (the last version of the 1.3 release), swig 2.0.0 and swig 3.0.12 (latest version).
From the three only swig 1.3.40 gave the segmentation fault.

Best regards,
George
Comment 3 Yunwei Dai 2017-03-07 04:07:55 CET
Hi George,

Thank you for your quick reply. You are right, i upgrade swig from 1.3.40 to 3.0.12, then pythonmod works well. 

Best regards, Yunwei
Comment 4 Wouter Wijngaards 2017-03-07 11:42:16 CET
Hi Yunwei, George,

I've fixed configure in unbound, it refuses swig 1.3.40, and requires swig 2.0.0 or higher to compile unbound.

Best regards, Wouter