Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

Python and/or Openssl broken with the new dynamic-linker hack #129

Closed
jrevillard opened this issue Sep 2, 2014 · 11 comments
Closed

Python and/or Openssl broken with the new dynamic-linker hack #129

jrevillard opened this issue Sep 2, 2014 · 11 comments
Assignees

Comments

@jrevillard
Copy link

As reported in #107 python/openssl is broken probably because of the dynamiclinker hack. The postinstall step fail to install pip. Python segfault when invoking the openssl library:

open("/home/jerome/linuxbrew/lib/libcrypto.so.1.0.0", O_RDONLY|0x80000 /* O_??? */) = 15
read(15, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@Y\6\0\0\0\0\0"..., 832) = 832
fstat(15, {st_mode=S_IFREG|0444, st_size=2411339, ...}) = 0
mmap(NULL, 4225272, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 15, 0) = 0x2b5262d45000
mprotect(0x2b5262f22000, 2093056, PROT_NONE) = 0
mmap(0x2b5263121000, 163840, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 15, 0x1dc000) = 0x2b5263121000
mmap(0x2b5263149000, 14584, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2b5263149000
mprotect(0x2b525f902000, 3668, PROT_READ|PROT_WRITE) = 0
mprotect(0x2b525f902000, 3668, PROT_READ) = 0
mprotect(0x7fffc60ee000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC|PROT_GROWSDOWN) = 0
close(15)                               = 0
close(14)                               = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++

I will try to investigate a bit
Jerome

@jrevillard
Copy link
Author

Hi,

It seems that I found the "root" cause. Indeed, if I revert 0b330bf everything works again.

Best,
Jerome

@sjackman
Copy link
Member

sjackman commented Sep 2, 2014

That patch 0b330bf removes the need to force link formula that are keg_only :provided_by_osx. Does brew unlink openssl before brew install python work around this issue?

@jrevillard
Copy link
Author

I cannot, linuxbrew say that I must link openssl before beeing able to instal python.

Best.

@sjackman
Copy link
Member

sjackman commented Sep 2, 2014

Try brew install −−ignore−dependencies python.

@jrevillard
Copy link
Author

Hi,

the installation "works" like this but pip is broken:

[jrevillard@srv11:~] 1 $ pip 
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/home/jrevillard/linuxbrew/opt/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512

The thing that I do not understand is that everything seems to work just reverting this patch. Perhaps that the problem is another dependency....

@sjackman
Copy link
Member

@mbsullivan Would you please be able to lend a hand getting Python working again? OpenSSL seems broken. curl also uses openssl. That could be a second test case.
See also Homebrew/legacy-homebrew#22816 and #110.

@mbsullivan
Copy link
Contributor

@sjackman sure, I'll take a look at it again! (Unfortunately, I will only have time after tomorrow evening due to an impending deadline.)

@sjackman
Copy link
Member

I just figured it out. Homebrew was mistakenly setting CPPFLAGS=-I#{MacOS.sdk_path}/usr/include, which on Linux is CPPFLAGS=-I/usr/include, and this really broke things.

@sjackman
Copy link
Member

My patch is good enough to fix pip, but it's not perfect. Python setup.py still adds -I/usr/include by default, which is broken. See http://hg.python.org/cpython/file/070fed5b7b9d/setup.py#l524

            inc_dirs = self.compiler.include_dirs + ['/usr/include']

It results in warnings like these in the build log

/usr/include/features.h:299:0: warning: "__STDC_ISO_10646__" redefined
 #define __STDC_ISO_10646__  200009L
/home/sjackman/.linuxbrew/include/stdc-predef.h:54:0: note: this is the location of the previous definition
 #define __STDC_ISO_10646__  201103L

@sjackman sjackman self-assigned this Sep 11, 2014
@harper357
Copy link

I seem to be having a similar (or maybe the same) error. I can't seem to import ssl in python and when i try to use pip i get an error about openssl

% pip
Traceback (most recent call last):
  File "/data/gfedewa/.linuxbrew/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 356, in load_entry_point
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2476, in load_entry_point
  File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2190, in load
  File "/data/gfedewa/.linuxbrew/opt/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/__init__.py", line 10, in <module>
    from pip.util import get_installed_distributions, get_prog
  File "/data/gfedewa/.linuxbrew/opt/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/util.py", line 18, in <module>
    from pip._vendor.distlib import version
  File "/data/gfedewa/.linuxbrew/opt/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/_vendor/distlib/version.py", line 14, in <module>
    from .compat import string_types
  File "/data/gfedewa/.linuxbrew/opt/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/_vendor/distlib/compat.py", line 31, in <module>
    from urllib2 import (Request, urlopen, URLError, HTTPError,
ImportError: cannot import name HTTPSHandler

@sjackman
Copy link
Member

I've also experienced issues with Python and OpenSSL. I know that I don't have any issues now with a fresh install. My best suggestion for a workaround would be to remove Python and all its dependencies and reinstall it.

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

No branches or pull requests

4 participants