Mageia Bugzilla – Attachment 11974 Details for
Bug 27473
Timezone-2020d update causes libical to crash making it impossible for Evolution to handle appointments, tasks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
Patch file as tested
libical.patch (text/plain), 2.39 KB, created by
aguador
on 2020-11-03 11:38:12 CET
(
hide
)
Description:
Patch file as tested
Filename:
MIME Type:
Creator:
aguador
Created:
2020-11-03 11:38:12 CET
Size:
2.39 KB
patch
obsolete
>index 9a1c641c..64b14ce3 100644 >--- a/src/libical/icaltimezone.c >+++ b/src/libical/icaltimezone.c >@@ -1787,6 +1787,12 @@ static void icaltimezone_load_builtin_timezone(icaltimezone *zone) > > icaltimezone_builtin_lock(); > >+ /* Try again, maybe it had been set by other thread while waiting for the lock */ >+ if (zone->component) { >+ icaltimezone_builtin_unlock(); >+ return; >+ } >+ > /* If the location isn't set, it isn't a builtin timezone. */ > if (!zone->location || !zone->location[0]) { > icaltimezone_builtin_unlock(); >index 5a24a52d..08f793d3 100644 >--- a/src/test/builtin_timezones.c >+++ b/src/test/builtin_timezones.c >@@ -20,10 +20,63 @@ > #include <config.h> > #endif > >+#ifdef HAVE_PTHREAD_H >+#include <pthread.h> >+#include <assert.h> >+#endif >+ > #include "libical/ical.h" > > #include <stdio.h> > >+#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD) && defined(HAVE_PTHREAD_CREATE) >+ >+#define N_THREADS 20 >+ >+static pthread_mutex_t thread_comp_mutex = PTHREAD_MUTEX_INITIALIZER; >+static const void *thread_comp = NULL; >+ >+static void * >+thread_func(void *user_data) >+{ >+ icaltimezone *zone = user_data; >+ icalcomponent *icalcomp; >+ >+ if(!zone) >+ return NULL; >+ >+ icalcomp = icaltimezone_get_component(zone); >+ pthread_mutex_lock(&thread_comp_mutex); >+ if(!thread_comp) >+ thread_comp = icalcomp; >+ else >+ assert(thread_comp == icalcomp); >+ pthread_mutex_unlock(&thread_comp_mutex); >+ icalcomp = icalcomponent_new_clone(icalcomp); >+ icalcomponent_free(icalcomp); >+ >+ return NULL; >+} >+ >+static void >+test_get_component_threadsafety(void) >+{ >+ pthread_t thread[N_THREADS]; >+ icaltimezone *zone; >+ int ii; >+ >+ zone = icaltimezone_get_builtin_timezone("Europe/London"); >+ >+ for(ii = 0; ii < N_THREADS; ii++) { >+ pthread_create(&thread[ii], NULL, thread_func, zone); >+ } >+ >+ for(ii = 0; ii < N_THREADS; ii++) { >+ pthread_join(thread[ii], NULL); >+ } >+} >+#endif >+ > int main() > { > icalarray *builtin_timezones; >@@ -34,6 +87,10 @@ int main() > set_zone_directory("../../zoneinfo"); > icaltimezone_set_tzid_prefix("/softwarestudio.org/"); > >+ #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD) && defined(HAVE_PTHREAD_CREATE) >+ test_get_component_threadsafety(); >+ #endif >+ > tt = icaltime_current_time_with_zone(icaltimezone_get_builtin_timezone("America/New_York")); > > tt.year = 2038;
index 9a1c641c..64b14ce3 100644 --- a/src/libical/icaltimezone.c +++ b/src/libical/icaltimezone.c @@ -1787,6 +1787,12 @@ static void icaltimezone_load_builtin_timezone(icaltimezone *zone) icaltimezone_builtin_lock(); + /* Try again, maybe it had been set by other thread while waiting for the lock */ + if (zone->component) { + icaltimezone_builtin_unlock(); + return; + } + /* If the location isn't set, it isn't a builtin timezone. */ if (!zone->location || !zone->location[0]) { icaltimezone_builtin_unlock(); index 5a24a52d..08f793d3 100644 --- a/src/test/builtin_timezones.c +++ b/src/test/builtin_timezones.c @@ -20,10 +20,63 @@ #include <config.h> #endif +#ifdef HAVE_PTHREAD_H +#include <pthread.h> +#include <assert.h> +#endif + #include "libical/ical.h" #include <stdio.h> +#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD) && defined(HAVE_PTHREAD_CREATE) + +#define N_THREADS 20 + +static pthread_mutex_t thread_comp_mutex = PTHREAD_MUTEX_INITIALIZER; +static const void *thread_comp = NULL; + +static void * +thread_func(void *user_data) +{ + icaltimezone *zone = user_data; + icalcomponent *icalcomp; + + if(!zone) + return NULL; + + icalcomp = icaltimezone_get_component(zone); + pthread_mutex_lock(&thread_comp_mutex); + if(!thread_comp) + thread_comp = icalcomp; + else + assert(thread_comp == icalcomp); + pthread_mutex_unlock(&thread_comp_mutex); + icalcomp = icalcomponent_new_clone(icalcomp); + icalcomponent_free(icalcomp); + + return NULL; +} + +static void +test_get_component_threadsafety(void) +{ + pthread_t thread[N_THREADS]; + icaltimezone *zone; + int ii; + + zone = icaltimezone_get_builtin_timezone("Europe/London"); + + for(ii = 0; ii < N_THREADS; ii++) { + pthread_create(&thread[ii], NULL, thread_func, zone); + } + + for(ii = 0; ii < N_THREADS; ii++) { + pthread_join(thread[ii], NULL); + } +} +#endif + int main() { icalarray *builtin_timezones; @@ -34,6 +87,10 @@ int main() set_zone_directory("../../zoneinfo"); icaltimezone_set_tzid_prefix("/softwarestudio.org/"); + #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD) && defined(HAVE_PTHREAD_CREATE) + test_get_component_threadsafety(); + #endif + tt = icaltime_current_time_with_zone(icaltimezone_get_builtin_timezone("America/New_York")); tt.year = 2038;
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 27473
: 11974 |
11975