Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: MythTV: Dev

Win32 + QT4 segfault: resolved

 

 

MythTV dev RSS feed   Index | Next | Previous | View Threaded


andrei at tanas

Jun 30, 2008, 6:51 PM

Post #1 of 8 (768 views)
Permalink
Win32 + QT4 segfault: resolved

I have found what was causing segfaults in Win32 builds during load (before
GDB was capable to do anything). I've got a working win32/qt4 mythfrontend
with this.
The explanation is rather complicated and will go to either TrollTech, or
GCC developers or to Microsoft when I will have time to analyze and put it
in words.

Regards,
Andrei Tanas.


diff -ur qt-win-opensource-src-4.4.0.orig/src/corelib/kernel/qobjectdefs.h
qt-win-opensource-src-4.4.0/src/corelib/kernel/qobjectdefs.h
--- qt-win-opensource-src-4.4.0.orig/src/corelib/kernel/qobjectdefs.h Mon
Jun 30 20:25:04 2008
+++ qt-win-opensource-src-4.4.0/src/corelib/kernel/qobjectdefs.h Mon Jun 30
16:25:50 2008
@@ -149,7 +149,7 @@
#define Q_OBJECT \
public: \
Q_OBJECT_CHECK \
- static const QMetaObject staticMetaObject; \
+ static QMetaObject staticMetaObject; \
virtual const QMetaObject *metaObject() const; \
virtual void *qt_metacast(const char *); \
QT_TR_FUNCTIONS \
@@ -160,7 +160,7 @@
/* tmake ignore Q_GADGET */
#define Q_GADGET \
public: \
- static const QMetaObject staticMetaObject; \
+ static QMetaObject staticMetaObject; \
private:
#else // Q_MOC_RUN
#define slots slots
diff -ur qt-win-opensource-src-4.4.0.orig/src/tools/moc/generator.cpp
qt-win-opensource-src-4.4.0/src/tools/moc/generator.cpp
--- qt-win-opensource-src-4.4.0.orig/src/tools/moc/generator.cpp Mon Jun 30
20:25:24 2008
+++ qt-win-opensource-src-4.4.0/src/tools/moc/generator.cpp Mon Jun 30
16:16:08 2008
@@ -319,7 +319,7 @@
if (isQt)
fprintf(out, "const QMetaObject QObject::staticQtMetaObject =
{\n");
else
- fprintf(out, "const QMetaObject %s::staticMetaObject = {\n",
cdef->qualified.constData());
+ fprintf(out, "QMetaObject %s::staticMetaObject = {\n",
cdef->qualified.constData());

if (isQObject)
fprintf(out, " { 0, ");
Attachments: qt4.patch (1.48 KB)


davidbuzz at gmail

Jul 1, 2008, 12:27 AM

Post #2 of 8 (733 views)
Permalink
Re: Win32 + QT4 segfault: resolved [In reply to]

yippee! :-)
_______________________________________________
mythtv-dev mailing list
mythtv-dev[at]mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


davidbuzz at gmail

Jul 1, 2008, 1:41 AM

Post #3 of 8 (730 views)
Permalink
Re: Win32 + QT4 segfault: resolved [In reply to]

Andrei,

It seems my theory was correct earlier... if I understand
correctly.... basically it means that (at least under mingw/msys) that
'extern const' is NOT allowed to refer to a DATA section (as created
by the 'const' keyword) (eg: extern const struct, or extern const
QMetaObject in this case ) if any/all of the data comes from a DLL.
I think.

This results in a DLL with an .rdata section that contains a run-time
resolved reference to the data/struct/etc, and because it's in a
read-only (.rdata) section of the executable, it can't be "run-time
resolved", because the piece of application is loaded into memory as
read-only, which SHOULD made sense if it's a .rdata section, right??
clearly not.

Arnon was also correct in his determination that it was related to the
QMetaObject, and the fact that it had changed ('const' added) from
QT3->QT4 had also not escaped him, so well done to all!

I am currently building with a modified win32-packager.pl script ...
and will let you all know how I go......(including changing to qt
4.4.0, so the qt build is slow.... ) quick patch will come after I
know it works.....

Buzz.
_______________________________________________
mythtv-dev mailing list
mythtv-dev[at]mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


andrei at tanas

Jul 1, 2008, 12:52 PM

Post #4 of 8 (707 views)
Permalink
Re: Win32 + QT4 segfault: resolved [In reply to]

Almost absolutely correct. I wouldn't say that the references needed to be resolved at run time though: the actual exception was happening inside ntdll.dll code, when it was trying to initialize the static const references with addresses of cross-dll inherited class instances while loading the dlls.
It's hard to tell whose responsibility it is: QT used static const, gcc put the variables into the read-only segment, even though it was impossible to resolve the references at compile time, and Windows put the segment into read-only mode before finishing resolving the references. I would say that QT and gcc haven't done anything "illegal", and Windows should have been smarter than that.
If you and Arnon were so close, why haven't you tried to test your theory, or at least haven't told me what you new? It was fun chasing this stuff, but i spent over 15 hours on it.
Anyway, looks like QT4 didn't mess things up too badly, it's in almost working condition now.

Regards,
Andrei.


----- Original message -----
Andrei,

It seems my theory was correct earlier... if I understand
correctly.... basically it means that (at least under mingw/msys) that
'extern const'  is NOT allowed to refer to a DATA section (as created
by the 'const' keyword) (eg: extern const struct, or extern const
QMetaObject in this case )  if any/all of the data comes from a DLL.
I think.

This results in a DLL with an .rdata section that contains a run-time
resolved reference to the data/struct/etc, and because it's in a
read-only (.rdata) section of the executable, it can't be "run-time
resolved", because the piece of application is loaded into memory as
read-only, which SHOULD made sense if it's a .rdata section, right??
clearly not.

Arnon was also correct in his determination that it was related to the
QMetaObject, and the fact that it had changed ('const' added) from
QT3->QT4 had also not escaped him, so well done to all!

I am currently building with a modified win32-packager.pl script ...
and will let you all know how I go......(including changing to qt
4.4.0, so the qt build is slow.... )  quick patch will come after I
know it works.....

Buzz.


davidbuzz at gmail

Jul 1, 2008, 5:50 PM

Post #5 of 8 (695 views)
Permalink
Re: Win32 + QT4 segfault: resolved [In reply to]

> If you and Arnon were so close, why haven't you tried to test your theory,
> or at least haven't told me what you new? It was fun chasing this stuff, but
> i spent over 15 hours on it.

Andrei,

Me too, so don't feel alone!... I didn't mean to exclude you from the
prior history, but it's all been on the -dev list... see the subject
"Seg Fault on HEAD build under win32".

As far as testing the theory, we had a few theories, but applying it
in practice means knowing where/how. You made the leap that the rest
of us couldn't. nicely done.

Buzz.
_______________________________________________
mythtv-dev mailing list
mythtv-dev[at]mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


davidbuzz at gmail

Jul 1, 2008, 5:54 PM

Post #6 of 8 (695 views)
Permalink
Re: Win32 + QT4 segfault: resolved [In reply to]

UPDATE:

I have finally finished building Qt4.4.0 (with your patch and the
other patches we have in win32-packager), and re-building myth from
scratch with that QT, and I'm still getting the 0x00000005 error.

Ideas?

I'm going to try clearing up my system of old QT4.3 stuff (and old
myth binaries), and going again... but that's another 4-6 hrs build
time, so I just though I'd give an update.....

