Hi,

2013/3/22 Vasily Evseenko <svpcom@gmail.com>
Hi,

There are some memory corruption while calling socket.gethostbyname_ex
from the thread while other thread executes JIT'ed code:
In such case socket.gethostbyname_ex returns random entries from
/etc/hosts instead of DNS lookup.

Please file a bug on https://bugs.pypy.org/
Some notes:
- it reproduces even without a JIT-enabled pypy
- PyPy uses gethostbyname() instead of gethostbyname_r()

 

------
import sys
import socket
import threading

domain = 'google.com'

def lookup(x):
    res = socket.gethostbyname_ex(x)
    if res[0] != 'google.com':
        print 'BUG: resolve %s -> %s' % (x, res)
        sys.stdout.flush()

def test():
    # do some JIT
    for i in xrange(1000000000):
        pass

for i in range(100):
    th = threading.Thread(target=lookup, args=[domain])
    th.start()

th = threading.Thread(target=test)
th.start()

print 'startup done'
------


Affected versions: PyPy 1.8, 1.9, 2.0b1 on Linux   (Fedora 16, Debian
GNU/Linux 6.0)
---
Python 2.7.3 (07e08e9c885ca67d89bcc304e45a32346daea2fa, Mar 19 2013,
07:39:19)
[PyPy 2.0.0-beta1 with GCC 4.4.5] on linux2

Python 2.7.3 (07e08e9c885ca67d89bcc304e45a32346daea2fa, Dec 18 2012,
05:33:54)
[PyPy 2.0.0-beta1 with GCC 4.6.3] on linux2

Python 2.7.2 (2346207d99463f299f09f3e151c9d5fa9158f71b, May 15 2012,
11:08:08)
[PyPy 1.8.0 with GCC 4.6.3] on linux2

Python 2.7.2 (341e1e3821fff77db3bb5cdb7a4851626298c44e, Oct 23 2012,
11:37:42)
[PyPy 1.9.0 with GCC 4.6.3] on linux2
---

Not affected: PyPy 2.0b1 on MacOSX
---
Python 2.7.3 (07e08e9c885ca67d89bcc304e45a32346daea2fa, Mar 19 2013,
07:52:27)
[PyPy 2.0.0-beta1] on darwin

Python 2.7.3 (7e4f0faa3d51, Nov 21 2012, 15:59:46)
[PyPy 2.0.0-beta1 with GCC 4.2.1] on darwin
---



_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev



--
Amaury Forgeot d'Arc