Example for reproducible segfault

273 views
Skip to first unread message

brian d

unread,
Aug 24, 2011, 5:25:46 PM8/24/11
to pymssql
Hello,
If this is not the proper avenue for reporting what may be a bug, or
if this the result of an illogical use of pymssql on my part, please
let me know. The following code is the smallest snippet that
illustrates the problem.

import threading
import datetime
import time

import pymssql


class ThreadClass(threading.Thread):
def run(self):
now = datetime.datetime.now()
print "%s connecting at time: %s" % (self.getName(), now)
conn = pymssql.connect(host="10.255.255.1", database='blah',
user="blah", password="blah")


for i in range(2):
t = ThreadClass()
t.start()
time.sleep(2)

The expected behavior would be to receive two tracebacks, instead of
one traceback and a segfault as shown below. This is happening with
pymssql 1.0.2. I tried this in each of the 4 environments below, with
the same result in each.

python 2.7.1 (Ubuntu 11.04 64 bit)
python 2.6.5 (Ubuntu 10.04 64 bit)
python 2.6.4 (Gentoo 64 bit)
python 2.6.6 (Gentoo 32 bit)


=========OUTPUT BEGIN===========

Thread-1 connecting at time: 2011-08-24 15:57:13.239528
Thread-2 connecting at time: 2011-08-24 15:57:15.242436
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib64/python2.6/threading.py", line 525, in
__bootstrap_inner
self.run()
File "pymssql_test.py", line 13, in run
user="blah", password="blah")
File "/usr/lib64/python2.6/site-packages/pymssql.py", line 607, in
connect
raise OperationalError, e[0]
OperationalError: DB-Lib error message 20009, severity 9:
Server is unavailable or does not exist.


Segmentation fault (core dumped)

=========OUTPUT END===========

If you would like any other information please let me know, I'd be
happy to provide it.

Thanks,
Brian Davis

Andrzej Kukuła

unread,
Aug 25, 2011, 12:53:58 AM8/25/11
to pym...@googlegroups.com
On Wed, Aug 24, 2011 at 23:25, brian d <the.bria...@gmail.com> wrote:

> let me know.  The following code is the smallest snippet that
> illustrates the problem.

(...)


> for i in range(2):
>    t = ThreadClass()
>    t.start()
>    time.sleep(2)

Thanks Brian.

pymssql 1.0.2 doesn't play well with threads; the module cannot be
shared by different threads. You may try pymssql 1.9 builds, but 1.0.x
will not improve on that. It requires major redesign, which is done
for 2.0.

Regards,
Andrzej

Reply all
Reply to author
Forward
0 new messages