我想确定一个SIGSEGV的原因

我想确定一个SIGSEGV的原因

本文介绍了我想确定一个SIGSEGV的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写的Gentoo Linux和RedHat Linux上的应用程序了,该功能可按之一总是死机redhat的机器上

I'm writing an applicaiton for gentoo linux and redhat linux, one of the funciton always crashes on the redhat machine

usleep(100000);
    Display *display;
    display = XOpenDisplay(NULL);
    Window w;
    int x,y,i;
    unsigned m;
    Window root = XDefaultRootWindow(display);
    XQueryPointer(display,root,&root,&w,&x,&y,&i,&i,&m);
    XImage *image;
    sleep(1);
    image = XGetImage(display,root,0,0,1366,768,AllPlanes,XYPixmap);
    int pixel = XGetPixel(image,x,y);
    printf("\\clr(%i,%i,%i){}\n",x,y,pixel);
    XCloseDisplay(display);

此功能始终与RHEL机器上的分段错误崩溃

This function always crashes with a segmentation fault on the rhel machine

运行在GDB中progrma:
计划接收信号SIGSEGV,分割过错。
0x000000369942cb48在?? ()从/usr/lib64/libX11.so.6
缺少独立debuginfos,用途:debuginfo软安装ATK-1.30.0-1.el6.x86_64开罗1.8.8-6.el6_6.x86_64外籍-2.0.1-11.el6_2.x86_64的fontconfig-2.8.0-5。 el6.x86_64的FreeType-2.3.11-15.el6_6.1.x86_64 GDK-pixbuf2-2.24.1-6.el6_7.x86_64 glib2-2.28.8-4.el6.x86_64的glibc-2.12-1.166.el6_7.1。 x86_64的gtk2-2.24.23-6.el6.x86_64 libX11-1.6.0-6.el6.x86_64 libXau-1.0.6-4.el6.x86_64 libXcomposite-0.4.3-4.el6.x86_64 libXcursor-1.1.14 -2.1.el6.x86_64 libXdamage-1.1.3-4.el6.x86_64 libXext-1.3.2-2.1.el6.x86_64 libXfixes-5.0.1-2.1.el6.x86_64 libXi已-1.7.2-2.2.el6.x86_64 libXinerama-1.1.3-2.1.el6.x86_64 libXrandr-1.4.1-2.1.el6.x86_64 libXrender-0.9.8-2.1.el6.x86_64 libXtst-1.2.2-2.1.el6.x86_64的libpng-1.2.49- 2.el6_7.x86_64 libselinux-2.0.94-5.8.el6.x86_64 libxcb-1.9.1-3.el6.x86_64攀高-1.28.1-10.el6.x86_64 pixman-0.32.4-4.el6.x86_64的zlib -1.2.3-29.el6.x86_64

running the progrma in gdb:Program received signal SIGSEGV, Segmentation fault.0x000000369942cb48 in ?? () from /usr/lib64/libX11.so.6Missing separate debuginfos, use: debuginfo-install atk-1.30.0-1.el6.x86_64 cairo-1.8.8-6.el6_6.x86_64 expat-2.0.1-11.el6_2.x86_64 fontconfig-2.8.0-5.el6.x86_64 freetype-2.3.11-15.el6_6.1.x86_64 gdk-pixbuf2-2.24.1-6.el6_7.x86_64 glib2-2.28.8-4.el6.x86_64 glibc-2.12-1.166.el6_7.1.x86_64 gtk2-2.24.23-6.el6.x86_64 libX11-1.6.0-6.el6.x86_64 libXau-1.0.6-4.el6.x86_64 libXcomposite-0.4.3-4.el6.x86_64 libXcursor-1.1.14-2.1.el6.x86_64 libXdamage-1.1.3-4.el6.x86_64 libXext-1.3.2-2.1.el6.x86_64 libXfixes-5.0.1-2.1.el6.x86_64 libXi-1.7.2-2.2.el6.x86_64 libXinerama-1.1.3-2.1.el6.x86_64 libXrandr-1.4.1-2.1.el6.x86_64 libXrender-0.9.8-2.1.el6.x86_64 libXtst-1.2.2-2.1.el6.x86_64 libpng-1.2.49-2.el6_7.x86_64 libselinux-2.0.94-5.8.el6.x86_64 libxcb-1.9.1-3.el6.x86_64 pango-1.28.1-10.el6.x86_64 pixman-0.32.4-4.el6.x86_64 zlib-1.2.3-29.el6.x86_64

不幸的是我不能安装任何额外的软件包(或从第三方回购安装)为RHEL机

unfortunately I cannot install any additional packages(or install from 3rd party repos) for the rhel machines

回溯:
(GDB)BT

backtrace:(gdb) bt

92行是:
    INT像素= XGetPixel(图像,X,Y);

line 92 is : int pixel = XGetPixel(image,x,y);

如果该行被删除的应用程序正常工作

the application works fine if that line is removed

感谢

推荐答案

使用 XGetWindowAttributes 来发现屏幕的实际宽度/ heitgh。不要使用硬codeD值。

Use XGetWindowAttributes to find the real width/heitgh of the screen. Do not use the hardcoded values.

这篇关于我想确定一个SIGSEGV的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 19:07