705N/A###############################################################################
705N/A# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
705N/A# Use subject to license terms.
705N/A# Permission is hereby granted, free of charge, to any person obtaining a
705N/A# copy of this software and associated documentation files (the
705N/A# "Software"), to deal in the Software without restriction, including
705N/A# without limitation the rights to use, copy, modify, merge, publish,
705N/A# distribute,
and/or sell copies of the Software, and to permit persons
705N/A# to whom the Software is furnished to do so, provided that the above
705N/A# copyright notice(s) and this permission notice appear in all copies of
705N/A# the Software and that both the above copyright notice(s) and this
705N/A# permission notice appear in supporting documentation.
705N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
705N/A# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
705N/A# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
705N/A# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
705N/A# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
705N/A# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
705N/A# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
705N/A# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
705N/A# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
705N/A# Except as contained in this notice, the name of a copyright holder
705N/A# shall not be used in advertising or otherwise to promote the sale, use
705N/A# or other dealings in this Software without prior written authorization
705N/A# of the copyright holder.
705N/A4010755: SEGV in XFindContext if XInitThreads has been enabled
705N/AXFindContext in Xlib was calling _XLockMutex with an uninitialized
705N/Amutex lock structure. The new version of XInitThreads activates the
705N/Alocking functions at any time, even after displays have been created.
705N/AIn this new case, the context structure was created prior to
705N/AXInitThreads being invoked. As a result, the display contained an
705N/Aopaque pointer to this context structure, which still contained an
705N/Auninitialized lock structure.
705N/AThe solution was to explicitly set the lock structure pointer to NULL
705N/A(as a flag) when creating the context, then check for NULL before
705N/Alocking. If NULL is found and threads are now enabled, then the
705N/Astructure gets reinitialized to the correct mutex lock structure
705N/A@@ -192,6 +192,7 @@ int XSaveContext(
705N/A _XCreateMutex(&db->linfo);
705N/A if (!display) *pdb = db; else
705N/A@@ -203,6 +204,8 @@ int XSaveContext(
705N/A UnlockDisplay(display);
+ _XCreateMutex(&db->linfo);
head = &Hash(db, rid, context);
_XUnlockMutex(&db->linfo);
@@ -254,6 +257,8 @@ int XFindContext(display, rid, context,
+ _XCreateMutex(&db->linfo);
for (entry = Hash(db, rid, context); entry; entry = entry->next)
@@ -292,6 +297,8 @@ int XDeleteContext(display, rid, context
+ _XCreateMutex(&db->linfo);
for (prev = &Hash(db, rid, context);
---
src/Xrm.c 2007-05-16 08:34:44.000000000 -0700
+++
src/Xrm.c 2008-02-12 21:00:44.594920000 -0800
@@ -500,6 +500,7 @@ static XrmDatabase NewDatabase(void)
db = (XrmDatabase) Xmalloc(sizeof(XrmHashBucketRec));
_XCreateMutex(&db->linfo);
db->table = (NTable)NULL;
db->mbstate = (XPointer)NULL;
@@ -775,7 +776,11 @@ void XrmCombineDatabase(
+ _XCreateMutex(&from->linfo);
_XLockMutex(&from->linfo);
+ _XCreateMutex(&(*into)->linfo);
_XLockMutex(&(*into)->linfo);
if ((ftable = from->table)) {
@@ -1022,6 +1027,8 @@ void XrmQPutResource(
if (!*pdb) *pdb = NewDatabase();
+ _XCreateMutex(&(*pdb)->linfo);
_XLockMutex(&(*pdb)->linfo);
PutEntry(*pdb, bindings, quarks, type, value);
_XUnlockMutex(&(*pdb)->linfo);
@@ -1038,6 +1045,8 @@ XrmPutResource(
XrmQuark quarks[MAXDBDEPTH+1];
if (!*pdb) *pdb = NewDatabase();
+ _XCreateMutex(&(*pdb)->linfo);
_XLockMutex(&(*pdb)->linfo);
XrmStringToBindingQuarkList(specifier, bindings, quarks);
PutEntry(*pdb, bindings, quarks, XrmStringToQuark(type), value);
@@ -1056,6 +1065,8 @@ XrmQPutStringResource(
if (!*pdb) *pdb = NewDatabase();
+ _XCreateMutex(&(*pdb)->linfo);
_XLockMutex(&(*pdb)->linfo);
PutEntry(*pdb, bindings, quarks, XrmQString, &value);
_XUnlockMutex(&(*pdb)->linfo);
@@ -1538,6 +1549,8 @@ XrmPutStringResource(
XrmStringToBindingQuarkList(specifier, bindings, quarks);
+ _XCreateMutex(&(*pdb)->linfo);
_XLockMutex(&(*pdb)->linfo);
PutEntry(*pdb, bindings, quarks, XrmQString, &value);
_XUnlockMutex(&(*pdb)->linfo);
@@ -1550,6 +1563,8 @@ XrmPutLineResource(
if (!*pdb) *pdb = NewDatabase();
+ _XCreateMutex(&(*pdb)->linfo);
_XLockMutex(&(*pdb)->linfo);
GetDatabase(*pdb, line, (char *)NULL, False);
_XUnlockMutex(&(*pdb)->linfo);
@@ -1562,6 +1577,8 @@ XrmGetStringDatabase(
+ _XCreateMutex(&db->linfo);
GetDatabase(db, data, (char *)NULL, True);
_XUnlockMutex(&db->linfo);
@@ -1670,6 +1687,8 @@ XrmGetFileDatabase(
return (XrmDatabase)NULL;
+ _XCreateMutex(&db->linfo);
GetDatabase(db, str, filename, True);
_XUnlockMutex(&db->linfo);
@@ -1694,6 +1713,8 @@ XrmCombineFileDatabase(
*target = db = NewDatabase();
+ _XCreateMutex(&db->linfo);
GetDatabase(db, str, filename, True);
_XUnlockMutex(&db->linfo);
@@ -1966,6 +1987,8 @@ Bool XrmEnumerateDatabase(
+ _XCreateMutex(&db->linfo);
@@ -2262,6 +2285,8 @@ Bool XrmQGetSearchList(
+ _XCreateMutex(&db->linfo);
@@ -2540,6 +2565,8 @@ Bool XrmQGetResource(
+ _XCreateMutex(&db->linfo);
@@ -2636,6 +2663,8 @@ XrmLocaleOfDatabase(
+ _XCreateMutex(&db->linfo);
retval = (*db->methods->lcname)(db->mbstate);
_XUnlockMutex(&db->linfo);
@@ -2648,6 +2677,8 @@ void XrmDestroyDatabase(
register NTable table, next;
+ _XCreateMutex(&db->linfo);
for (next = db->table; (table = next); ) {