A question about XOpenDisplay fail

Peter Hutterer peter.hutterer at who-t.net
Wed Apr 28 04:17:50 PDT 2010


On Wed, Apr 28, 2010 at 02:50:50PM +0800, Ma, Qingyu (GE Healthcare) wrote:
> Hello,
>  
> During my developing work, I meet a problem about XOpenDisplay. Could
> you please give me some consult?

please don't cross-post. taking xorg-devel off the CC list.
 
> I'm developing a system, which uses fvwm as WM. Two fvwm are executed to
> implement two separated screens. My process is displayed on one
> screen(DISPLAY). It calls XOpenDisplay(NULL) to get one Display
> connection to be used as display image, and another Display to be used
> as toggle keyboard led (whenever keyboard led state is changed, a new
> Display is opened and closed). The function is OK. But when I was doing
> monkey and cycle test, there is a very very little possibility that my
> process may crash. I looked through my code, and found a bug which was
> that I didn't check the return value of XOpenDisplay, and use it
> directly . I have checked that a NULL Display will cause process crash
> in following code. It's just my analysis and guess, I'm not sure whether
> it does be the root cause. And, by now, the cycle and monkey cannot
> re-occur the issue.  
>  
> So, I want to get some information from you to help to reach the root
> cause. What will cause XOpenDisplay return NULL? How can I simulate the
> case?(When my process is executed, I'm sure the XWindow and fvwm have
> been booted up.)

XOpenDisplay on an invalid display will return NULL. so you can either
specify an invalid display in the code directly or through your DISPLAY
environment variable.

DISPLAY=:10 your-program-name

should fail, unless you really have an X server on display 10 which is
rather unlikely.

Cheers,
  Peter



More information about the xorg mailing list