LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Xopendisplay making segmentation fault (https://www.linuxquestions.org/questions/linux-newbie-8/xopendisplay-making-segmentation-fault-4175589014/)

abinp12 09-08-2016 09:13 AM

Xopendisplay making segmentation fault
 
Hi,
I currently did a sample multi threaded code using Xlib and sdl to make two separate child windows .It works well in X86 architecture.I cross compiled same code for ARM and built executables. I tried this executables in R CAR-E2 Board,some errors occurred. Mostly segmentation fault occurred. Some times, window got created using xlib, persists for a very short time and exits,while window created using sdl works successfully. I already set DISPLAY environment variables to :0.0 and crosschecked. When the program was debugged, it was found that Xopendisplay makes this error.

Is XAUTHORITY environment variable making such issue?

When I checked XAUTHORITY variable, it was not set(Xauthority file was not found). Please anyone suggest a solution for this problem. I am waiting for your valuable answers.

Thanks in Advance
Abin

pan64 09-09-2016 08:21 AM

you gave almost no information, therefore you will get no usable answer. Please post real error messages, probably the code you compiled, the process how did you compile it ....
http://catb.org/~esr/faqs/smart-questions.html
probably it is not related to xauthority, but some incompatibility between the compiler and runtime environment

jpollard 09-09-2016 08:25 AM

You might check the version of Xlib between the target system and your cross development system.

Even make sure the same compiler is used between the target system and your development system (this is less likely a problem IMO).

abinp12 09-18-2016 11:24 PM

1 Attachment(s)
Quote:

Originally Posted by pan64 (Post 5602907)
you gave almost no information, therefore you will get no usable answer. Please post real error messages, probably the code you compiled, the process how did you compile it ....
http://catb.org/~esr/faqs/smart-questions.html
probably it is not related to xauthority, but some incompatibility between the compiler and runtime environment


Pan64 thanks for your reply.

I wrote a simple program for ARM platform to create a window with X11 API's .I wrote a application which contain Xopendisplay() and crosscompiled for ARM using arm-poky-linux-gnueabi-gcc-4.8.3 .Executable image is copied to ARM linux ,When I executed the program, got error " Segmentation fault".

When I debugging,found that Xopendisplay() function making such error. X86 version of the same application is working fine.
Please note that I am running the application from root access . Can you give me the exact reason for this error
i checked a simple code like this

#include <X11/Xlib.h>
#include <stdio.h>

int main()
{
Display *display;
if( ! (display=XOpenDisplay(NULL) ) ) {
return(1);
}
return 0;
}

getting error Segmentaion fault in ARM

please find the attachment when i started x11 using startx commands in arm

Thanks and regards
Abin

pan64 09-19-2016 02:06 AM

based on the log (error.txt) startx was not successful. You may need to install xterm/twm or modify your environment to find them. As far as I see this log is not related to segfault.
I think segault means the lib you use on the runtime environment is not really compatible with the one you used to build your app.
From the other hand XOpenDisplay needs a valid char * input, NULL is not accepted, probably that causes segfault.
Code:

SYNTAX
      Display *XOpenDisplay(char *display_name);


jpollard 09-19-2016 05:04 AM

Actually, the segfault would be normal - depending on the implementation of the library.

The function calls for a parameter - but not NULL. Now the argument MAY be "", but that is a valid pointer to an empty string.

abinp12 09-19-2016 09:40 AM

1 Attachment(s)
Quote:

Originally Posted by pan64 (Post 5607144)
based on the log (error.txt) startx was not successful. You may need to install xterm/twm or modify your environment to find them. As far as I see this log is not related to segfault.
I think segault means the lib you use on the runtime environment is not really compatible with the one you used to build your app.
From the other hand XOpenDisplay needs a valid char * input, NULL is not accepted, probably that causes segfault.
Code:

SYNTAX
      Display *XOpenDisplay(char *display_name);



Thanks pan64.

The xterm already in ARM linux and i tried with it.Also i crosscompiled and running the application on the same library.i changed program like this,

#include <X11/Xlib.h>
#include <stdio.h>

int main()
{
Display *display;
char *display_name = "foo";
if( ! (display=XOpenDisplay(display_name) ) )
{

XCloseDisplay(display);


return(1);
}
return 0;
}

But still i getting same error, "segmentation fault".Here I am attaching startx ,After i copied xterm to /usr/bin.

abinp12 09-19-2016 09:44 AM

Quote:

Originally Posted by jpollard (Post 5607185)
Actually, the segfault would be normal - depending on the implementation of the library.

The function calls for a parameter - but not NULL. Now the argument MAY be "", but that is a valid pointer to an empty string.

jpollard tanx for your reply

I tried argument as "" in OpenDisplay() like

display=XOpenDisplay("");

Still getting segmenation fault.

abinp12 09-19-2016 09:51 AM

Quote:

Originally Posted by jpollard (Post 5602909)
You might check the version of Xlib between the target system and your cross development system.

Even make sure the same compiler is used between the target system and your development system (this is less likely a problem IMO).

Thanks jpollard.
I crosschecked xlib version on both target and cross development system.Both having same version library.

pan64 09-20-2016 12:53 AM

there are still serious errors can be found in that error.txt.
Code:

/etc/X11/xinit/xinitrc: line 95: twm: command not found
/etc/X11/xinit/xinitrc: line 96: xclock: command not found
/etc/X11/xinit/xinitrc: line 99: /bin/xterm: cannot execute binary file: Exec format error

It looks like X system was not properly installed on that host. Or maybe damaged somehow. Try to reinstall.


All times are GMT -5. The time now is 07:51 PM.