LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-08-2016, 09:13 AM   #1
abinp12
LQ Newbie
 
Registered: Sep 2016
Posts: 5

Rep: Reputation: Disabled
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
 
Old 09-09-2016, 08:21 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,799

Rep: Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552
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
 
Old 09-09-2016, 08:25 AM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,678

Rep: Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258
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).
 
Old 09-18-2016, 11:24 PM   #4
abinp12
LQ Newbie
 
Registered: Sep 2016
Posts: 5

Original Poster
Rep: Reputation: Disabled
Cool

Quote:
Originally Posted by pan64 View Post
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
Attached Files
File Type: txt error.txt (2.4 KB, 6 views)

Last edited by abinp12; 09-19-2016 at 01:39 AM.
 
Old 09-19-2016, 02:06 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,799

Rep: Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552
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);
 
Old 09-19-2016, 05:04 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,678

Rep: Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258
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.
 
Old 09-19-2016, 09:40 AM   #7
abinp12
LQ Newbie
 
Registered: Sep 2016
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
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.
Attached Files
File Type: txt error.txt (2.6 KB, 2 views)
 
Old 09-19-2016, 09:44 AM   #8
abinp12
LQ Newbie
 
Registered: Sep 2016
Posts: 5

Original Poster
Rep: Reputation: Disabled
Angry

Quote:
Originally Posted by jpollard View Post
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.
 
Old 09-19-2016, 09:51 AM   #9
abinp12
LQ Newbie
 
Registered: Sep 2016
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
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.
 
Old 09-20-2016, 12:53 AM   #10
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,799

Rep: Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Segmentation Fault AdnanShaheen Linux - Software 4 05-17-2011 11:09 AM
segmentation fault help PARIHAR Linux - Newbie 8 05-03-2010 06:24 AM
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika SUSE / openSUSE 2 12-02-2005 09:34 AM
Segmentation fault? JiggaJerry Fedora 10 01-16-2005 04:01 PM
segmentation fault itywygms Linux - Newbie 10 09-19-2004 08:25 PM


All times are GMT -5. The time now is 01:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration