Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a particular problem I need solved right now, but I'd really like to know a good strategy for approaching this type of problem - segmentation faults when compiling other people's code, so I'm happy for either particular or general type answers.

The particulars

I'm trying to install OpenSSL 1.0.1g on a Synology DS412+. The version of GCC I've got (v4.2.1) doesn't have 64bit compiled in, which OpenSSL complains about:

$ ./config --prefix=/opt         \
           --openssldir=/etc/ssl \
           --libdir=lib          \
           shared                \
           zlib-dynamic
$ make

snip!

cryptlib.c:1: sorry, unimplemented: 64-bit mode not compiled in
cryptlib.c: In function 'OPENSSL_ia32cap_loc':
cryptlib.c:677: warning: dereferencing type-punned pointer will break strict-ali
asing rules
make[1]: *** [cryptlib.o] Error 1

So, I'm trying to install GCC 4.8.2 (I've tried several versions now) and each time it appears to fail in the GMP portion of the make. It's happened so much I decided to download GMP and try compiling that:

$ ./configure --prefix=/opt --build=i386-pc-linux-gnu
$ make

./gen-fac 32 0 >fac_table.h || (rm -f fac_table.h; exit 1)
/opt/bin/bash: line 1: 20507 Segmentation fault      (core dumped) ./gen-fac 32
0 > fac_table.h
make: *** [fac_table.h] Error 1

I'm not a C programmer, and this isn't even my code so the likelihood of me whipping out Valgrind to inspect the core is low. I've had this happen plenty of times compiling libraries, and learning C isn't something that's on my priority list. Are there alternatives to...?

  • learning C
  • asking on a forum/mailing list

The only package manager I have got access to is ipkg, and it provided the GCC that's not up to full muster. Could I set up a VM, build a binary for ipkg and put it on the DS412? Having not done something like that before, I don't know how feasible it is.

Any help or insight is much appreciated.

share|improve this question
    
Unfortunately, debugging C code does involve learning some C, though perhaps not a lot. The customary tool for debugging segfaults is gdb, or indeed any similar debugger. The techniques for using gdb are not hard, and will give you some indication of where the segfault is happening. –  Faheem Mitha May 15 at 18:22
    
@FaheemMitha I'll add it to my TODO list then! :) Thanks. –  iain May 19 at 12:17

2 Answers 2

I don't think you're going to be able to do what you want. These appliance types of devices such as Synology are often times using stripped down versions of tools such as Bash etc. These stripped down versions are likely missing capabilities which would seem to be your issue since it's pulling in Bash from a non-standard location, i.e. /opt/bin/bash.

https://www.synology.com/en-us/products/overview/DS412%2B

Before attempting to build this yourself I'd take a look on their website or in their forums to see if OpenSSL is being provided as a binary package that you can simply upgrade to instead of attempting to build it yourself.

share|improve this answer
    
Thanks. I've found that user installed stuff on the Diskstation tends to get put in /opt as that doesn't get overwritten during upgrades. ipkg does have a binary of OpenSSL, but it's at version 0.9.8v-2 and I need one that's >= 1.0.1 so I can get Ruby 2.1.2 on there. A nice bit of yak shaving for me! –  iain May 19 at 12:44
  1. The last two lines look suspicious

    $ ./config --prefix=/opt         \
           --openssldir=/etc/ssl \
           --libdir=lib          \
           shared                \
           zlib-dynamic
    

    any options for configure (usually) begin with --.

  2. 64bit - are you sure the distribution you are using is 64bit? Is the processor 64bit? Is the kernel running on the device 64bit? By the way, there's not much gain in using 64bit code with just 1GB RAM. It will actually eat a bit more memory due to bigger size of some data types and alignment.

  3. The error

    /opt/bin/bash: line 1: 20507 Segmentation fault  (core dumped)
        ./gen-fac 32 0 > fac_table.h
    

    suggests where's the problem - look for sources of gen-fac and try to run it in the debugger.

  4. Last but not least, can't you use ipkg install openssl or whatever the right syntax is for installing the distribution package?

share|improve this answer
    
The ./config is okay (or nearly so). OpenSSL has evolved over about 20 years and the build procedures, runtime (commandline) arguments, and APIs have grown a few warts along the way. ./config is the simplified "guess" interface while ./Configure (cap C) is the full-options form; there is no specific case for synology in config and I don't know enough to say if the guess logic is correct (or optimal) for that platform, but if not at worst you should get meaningful compile or link errors, not a toolchain segfault. –  dave_thompson_085 May 16 at 18:13
    
Thanks for taking the time to answer so thoroughly. 1 I got the config from here but it seemed pretty sound on inspection of the options, but I see what you mean. 2 It's definitely all 64 bit‌​. 4 ipkg does have a binary of OpenSSL, but it's at version 0.9.8v-2 and I need one >= 1.0.1 so I can get Ruby 2.1.2 on there. I'll give 3 a shot. –  iain May 19 at 12:41
    
Hmm... are you using the LFS patches that are marked as required there? You could probably also try to switch to a more recent Debian (or any other distribution, including Gentoo, since you can do a native build on something faster than the NAS). –  peterph May 19 at 20:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.