--Boundary-00=_zDxBAOg7eqs0DTu Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thu January 15 2004 14:20, Dr. Juergen Pfennig wrote: > About the current implementation in kconfigbackend.cpp: mmap() is used > always to read conf files. Interrestingly the author was aware of a SIGBUS > problem and tried to recover from the SIGBUS. BUT THIS DOES NOT WORK. May= be > it never worked? Or maybe it's a compiler optimization problem. Ok, after reading up on "how to recover from SIGBUS on mmap" I now have a=20 better patch :-) Please test. Darwin, Solaris and BSD developers: Does this patch compile for you? Cheers, Waldo =2D --=20 bastian@kde.org -=3D|[ KDE: K Desktop for the Enterprise ]|=3D- bastian@sus= e.com =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQFABxDzN4pvrENfboIRAuuoAKCUHW4DDEC/xyg+8i7FHE+6DSFiegCfTmcO ptbIKTNbC+wq5WWRKxVWzy4=3D =3D/szJ =2D----END PGP SIGNATURE----- --Boundary-00=_zDxBAOg7eqs0DTu Content-Type: text/x-diff; charset="iso-8859-1"; name="kconfig_sigbus.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kconfig_sigbus.patch" Index: kconfigbackend.cpp =================================================================== RCS file: /home/kde/kdelibs/kdecore/kconfigbackend.cpp,v retrieving revision 1.89 diff -u -r1.89 kconfigbackend.cpp --- kconfigbackend.cpp 29 Nov 2003 14:46:55 -0000 1.89 +++ kconfigbackend.cpp 15 Jan 2004 22:08:36 -0000 @@ -32,6 +32,7 @@ #endif #include #include +#include #include #include @@ -366,14 +367,21 @@ } #ifdef HAVE_MMAP +static const char *mmap_map; #ifdef SIGBUS -static const char **mmap_pEof; +static sigjmp_buf jmpbuf; +static volatile sig_atomic_t mmap_can_jump = 0; +static void (*mmap_old_sighandler)(int) = 0; -static void mmap_sigbus_handler(int) +static void mmap_sigbus_handler (int sig) { - *mmap_pEof = 0; - write(2, "SIGBUS\n", 7); - signal(SIGBUS, mmap_sigbus_handler); + if (!mmap_can_jump) + { + signal (sig, SIG_DFL); + raise (sig); + } + mmap_can_jump = 0; + siglongjmp (jmpbuf, 1); } #endif #endif @@ -382,7 +390,9 @@ KEntryMap *pWriteBackMap, bool bGlobal, bool bDefault) { - void (*old_sighandler)(int) = 0; + const char *s; // May get clobbered by sigsetjump, but we don't use them afterwards. + const char *eof; // May get clobbered by sigsetjump, but we don't use them afterwards. + QByteArray data; if (!rFile.isOpen()) // come back, if you have real work for us ;-> return; @@ -394,23 +404,26 @@ QCString aCurrentGroup(""); - const char *s, *eof; - QByteArray data; - unsigned int ll = localeString.length(); #ifdef HAVE_MMAP - const char *map = ( const char* ) mmap(0, rFile.size(), PROT_READ, MAP_PRIVATE, + mmap_map = ( const char* ) mmap(0, rFile.size(), PROT_READ, MAP_PRIVATE, rFile.handle(), 0); - if (map) + if (mmap_map) { - s = map; + s = mmap_map; eof = s + rFile.size(); #ifdef SIGBUS - mmap_pEof = &eof; - old_sighandler = signal(SIGBUS, mmap_sigbus_handler); + mmap_old_sighandler = signal(SIGBUS, mmap_sigbus_handler); + mmap_can_jump = 1; + if (sigsetjmp (jmpbuf, 1)) + { + munmap(( char* )mmap_map, rFile.size()); + signal (SIGBUS, mmap_old_sighandler); + return; + } #endif } else @@ -641,11 +654,11 @@ bFileImmutable = true; #ifdef HAVE_MMAP - if (map) + if (mmap_map) { - munmap(( char* )map, rFile.size()); + munmap(( char* )mmap_map, rFile.size()); #ifdef SIGBUS - signal(SIGBUS, old_sighandler); + signal(SIGBUS, mmap_old_sighandler); #endif } #endif --Boundary-00=_zDxBAOg7eqs0DTu--