public inbox for cygwin-xfree@sourceware.org help / color / mirror / Atom feed
* Cannot run Qt5 applications. @ 2015-02-04 23:20 David Stacey 2015-02-05 1:40 ` Jon TURNEY 0 siblings, 1 reply; 8+ messages in thread From: David Stacey @ 2015-02-04 23:20 UTC (permalink / raw) To: cygwin-xfree [-- Attachment #1: Type: text/plain, Size: 1341 bytes --] 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) and no clock. I've tried compiling a really trivial Qt5 example (attached): g++ -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui \ -o qt5-demo qt5-demo.cpp -lQt5Widgets -lQt5Core And then running ./qt5-demo gives: QObject::connect: signal not found in QPushButton QObject::connect: signal not found in QWidget QObject::connect: signal not found in QWidget QXcbConnection: XCB error: 145 (Unknown), sequence: 162, resource id: 0, major code: 140 (Unknown), minor code: 20 Bad system call (core dumped) The demo runs fine in Fedora 21. It also runs in Cygwin when compiled with Qt4: g++ -I/usr/include/qt4 -I/usr/include/qt4/QtGui -o qt5-demo qt5-demo.cpp \ -lQtGui -lQtCore And now running the (incorrectly-named!) ./qt5-demo launches the application. Please could you advise what I'm doing wrong. Many thanks in advance, Dave. [-- Attachment #2: qt5-demo.cpp --] [-- Type: text/plain, Size: 273 bytes --] #include <QApplication> #include <QPushButton> int main(int argc, char** argv) { QApplication app(argc, argv); QPushButton *button = new QPushButton("Hello!"); QObject::connect(button, SIGNAL(clicked()), &app, SLOT(quit())); button->show(); return app.exec(); } [-- Attachment #3: Type: text/plain, Size: 223 bytes --] -- 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/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Cannot run Qt5 applications. 2015-02-04 23:20 Cannot run Qt5 applications David Stacey @ 2015-02-05 1:40 ` Jon TURNEY 2015-02-06 14:57 ` David Stacey 2015-02-13 18:32 ` Jon TURNEY 0 siblings, 2 replies; 8+ messages in thread From: Jon TURNEY @ 2015-02-05 1:40 UTC (permalink / raw) To: cygwin-xfree 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/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Cannot run Qt5 applications. 2015-02-05 1:40 ` Jon TURNEY @ 2015-02-06 14:57 ` David Stacey 2015-02-13 18:32 ` Jon TURNEY 1 sibling, 0 replies; 8+ messages in thread From: David Stacey @ 2015-02-06 14:57 UTC (permalink / raw) To: cygwin-xfree 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/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Cannot run Qt5 applications. 2015-02-05 1:40 ` Jon TURNEY 2015-02-06 14:57 ` David Stacey @ 2015-02-13 18:32 ` Jon TURNEY 2015-03-02 23:34 ` Yaakov Selkowitz 1 sibling, 1 reply; 8+ messages in thread From: Jon TURNEY @ 2015-02-13 18:32 UTC (permalink / raw) To: cygwin-xfree; +Cc: Yaakov Selkowitz [-- Attachment #1: Type: text/plain, Size: 1054 bytes --] 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 [-- Attachment #2: qt5-shm.patch --] [-- Type: text/plain, Size: 2318 bytes --] --- origsrc/qtbase-opensource-src-5.3.2/src/plugins/platforms/xcb/qxcbbackingstore.cpp 2014-09-11 11:48:06.000000000 +0100 +++ src/qtbase-opensource-src-5.3.2/src/plugins/platforms/xcb/qxcbbackingstore.cpp 2015-02-13 17:30:11.410525500 +0000 @@ -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); [-- Attachment #3: Type: text/plain, Size: 223 bytes --] -- 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/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Cannot run Qt5 applications. 2015-02-13 18:32 ` Jon TURNEY @ 2015-03-02 23:34 ` Yaakov Selkowitz 2015-03-03 9:04 ` Corinna Vinschen 0 siblings, 1 reply; 8+ messages in thread From: Yaakov Selkowitz @ 2015-03-02 23:34 UTC (permalink / raw) To: cygwin-xfree On Fri, 2015-02-13 at 18:32 +0000, 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/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Cannot run Qt5 applications. 2015-03-02 23:34 ` Yaakov Selkowitz @ 2015-03-03 9:04 ` Corinna Vinschen 2015-03-03 14:49 ` Jon TURNEY 0 siblings, 1 reply; 8+ messages in thread From: Corinna Vinschen @ 2015-03-03 9:04 UTC (permalink / raw) To: cygwin-xfree [-- Attachment #1: Type: text/plain, Size: 1541 bytes --] On Mar 2 17:34, Yaakov Selkowitz wrote: > On Fri, 2015-02-13 at 18:32 +0000, 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 [-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Cannot run Qt5 applications. 2015-03-03 9:04 ` Corinna Vinschen @ 2015-03-03 14:49 ` Jon TURNEY 2015-03-03 17:11 ` Corinna Vinschen 0 siblings, 1 reply; 8+ messages in thread From: Jon TURNEY @ 2015-03-03 14:49 UTC (permalink / raw) To: cygwin-xfree 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 +0000, 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/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Cannot run Qt5 applications. 2015-03-03 14:49 ` Jon TURNEY @ 2015-03-03 17:11 ` Corinna Vinschen 0 siblings, 0 replies; 8+ messages in thread From: Corinna Vinschen @ 2015-03-03 17:11 UTC (permalink / raw) To: cygwin-xfree [-- Attachment #1: Type: text/plain, Size: 579 bytes --] 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 [-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-03-03 17:11 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-02-04 23:20 Cannot run Qt5 applications David Stacey 2015-02-05 1:40 ` Jon TURNEY 2015-02-06 14:57 ` David Stacey 2015-02-13 18:32 ` Jon TURNEY 2015-03-02 23:34 ` Yaakov Selkowitz 2015-03-03 9:04 ` Corinna Vinschen 2015-03-03 14:49 ` Jon TURNEY 2015-03-03 17:11 ` Corinna Vinschen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).