Re: Cannot run Qt5 applications.

2015-03-03 Thread Corinna Vinschen
On Mar  3 14:48, Jon TURNEY wrote:
 On 03/03/2015 09:04, Corinna Vinschen wrote:
 Or you just add signal(SIGSYS, SIG_IGN) prior to calling shmget.
 SIGSYS is raised when calling a system call which isn't available.
 That's perfectly valid.
 
 This is true.
 
 I guess it's not how Linux behaves, though, so I think changing it ought to
 be considered to minimize porting effort.

Done.


HTH,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


pgpAsbfOyZl3B.pgp
Description: PGP signature


Re: Cannot run Qt5 applications.

2015-03-03 Thread Corinna Vinschen
On Mar  2 17:34, Yaakov Selkowitz wrote:
 On Fri, 2015-02-13 at 18:32 +, Jon TURNEY wrote:
  On 05/02/2015 01:40, Jon TURNEY wrote:
   On 04/02/2015 23:20, David Stacey wrote:
   I'm having difficulty running any Qt5 application. These are the
   commands I'm issuing:
   [snip]
   and I see the clock, so X is up and running. Then:
   [snip]
  
   Possibly you need to install and start cygserver (See [1])
  
   If so, this is because Qt5 is assuming shared memory is available, which
   could possibly be handled in a better way...
  
  This looks like a portability problem in Qt5, where it only handles 
  shmget() failing with a return value of -1, not with SIGSYS, to fallback 
  to using an image in unshared memory.
  
  Patch attached.
 
 Or is it a problem with our shmget()?
 
 http://pubs.opengroup.org/onlinepubs/9699919799/functions/shmget.html
 http://man7.org/linux/man-pages/man2/shmget.2.html
 
 Perhaps we should be just returning -1 with an errno (ENOSYS?) instead
 of raise(SIGSYS)?

Or you just add signal(SIGSYS, SIG_IGN) prior to calling shmget.
SIGSYS is raised when calling a system call which isn't available.
That's perfectly valid.

Of course, it would be nice if Qt5 used POSIX shared memory objects
iunstead, but that's asked too much, probably.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


pgplD_qeT8_Zi.pgp
Description: PGP signature


Re: Cannot run Qt5 applications.

2015-03-03 Thread Jon TURNEY

On 03/03/2015 09:04, Corinna Vinschen wrote:

On Mar  2 17:34, Yaakov Selkowitz wrote:

On Fri, 2015-02-13 at 18:32 +, Jon TURNEY wrote:

On 05/02/2015 01:40, Jon TURNEY wrote:

On 04/02/2015 23:20, David Stacey wrote:

I'm having difficulty running any Qt5 application. These are the
commands I'm issuing:
[snip]
and I see the clock, so X is up and running. Then:
[snip]


Possibly you need to install and start cygserver (See [1])

If so, this is because Qt5 is assuming shared memory is available, which
could possibly be handled in a better way...


This looks like a portability problem in Qt5, where it only handles
shmget() failing with a return value of -1, not with SIGSYS, to fallback
to using an image in unshared memory.

Patch attached.


Or is it a problem with our shmget()?

http://pubs.opengroup.org/onlinepubs/9699919799/functions/shmget.html
http://man7.org/linux/man-pages/man2/shmget.2.html

Perhaps we should be just returning -1 with an errno (ENOSYS?) instead
of raise(SIGSYS)?


I think it was a BSD-ism to raise SIGSYS if shared memory is not 
available due to policy.


Historically, there must have been some OS which did this, because there 
is code to detect this situation in the X server [1]


[1] http://cgit.freedesktop.org/xorg/xserver/tree/Xext/shm.c#n167

Looking at [2],[3] it seems perhaps this was added in Cygwin because 
some FreeBSD test code was used?


[2] https://cygwin.com/ml/cygwin-cvs/2003-q4/msg00130.html
[3] https://cygwin.com/ml/cygwin-cvs/2003-q4/msg00128.html

I'd kind of assumed that modern BSDs behave in the same way, but that 
doesn't actually seem likely.


I have absolutely no problem with changing this to return ENOSPC (there 
is a limit of 0 SHM identifiers, and we have reached it), or whatever is 
appropriate in this state.



Or you just add signal(SIGSYS, SIG_IGN) prior to calling shmget.
SIGSYS is raised when calling a system call which isn't available.
That's perfectly valid.


This is true.

I guess it's not how Linux behaves, though, so I think changing it ought 
to be considered to minimize porting effort.


I'll also note that checking once at startup, as the X server does, is 
not enough.  If the cygserver is stopped, it will die with an unexpected 
SIGSYS when a client tried to use shared memory.



Of course, it would be nice if Qt5 used POSIX shared memory objects
instead, but that's asked too much, probably.


Unfortunately, it has to use whatever the X server's MIT-SHM extension 
uses...


--
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Cannot run Qt5 applications.

2015-03-02 Thread Yaakov Selkowitz
On Fri, 2015-02-13 at 18:32 +, Jon TURNEY wrote:
 On 05/02/2015 01:40, Jon TURNEY wrote:
  On 04/02/2015 23:20, David Stacey wrote:
  I'm having difficulty running any Qt5 application. These are the
  commands I'm issuing:
  [snip]
  and I see the clock, so X is up and running. Then:
  [snip]
 
  Possibly you need to install and start cygserver (See [1])
 
  If so, this is because Qt5 is assuming shared memory is available, which
  could possibly be handled in a better way...
 
 This looks like a portability problem in Qt5, where it only handles 
 shmget() failing with a return value of -1, not with SIGSYS, to fallback 
 to using an image in unshared memory.
 
 Patch attached.

Or is it a problem with our shmget()?