Buzz.
_______________________________________________
mythtv-dev mailing list
mythtv-dev[at]mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


davidbuzz at gmail

Jul 1, 2008, 8:23 PM

Post #7 of 8 (682 views)
Permalink
Re: Win32 + QT4 segfault: resolved [In reply to]

Andrei,

I'm still unable to replicate your experience....I had a barfed QT
install before, but have fixed it now, and am using your patch....

Now I get this (below) while building QT4.4.0 ...ideas?

Buzz.

cd src\corelib\ && mingw32-make -f Makefile
mingw32-make[1]: Entering directory
`C:/msys/1.0/qt-win-opensource-src-4.4.0/src/corelib'
mingw32-make -f Makefile.Debug all
mingw32-make[2]: Entering directory
`C:/msys/1.0/qt-win-opensource-src-4.4.0/src/corelib'
g++ -c -include tmp\obj\debug_shared\qt_pch.h -g -Wall -frtti
-fexceptions -mthreads -DQT_SHARED -DQ
T_THREAD_SUPPORT -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_BUILD_CORE_LIB
-DQT_NO_USING_NAMESPACE -DQT_M
AKEDLL -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT
-D_USE_MATH_DEFINES -DHB_EXPORT=Q_CORE
_EXPORT -DQT_DLL -I"..\..\include" -I"..\..\include\QtCore"
-I"tmp\rcc\debug_shared" -I"tmp" -I"conc
urrent" -I"global" -I"..\3rdparty\zlib" -I"..\3rdparty\harfbuzz\src"
-I"c:\msys\1.0\qt-win-opensourc
e-src-4.4.0\include\ActiveQt" -I"tmp\moc\debug_shared" -I"."
-I"..\..\mkspecs\win32-g++" -o tmp\obj\
debug_shared\qbuffer.o io\qbuffer.cpp
In file included from io\qbuffer.cpp:453:
tmp/moc/debug_shared/moc_qbuffer.cpp:40: error: conflicting
declaration 'QMetaObject QBuffer::static
MetaObject'
io\qbuffer.h:62: error: 'QBuffer::staticMetaObject' has a previous
declaration as `const QMetaObject
QBuffer::staticMetaObject'
tmp/moc/debug_shared/moc_qbuffer.cpp:46: error: prototype for `const
QMetaObject* QBuffer::metaObjec
t() const' does not match any in class `QBuffer'
io\qbuffer.h:62: error: candidate is: virtual QMetaObject*
QBuffer::metaObject() const
tmp/moc/debug_shared/moc_qbuffer.cpp:46: error: `const QMetaObject*
QBuffer::metaObject() const' and
`virtual QMetaObject* QBuffer::metaObject() const' cannot be overloaded
mingw32-make[2]: *** [tmp/obj/debug_shared/qbuffer.o] Error 1
mingw32-make[2]: Leaving directory
`C:/msys/1.0/qt-win-opensource-src-4.4.0/src/corelib'
mingw32-make[1]: *** [debug-all] Error 2
mingw32-make[1]: Leaving directory
`C:/msys/1.0/qt-win-opensource-src-4.4.0/src/corelib'
mingw32-make: *** [sub-corelib-make_default-ordered] Error 2
_______________________________________________
mythtv-dev mailing list
mythtv-dev[at]mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


