[erlang-questions] R14B04 and OpenSSL 1.0.1c

85 views
Skip to first unread message

Bogdan Andu

unread,
May 22, 2013, 3:00:12 AM5/22/13
to erlang-q...@erlang.org
Hello,

I recently compiled otp_src_R14B04 with OpenSSL version 1.0.1c.

It is detected ok, but when I try to start crypto app I get the follwing error:

Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]

Eshell V5.8.5  (abort with ^G)
1> crypto:start().
/usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                                         /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                          /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                           /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                                                                                    /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                                     /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                      /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                       /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                                                                                /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                                 /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                  /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                   /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                                                                            /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                             /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                              /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                               /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                                                                        /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                         /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                          /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                           /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                                                                    /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                     /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                      /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                       /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                                                                /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                 /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                  /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                   /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                                                                            /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
                                                                                                             /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'

=ERROR REPORT==== 21-May-2013::15:19:12 ===
Unable to load crypto library. Failed with error:
"load_failed, Failed to load NIF library /usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto: 'Cannot load specified object'"
OpenSSL might not be installed on this system.

=ERROR REPORT==== 21-May-2013::15:19:12 ===
The on_load function for module crypto returned {error,
                                                 {load_failed,
                                                  "Failed to load NIF library /usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto: 'Cannot load specified object'"}}
** exception error: undefined function crypto:start/0
2>

It seems that /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so library tries to access the symbol   '__guard_local' that no longer seems to exists in libssl.so.19.0 .

On OpenSSL verion 1.0.0f there is no problem, only in version 1.0.1c .

What can be done to have ssl functionality as I need it.

Thank you in advanced,

Bogdan

Stanislav Sedov

unread,
May 22, 2013, 3:09:16 AM5/22/13
to Bogdan Andu, erlang-q...@erlang.org

On May 22, 2013, at 12:00 AM, Bogdan Andu <bog...@gmail.com> wrote:
> /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so: undefined symbol '__guard_local'
>
> =ERROR REPORT==== 21-May-2013::15:19:12 ===
> Unable to load crypto library. Failed with error:
> "load_failed, Failed to load NIF library /usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto: 'Cannot load specified object'"
> OpenSSL might not be installed on this system.
>
> =ERROR REPORT==== 21-May-2013::15:19:12 ===
> The on_load function for module crypto returned {error,
> {load_failed,
> "Failed to load NIF library /usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto: 'Cannot load specified object'"}}
> ** exception error: undefined function crypto:start/0
> 2>
>
> It seems that /usr/local/lib/erlang/erts-5.8.5/bin/beam.smp:/usr/local/lib/erlang/lib/crypto-2.0.4/priv/lib/crypto.so library tries to access the symbol '__guard_local' that no longer seems to exists in libssl.so.19.0 .
>
> On OpenSSL verion 1.0.0f there is no problem, only in version 1.0.1c .
>
> What can be done to have ssl functionality as I need it.
>

What OS is it? Do you know where this symbol is coming from?
I don't think it comes from Erlang -- most likely openssl and erlang was built agains different
headers/libraries.

--
ST4096-RIPE



_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Bogdan Andu

unread,
May 22, 2013, 3:34:18 AM5/22/13
to Stanislav Sedov, erlang-q...@erlang.org
The os is OpenBSD 5.3 amd64 with preinstalled opensssl library /usr/lib/libssl.so.19.0

$ /usr/sbin/openssl
OpenSSL> version
OpenSSL 1.0.1c 10 May 2012
OpenSSL>
^D

This is the only ssl library in the system, and erlang was configured with this ssl library
and no complaints at ./configure time.

On the other hand:

On OpenBSD 5.2 amd64 with preinstalled opensssl library /usr/lib/libssl.so.18.0

$ /usr/sbin/openssl
OpenSSL> version
OpenSSL 1.0.0f 4 Jan 2012
OpenSSL>
^D

everything works perfect, and Erlang was also configured againsat this preinstalled library

Stanislav Sedov

unread,
May 22, 2013, 4:46:45 AM5/22/13
to Bogdan Andu, erlang-q...@erlang.org

On May 22, 2013, at 12:34 AM, Bogdan Andu <bog...@gmail.com> wrote:

> The os is OpenBSD 5.3 amd64 with preinstalled opensssl library /usr/lib/libssl.so.19.0
>
> $ /usr/sbin/openssl
> OpenSSL> version
> OpenSSL 1.0.1c 10 May 2012
> OpenSSL>
> ^D
>
> This is the only ssl library in the system, and erlang was configured with this ssl library
> and no complaints at ./configure time.
>
> On the other hand:
>
> On OpenBSD 5.2 amd64 with preinstalled opensssl library /usr/lib/libssl.so.18.0
>
> $ /usr/sbin/openssl
> OpenSSL> version
> OpenSSL 1.0.0f 4 Jan 2012
> OpenSSL>
> ^D
>
> everything works perfect, and Erlang was also configured againsat this preinstalled library
>

I found this message on the mailing list, which seems to be relevant:
http://www.mail-archive.com/cdesktop...@lists.sourceforge.net/msg00598.html

