qrencode - Segmentation fault (core dumped)

帅比萌擦擦* 提交于 2019-12-08 09:43:42

问题


I have made a working program that generated an image given a certain string. It is fully working on my Slackware 32bit distro and others distros also 32bit.

Now i need to implement it on the client machine, which is an AIX powerpc. It compiled without any problem, and seems to work (every other function works and gives correct results), except when i call these 2 functions "QRcode_encodeString" and "QRcode_encodeData". It keeps giving me Segmentation fault.

You can assume my main() only line is that function call:

#include <stdio.h>
#include <qrencode.h>

int main(void)
{
   QRcode* pQRC = QRcode_encodeString("abc", 0, QR_ECLEVEL_L, QR_MODE_8, 0);    
   return 0;
}

I don't have gdb on the client machine and no root priv. It works with "QRcode_encodeStringMQR()" which generates a micro QRcode, but that isn't a solution for me. It generates a dump file by the name "core" which I can't use it since that machine doesn't have gdb... And I'm assuming I can't open it on another machine since they don't share the same architecture. I have literaly no clue on how to troubleshoot this one...

Again, this code works on my Slackware distro.

My knowledge about powerpc and AIX is limited to this experience only, unfortunately.

I forgot to mention, only cc is available and I'm compiling like this:

cc qrgen.c -lqrencode -L/usr/local/lib -I/usr/local/include

回答1:


Just for information, I was able to compile it on a Linux on Power environment and it runs fine, without segmentation fault. Machine: POWER8 OS: Ubuntu 15.04

ubuntu@ubuntu1504:~/qr$ cat hello.c 
#include <stdio.h>
#include <qrencode.h>

int main(void)
{
   QRcode* pQRC = QRcode_encodeString("abc", 0, QR_ECLEVEL_L, QR_MODE_8, 0);    
   return 0;
}

ubuntu@ubuntu1504:~/qr$ gcc hello.c  -lqrencode

ubuntu@ubuntu1504:~/qr$ ./a.out 

ubuntu@ubuntu1504:~/qr$ strace  ./a.out 
execve("./a.out", ["./a.out"], [/* 20 vars */]) = 0
brk(0)                                  = 0x1003f690000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=42765, ...}) = 0
mmap(NULL, 42765, PROT_READ, MAP_PRIVATE, 3, 0) = 0x3fff816c0000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/usr/lib/powerpc64le-linux-gnu/libqrencode.so.3", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\25\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=67496, ...}) = 0
mmap(NULL, 131832, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3fff81690000
mmap(0x3fff816a0000, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0) = 0x3fff816a0000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/powerpc64le-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0\25\0\1\0\0\0@R\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1789000, ...}) = 0
mmap(NULL, 1860208, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3fff814c0000
mmap(0x3fff81670000, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1a0000) = 0x3fff81670000
close(3)                                = 0
mprotect(0x3fff81670000, 65536, PROT_READ) = 0
mprotect(0x3fff816a0000, 65536, PROT_READ) = 0
mprotect(0x10010000, 65536, PROT_READ)  = 0
mprotect(0x3fff81720000, 65536, PROT_READ) = 0
munmap(0x3fff816c0000, 42765)           = 0
brk(0)                                  = 0x1003f690000
brk(0x1003f6c0000)                      = 0x1003f6c0000
exit_group(0)                           = ?
+++ exited with 0 +++



回答2:


I found the problem... The installation of the lib generated problems and caused the caused the symbolic links to exist as a simple file and the library just wasn't there...

This is the missing file "/usr/local/lib/libqrencode.so.3.4.4" which is the code itself... I was looking at the files and didn't notice it because there was a file called libqrencode.so.3.4 but this file was supose to be a symbolic link to libqrencode.so.3.4.4 since libqrencode.so.3.4.4 didn't exist, instead of the symbolic link failing, it created a empty file with that same name...



来源:https://stackoverflow.com/questions/29107183/qrencode-segmentation-fault-core-dumped

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!