andrei at tanas

Jul 1, 2008, 9:09 PM

Post #8 of 8 (684 views)
Permalink
Re: Win32 + QT4 segfault: resolved [In reply to]

It looks like you either have moc_*.cpp files from previous build or are
using unpatched "moc" tool.

1. Make sure to "make distclean" in QT so that all "tmp/moc/*" stuff is
re-generated.
2. Find and delete your "moc.exe" before recompiling QT to make sure you are
using the patched one.

----- Original Message -----
From: "buzz" <davidbuzz[at]gmail.com>
To: "Andrei Tanas" <andrei[at]tanas.ca>; "Development of mythtv"
<mythtv-dev[at]mythtv.org>
Sent: Tuesday, July 01, 2008 11:23 PM
Subject: Re: [mythtv] Win32 + QT4 segfault: resolved


> Andrei,
>
> I'm still unable to replicate your experience....I had a barfed QT
> install before, but have fixed it now, and am using your patch....
>
> Now I get this (below) while building QT4.4.0 ...ideas?
>
> Buzz.
>
> cd src\corelib\ && mingw32-make -f Makefile
> mingw32-make[1]: Entering directory
> `C:/msys/1.0/qt-win-opensource-src-4.4.0/src/corelib'
> mingw32-make -f Makefile.Debug all
> mingw32-make[2]: Entering directory
> `C:/msys/1.0/qt-win-opensource-src-4.4.0/src/corelib'
> g++ -c -include tmp\obj\debug_shared\qt_pch.h -g -Wall -frtti
> -fexceptions -mthreads -DQT_SHARED -DQ
> T_THREAD_SUPPORT -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_BUILD_CORE_LIB
> -DQT_NO_USING_NAMESPACE -DQT_M
> AKEDLL -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT
> -D_USE_MATH_DEFINES -DHB_EXPORT=Q_CORE
> _EXPORT -DQT_DLL -I"..\..\include" -I"..\..\include\QtCore"
> -I"tmp\rcc\debug_shared" -I"tmp" -I"conc
> urrent" -I"global" -I"..\3rdparty\zlib" -I"..\3rdparty\harfbuzz\src"
> -I"c:\msys\1.0\qt-win-opensourc
> e-src-4.4.0\include\ActiveQt" -I"tmp\moc\debug_shared" -I"."
> -I"..\..\mkspecs\win32-g++" -o tmp\obj\
> debug_shared\qbuffer.o io\qbuffer.cpp
> In file included from io\qbuffer.cpp:453:
> tmp/moc/debug_shared/moc_qbuffer.cpp:40: error: conflicting
> declaration 'QMetaObject QBuffer::static
> MetaObject'
> io\qbuffer.h:62: error: 'QBuffer::staticMetaObject' has a previous
> declaration as `const QMetaObject
> QBuffer::staticMetaObject'
> tmp/moc/debug_shared/moc_qbuffer.cpp:46: error: prototype for `const
> QMetaObject* QBuffer::metaObjec
> t() const' does not match any in class `QBuffer'
> io\qbuffer.h:62: error: candidate is: virtual QMetaObject*
> QBuffer::metaObject() const
> tmp/moc/debug_shared/moc_qbuffer.cpp:46: error: `const QMetaObject*
> QBuffer::metaObject() const' and
> `virtual QMetaObject* QBuffer::metaObject() const' cannot be overloaded
> mingw32-make[2]: *** [tmp/obj/debug_shared/qbuffer.o] Error 1
> mingw32-make[2]: Leaving directory
> `C:/msys/1.0/qt-win-opensource-src-4.4.0/src/corelib'
> mingw32-make[1]: *** [debug-all] Error 2
> mingw32-make[1]: Leaving directory
> `C:/msys/1.0/qt-win-opensource-src-4.4.0/src/corelib'
> mingw32-make: *** [sub-corelib-make_default-ordered] Error 2
>

_______________________________________________
mythtv-dev mailing list
mythtv-dev[at]mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

MythTV dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.