http://pubs.opengroup.org/onlinepubs/9699919799/functions/shmget.html
http://man7.org/linux/man-pages/man2/shmget.2.html

Perhaps we should be just returning -1 with an errno (ENOSYS?) instead
of raise(SIGSYS)?

--
Yaakov



--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Cannot run Qt5 applications.

2015-02-13 Thread Jon TURNEY

On 05/02/2015 01:40, Jon TURNEY wrote:

On 04/02/2015 23:20, David Stacey wrote:

I'm having difficulty running any Qt5 application. These are the
commands I'm issuing:

 XWin -multiwindow 
 export DISPLAY=:0.0
 xclock 

and I see the clock, so X is up and running. Then:

 /usr/lib/qt5/examples/gui/analogclock/analogclock
 QXcbConnection: XCB error: 145 (Unknown), sequence: 162, resource
id: 0, major c
 ode: 140 (Unknown), minor code: 20
 Bad system call (core dumped)


Possibly you need to install and start cygserver (See [1])

If so, this is because Qt5 is assuming shared memory is available, which
could possibly be handled in a better way...

[1]  http://x.cygwin.com/docs/ug/using-shared-memory.html


Yaakov,

This looks like a portability problem in Qt5, where it only handles 
shmget() failing with a return value of -1, not with SIGSYS, to fallback 
to using an image in unshared memory.


Patch attached.

--
Jon TURNEY
Volunteer Cygwin/X X Server maintainer
--- 
origsrc/qtbase-opensource-src-5.3.2/src/plugins/platforms/xcb/qxcbbackingstore.cpp
  2014-09-11 11:48:06.0 +0100
+++ 
src/qtbase-opensource-src-5.3.2/src/plugins/platforms/xcb/qxcbbackingstore.cpp  
2015-02-13 17:30:11.410525500 +
@@ -75,6 +75,7 @@ public:
 
 private:
 void destroy();
+static bool isShmSupported();
 
 xcb_shm_segment_info_t m_shm_info;
 
@@ -88,6 +89,44 @@ private:
 QRegion m_dirty;
 };
 
+static bool shmNotSupported = false;
+
+static void
+SigSysHandler(int signo)
+{
+shmNotSupported = true;
+}
+
+bool
+QXcbShmImage::isShmSupported()
+{
+static bool checked = false;
+if (!checked)
+  {
+void (*oldHandler)(int);
+int shmid = -1;
+
+/* If no SHM support in the kernel, the bad syscall will generate 
SIGSYS */
+oldHandler = signal(SIGSYS, SigSysHandler);
+
+shmNotSupported = false;
+shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
+if (shmid != -1)
+  {
+/* Successful allocation - clean up */
+shmctl(shmid, IPC_RMID, NULL);
+  }
+else
+  {
+/* Allocation failed */
+shmNotSupported = true;
+  }
+signal(SIGSYS, oldHandler);
+checked = true;
+  }
+return (!shmNotSupported);
+}
+
 QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize size, uint depth, 
QImage::Format format)
 : QXcbObject(screen-connection())
 , m_gc(0)
@@ -116,7 +155,9 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *s
 if (!segmentSize)
 return;
 
-int id = shmget(IPC_PRIVATE, segmentSize, IPC_CREAT | 0600);
+int id = -1;
+if (isShmSupported())
+  id = shmget(IPC_PRIVATE, segmentSize, IPC_CREAT | 0600);
 if (id == -1)
 qWarning(QXcbShmImage: shmget() failed (%d) for size %d (%dx%d),
  errno, segmentSize, size.width(), size.height());
@@ -130,7 +171,7 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *s
 xcb_generic_error_t *error = NULL;
 if (shm_present)
 error = xcb_request_check(xcb_connection(), 
xcb_shm_attach_checked(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, 
false));
-if (!shm_present || error) {
+if (!shm_present || error || (id == -1)) {
 free(error);
 
 shmdt(m_shm_info.shmaddr);
--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/

Re: Cannot run Qt5 applications.

2015-02-06 Thread David Stacey

On 05/02/15 01:40, Jon TURNEY wrote:

On 04/02/2015 23:20, David Stacey wrote:

I'm having difficulty running any Qt5 application. These are the
commands I'm issuing:

 XWin -multiwindow 
 export DISPLAY=:0.0
 xclock 

and I see the clock, so X is up and running. Then:

 /usr/lib/qt5/examples/gui/analogclock/analogclock
 QXcbConnection: XCB error: 145 (Unknown), sequence: 162, resource
id: 0, major c
 ode: 140 (Unknown), minor code: 20
 Bad system call (core dumped)


Possibly you need to install and start cygserver (See [1])

If so, this is because Qt5 is assuming shared memory is available, 
which could possibly be handled in a better way...


Yes, that did the trick - thank you. I would never have figured that our 
from the error message!


Dave.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Cannot run Qt5 applications.

2015-02-04 Thread Jon TURNEY

On 04/02/2015 23:20, David Stacey wrote:

I'm having difficulty running any Qt5 application. These are the
commands I'm issuing:

 XWin -multiwindow 
 export DISPLAY=:0.0
 xclock 

and I see the clock, so X is up and running. Then:

 /usr/lib/qt5/examples/gui/analogclock/analogclock
 QXcbConnection: XCB error: 145 (Unknown), sequence: 162, resource
id: 0, major c
 ode: 140 (Unknown), minor code: 20
 Bad system call (core dumped)


Possibly you need to install and start cygserver (See [1])

If so, this is because Qt5 is assuming shared memory is available, which 
could possibly be handled in a better way...


[1]  http://x.cygwin.com/docs/ug/using-shared-memory.html

--
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/