Hello,
I have a custom OpenSSL engine and it is working fine with pthread. I was trying to use a third-party thread library by linking this library with my engine. However, upon linking and running the engine, I'm getting a Segmentation fault. I just could not figure out why. I have a hunch that my linking with the newly built dynamic library is not correct,
Following is what I did
1. Compile the thread library as a dynamic library
CC = gccCFLAGS = -Wall -fPIC -g -O3 -MDLDFLAGS = -sharedOBJ = uthread.o
all: libuthread.so
libuthread.so: $(OBJ)
$(LD) -shared -o $(@) $(OBJ)
clean:
rm -f *.o *.d libuthread.so
-include *.d
%.o: %.c
2. Copy this library to /lib/x86_64-linux-gnu/$(CC) $(CFLAGS) -o $@ -c $<
3. My Make file to compile my OpenSSL engine
4. After compilation, $ldd rsa-engine-new.so shows the following,gcc -g -fPIC -c -fomit-frame-pointer rsa-engine.cgcc -g -shared -o librsa_engine.so -L./libdune rsa-engine.o rsa/rsa.o rsa/bignum.o rsa/aes.o -Wl,-Bstatic -ldune -Wl,-Bdynamic -lcrypto -luthreadmv librsa_engine.so rsa-engine-new.so
linux-vdso.so.1 => (0x00007ffded367000)
I use gdb to find out what causes the segmentation fault, I find out that uthread_join(), is failing at some point. Can someone please tell me what I'm, doing wrong?libcrypto.so.1.1 => /opt/openssl/lib/libcrypto.so.1.1 (0x00007f895c5fa000)libuthread.so => /lib/x86_64-linux-gnu/libuthread.so (0x00007f895c3f4000)libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f895c02a000)libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f895be26000)libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f895bc09000)/lib64/ld-linux-x86-64.so.2 (0x00007f895cd56000)
N.B: I checked the library with a simple program and the library works fine.
Thanks,
Shariful