Chris Arena <[EMAIL PROTECTED]> writes:

> I just wanted to contact the developers of GGI to propose this change.
> I made the following change to the dlptlock.c routines ggLock and
> ggUnlock to avoid a SEG fault  in the version of Descent 2 I'm working
> on for Linux:
> 
> // [CCA 06-25-00]
> // The following change was made to make the operation 'robust'
> //
> int ggLock(void *lock)
> {
>   if ((lock != NULL) && (my_lock((pthread_mutex_t*)lock) == 0))
>   {
>     return 0;
>   }
>   return GGI_EUNKNOWN;
> }
> 
> // [CCA 06-25-00]
> // The following change was made to make the operation 'robust'
> //
> int ggUnlock(void *lock)
> {
>   if ((lock != NULL) && (my_unlock((pthread_mutex_t*)lock) == 0))
>   {
>     return 0;
>   }
> 
>   return GGI_EUNKNOWN;
> }
> 
> While the behavior is different, since both routines have a way to
> express the "failure" with the mutex that avoids the SEGMENTATION fault,

The only way the segfault should be avoided is by fixing the broken
code in Descent 2. You should be thankful that LibGG does not silently
ignore such broken code, if it did you'd have a really hard time
tracking down the random crashes caused by broken locking.

> it seemed like a good way to fix this problem. If I can find the cause
> of the "lock" pointer being NULL, I'll fix that. But in the meantime
> ....
> 
> What do you think of this change?

Totally broken. NULL is not a valid mutex pointer.

//Marcus
-- 
-------------------------------+------------------------------------
        Marcus Sundberg        | http://www.stacken.kth.se/~mackan
 Royal Institute of Technology |       Phone: +46 707 452062
       Stockholm, Sweden       |   E-Mail: [EMAIL PROTECTED]

Reply via email to