This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Segmentation fault when importing hashlib
Type: crash Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: gregory.p.smith, nixdash, pitrou
Priority: normal Keywords:

Created on 2012-12-10 23:52 by nixdash, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg177317 - (view) Author: ashwani (nixdash) Date: 2012-12-10 23:52
Hello,

I did a local installation of python 3.3.0 on my organization's CentOS machine.
We also have Python 2.6.6 installed for every users on this machine.
Python 3.3.0 crashes when I import the hash lib.
Following is snapshot of the crash.


ir[63] [~/]$ python3  -X faulthandler
Python 3.3.0 (default, Dec  9 2012, 20:13:58) 
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
Fatal Python error: Segmentation fault

Current thread 0x00007f0362784700:
  File "/usa/arao/Python-3.3.0/lib/python3.3/hashlib.py", line 99 in __get_openssl_constructor
  File "/usa/arao/Python-3.3.0/lib/python3.3/hashlib.py", line 141 in <module>
  File "<frozen importlib._bootstrap>", line 313 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 869 in _load_module
  File "<frozen importlib._bootstrap>", line 562 in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 1004 in load_module
  File "<frozen importlib._bootstrap>", line 1023 in load_module
  File "<frozen importlib._bootstrap>", line 586 in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1525 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1558 in _find_and_load
  File "<stdin>", line 1 in <module>
Segmentation fault


Can someone help me on this?

Thanks,
Ashwin
msg177318 - (view) Author: ashwani (nixdash) Date: 2012-12-10 23:56
Following is the behavior on the same machine with Python 2.6.6



ir[65] [~/]$ python
Python 2.6.6 (r266:84292, Dec  7 2011, 20:48:22) 
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>>
msg177324 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2012-12-11 07:36
Given where the crash is occurring and that faulthandler traceback it makes me wonder if it was compiled with a set of openssl headers that don't make the library it is using at runtime.

If you recompile the interpreter in debug mode (--with-pydebug on your ./configure) does it still happen?

Can you run it under gdb and get the C stacktrace?  that'll tell more than faulthandler alone does.  [I'm glad to see you're using faulthandler though!]
msg177392 - (view) Author: ashwani (nixdash) Date: 2012-12-12 22:57
Ok , It did not crash when I recompiled with --with-pydebug.
I observed crash when I was working with the urllib.request.
It  was crashing when I  imported urllib.request. I drill down the code of urllib.request and found that it was crashing because of hashlib import.
Now, it is not crashing when I import hashlib and urllib.request.
But urllib.request.urlopen fails to open a site. It does open few other sites.
Now this might be completely different issue.

I think we first need to find why it is not crashing after the recompilation.

Following is comparison of urlopen on the same machine using two different python versions.


ir[40] [~/Python-3.3.0/]$ python3
Python 3.3.0 (default, Dec 12 2012, 17:26:56) 
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
[71516 refs]
>>> import urllib
[71550 refs]
>>> import urllib.request
[123410 refs]
>>> u = urllib.request.urlopen('http://en.wikipedia.org/wiki/Wikipedia')
]Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usa/arao/Python-3.3.0/lib/python3.3/urllib/request.py", line 160, in urlopen
    return opener.open(url, data, timeout)
  File "/usa/arao/Python-3.3.0/lib/python3.3/urllib/request.py", line 479, in open
    response = meth(req, response)
  File "/usa/arao/Python-3.3.0/lib/python3.3/urllib/request.py", line 591, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usa/arao/Python-3.3.0/lib/python3.3/urllib/request.py", line 517, in error
    return self._call_chain(*args)
  File "/usa/arao/Python-3.3.0/lib/python3.3/urllib/request.py", line 451, in _call_chain
    result = func(*args)
  File "/usa/arao/Python-3.3.0/lib/python3.3/urllib/request.py", line 599, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
[126943 refs]
>>> u = urllib.request.urlopen('http://mit.edu/')
[127082 refs]
>>> len(u.read())
13857
[127068 refs]

It does open some other sites.


r[37] [~/Python-3.3.0/]$ python
Python 2.6.6 (r266:84292, Dec  7 2011, 20:48:22) 
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> u = urllib.urlopen('http://en.wikipedia.org/wiki/Wikipedia')
>>> len(u.read())
3000
>>> import hashlib
>>> 


Thanks,
Ashwin
msg177397 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2012-12-13 00:57
given the behavior you are seeing, I'm not inclined to trust your computer or however it is configured.  I do not believe this is a Python issue.

3.3 works fine on RHEL 6 so it should work fine on CentOS 6.  http://buildbot.python.org/all/builders/x86%20RHEL%206%203.3

next steps as far as debugging the crash goes still stand: run python under gdb and get the C stacktrace from the crash.
History
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60864
2012-12-13 00:57:27gregory.p.smithsetstatus: open -> closed
resolution: not a bug
messages: + msg177397
2012-12-12 22:57:27nixdashsetmessages: + msg177392
2012-12-11 07:36:30gregory.p.smithsetmessages: + msg177324
2012-12-11 07:03:16pitrousetnosy: + gregory.p.smith
2012-12-11 00:03:37vstinnersetnosy: + pitrou
2012-12-10 23:56:28nixdashsetmessages: + msg177318
2012-12-10 23:52:48nixdashcreate