It looks like the __guard_local symbol is generated by new stack_protector code,
and according to the patch it seems that linking against libcrtbeginS.o and
libcrtendS.o fixes the issue for CDE. It might be worth trying to modify the
erlang linker flags (or at least crypto linking flags) to link against these
objects.

However, I don't really understand what's going on here. According to [1],
the new __guard_local symbol should be present in crtbegin.o. But maybe crypto.so
is being linked manually by erlang build system (i.e. not via cc(1)), in which case
applying the same fix as was provided for CDE might help.

[1]: http://openbsd.7691.n7.nabble.com/GCC-diff-needs-testing-on-multiple-arches-td167891.html

Bogdan Andu

unread,
May 22, 2013, 5:23:41 AM5/22/13
to Stanislav Sedov, erlang-q...@erlang.org
Thank you for the pointers.

I'll give it a try to see what happens.

It seems that linking erlang against a previous, working ssl library would give the same error.

Bogdan

Bogdan Andu

unread,
May 23, 2013, 5:46:15 AM5/23/13
to Stanislav Sedov, erlang-q...@erlang.org
I have applied the patches:
cd $OTP_SRC_DIR_R14B04
patch -p0 <
/usr/ports/lang/erlang/patches/patch-erts_configure_in
patch -p0 <
/usr/ports/lang/erlang/patches/patch-erts_emulator_Makefile_in
patch -p0 <
/usr/ports/lang/erlang/patches/patch-erts_lib_src_Makefile_in
patch -p0 <
/usr/ports/lang/erlang/patches/patch-lib_tools_c_src_Makefile_in
patch -p0 <
/usr/ports/lang/erlang/patches/patch-make_target_mk

*all patches succedded,
and then:

./configure
sudo gmake install
the same error

I modified
erts/configure.in:
from:
openbsd*)
                DED_LD="$CC"
                DED_LD_FLAG_RUNTIME_LIBRARY_PATH="$CFLAG_RUNTIME_LIBRARY_PATH"
                DED_LDFLAGS="-shared"
        ;;
in:
openbsd*)
               
DED_LD="$CC"
               
DED_LD_FLAG_RUNTIME_LIBRARY_PATH="$CFLAG_RUNTIME_LIBRARY_PATH"
               
DED_LDFLAGS="-shared /usr/lib/crtbeginS.o /usr/lib/crtbegin.o"
        ;;
because:
$ nm /usr/lib/crtbegin.o
         U _GLOBAL_OFFSET_TABLE_
         U
_Jv_RegisterClasses
00000000 D __dso_handle
00000000 T __fini
00000000 D
__guard_local
00000000 T __init
00000000 W __register_frame_info
         U
atexit
$ nm /usr/lib/crtbeginS.o
         U _GLOBAL_OFFSET_TABLE_
         U
_Jv_RegisterClasses
         U __cxa_finalize
00000000 D __dso_handle
00000000
D __guard_local
00000000 T _fini
00000000 T _init

gmake clean
./configure
sudo gmake install
the same error

Does anyone has an idea of how to solve this
issue, because I really need R14B04.

Please help. I am really out of ideas.
Maybe I should link against other libraries but I do not know what they are.
How can I dicover these libraries that I should link erlang against?

Bogdan

Stanislav Sedov

unread,
May 23, 2013, 4:50:39 PM5/23/13
to Bogdan Andu, erlang-q...@erlang.org
Did you try to link agains libcrtendS.o as well like openbsd guys do for CDE?
Also, you need to make sure that crypto.o linking actually uses these flags you
changes in erts/configure.in (also, btw, you need to rebuild configure if you
changes configure.in).

I don't have openbsd installed anywhere, so cannot provide more detailed help,
unfortunately. I'd recommend you to play with the linking flags for crypto.o:
log the entire build, find where it links crypto.o and use the same command
from the shell. It will be easier to try different flags combinations that
way.

Bogdan Andu

unread,
May 24, 2013, 4:48:22 AM5/24/13
to Stanislav Sedov, erlang-q...@erlang.org
in erts/configure.in there is a section:


openbsd*)
                DED_LD="$CC"
                DED_LD_FLAG_RUNTIME_LIBRARY_PATH="$CFLAG_RUNTIME_LIBRARY_PATH"
                DED_LDFLAGS="-shared"
        ;;

Spoke with guys on the mi...@openbsd.org maillist and they told me to run autoreconf, to regenerate configure from configure.in .

And indeed that did the trick and now is working fine.

There is no need to specify :
DED_LDFLAGS="-shared /usr/lib/crtbeginS.o /usr/lib/crtendS.o"
because this generates conflict on symbol '__guard_local'


Based on discussions in this topic and in mi...@openbsd.org maillist here is a small recipe for those who need to compile erlang R14B04 from sources on OpenBSD 5.3 amd64:

1. cd otp_src_R14B04
2. apply the patches founded in directory /usr/ports/lang/erlang/patches/
3. $ autoreconf
4. compile and install as usual

Thank you for your help,

Bogdan
Reply all
Reply to author
Forward
0 new messages