GNetworkAddress is not thread safe
@mcrha
Submitted by Milan Crha Link to original bug (#748996)
Description
I sometimes get a runtime warning
GLib-GIO-CRITICAL **: g_network_address_set_addresses: assertion 'addresses != NULL && addr->priv->sockaddrs == NULL' failed when running evolution from scratch. it's not there always, and it's sometimes only once there, other times multiple times there.
I tried to investigate it and it turned out that the 'addresses' is not NULL, but also 'addr->priv->sockaddrs' is not NULL, aka it's already set. This setting is done in Thread 15 and Thread 8 at the same time, as can be seen here (I added there some debugging and locking around the backtrace capturing, thus the lines do not match actual source files):
Thread 15 (Thread 0x7f437effd700 (LWP 6257)):
#0 0x000000324acc3e0b in __libc_waitpid (pid=6540, stat_loc=stat_loc@entry=0x7f437effc430, options=options@entry=0) at ../sysdeps/unix/sysv/linux/waitpid.c:40
#1 0x000000324ac42a3b in do_system (line=<optimized out>) at ../sysdeps/posix/system.c:148
#2 0x00007f43f4270a8c in g_network_address_set_addresses (addr=0x5cbce10, addresses=0x4a418a0, resolver_serial=1430897968) at gnetworkaddress.c:245
#3 0x00007f43f4271d0c in g_network_address_address_enumerator_next (enumerator=0x7f434c004b50, cancellable=0x0, error=0x7f437effc6d8) at gnetworkaddress.c:912
#4 0x00007f43f428a4e0 in g_socket_address_enumerator_next (enumerator=0x7f434c004b50, cancellable=0x0, error=0x7f437effc6d8) at gsocketaddressenumerator.c:83
#5 0x00007f43f427b766 in g_proxy_address_enumerator_next (enumerator=0x7f43d4505140, cancellable=0x0, error=0x7f437effc890) at gproxyaddressenumerator.c:210
#6 0x00007f43f428a4e0 in g_socket_address_enumerator_next (enumerator=0x7f43d4505140, cancellable=0x0, error=0x7f437effc890) at gsocketaddressenumerator.c:83
#7 0x00007f43f4272ca3 in g_network_monitor_base_can_reach (monitor=0x2818960, connectable=0x5cbce10, cancellable=0x0, error=0x7f437effc890) at gnetworkmonitorbase.c:194
#8 0x00007f43f427242b in g_network_monitor_can_reach (monitor=0x2818960, connectable=0x5cbce10, cancellable=0x0, error=0x7f437effc890) at gnetworkmonitor.c:139
#9 0x00007f43f485ebfa in camel_network_service_can_reach_sync (service=0x5ad0d70, cancellable=0x0, error=0x0) at camel-network-service.c:930
#10 0x00007f43f48898d5 in store_maybe_connect_sync (store=0x5ad0d70, cancellable=0x0, error=0x7f437effca58) at camel-store.c:314
#11 0x00007f43f488c331 in camel_store_get_folder_info_sync (store=0x5ad0d70, top=0x0, flags=(CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_SUBSCRIBED), cancellable=0x0, error=0x7f437effca58) at camel-store.c:1543
#12 0x00007f43e4bc3141 in mail_folder_cache_note_store_thread (simple=0x69b0c70, source_object=0x4f888e0, cancellable=0x0) at mail-folder-cache.c:1884
#13 0x00007f43f428285a in run_in_thread (job=0x69b01c0, c=0x0, _data=0x5a1aa90) at gsimpleasyncresult.c:858
#14 0x00007f43f4268e71 in io_job_thread (task=0x69c4140, source_object=0x0, task_data=0x69b01c0, cancellable=0x0) at gioscheduler.c:85
#15 0x00007f43f4297a87 in g_task_thread_pool_thread (thread_data=0x69c4140, pool_data=0x0) at gtask.c:1215
#16 0x00007f43f3cc8108 in g_thread_pool_thread_proxy (data=0x6815560) at gthreadpool.c:307
#17 0x00007f43f3cc7b2a in g_thread_proxy (data=0x693bca0) at gthread.c:764
#18 0x000000324b80752a in start_thread (arg=0x7f437effd700) at pthread_create.c:310
#19 0x000000324ad0022d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
while the addresses are also going to be set in:
Thread 8 (Thread 0x7f4360ff9700 (LWP 6406)):
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f43f3cedc6b in g_mutex_lock_slowpath (mutex=0x7f43f45ae5c0 <mutex>) at gthread-posix.c:1308
#2 0x00007f43f3cedd0c in g_mutex_lock (mutex=0x7f43f45ae5c0 <mutex>) at gthread-posix.c:1332
#3 0x00007f43f42709d0 in g_network_address_set_addresses (addr=0x5cbce10, addresses=0x69ac920, resolver_serial=1430897968) at gnetworkaddress.c:237
#4 0x00007f43f4271d0c in g_network_address_address_enumerator_next (enumerator=0x7f43dc005530, cancellable=0x7f43340082d0, error=0x7f4360ff87c8) at gnetworkaddress.c:912
#5 0x00007f43f428a4e0 in g_socket_address_enumerator_next (enumerator=0x7f43dc005530, cancellable=0x7f43340082d0, error=0x7f4360ff87c8) at gsocketaddressenumerator.c:83
#6 0x00007f43f427b766 in g_proxy_address_enumerator_next (enumerator=0x7f4340009940, cancellable=0x7f43340082d0, error=0x7f4360ff8980) at gproxyaddressenumerator.c:210
#7 0x00007f43f428a4e0 in g_socket_address_enumerator_next (enumerator=0x7f4340009940, cancellable=0x7f43340082d0, error=0x7f4360ff8980) at gsocketaddressenumerator.c:83
#8 0x00007f43f4272ca3 in g_network_monitor_base_can_reach (monitor=0x2818960, connectable=0x5cbce10, cancellable=0x7f43340082d0, error=0x7f4360ff8980) at gnetworkmonitorbase.c:194
#9 0x00007f43f427242b in g_network_monitor_can_reach (monitor=0x2818960, connectable=0x5cbce10, cancellable=0x7f43340082d0, error=0x7f4360ff8980) at gnetworkmonitor.c:139
#10 0x00007f43f485ebfa in camel_network_service_can_reach_sync (service=0x5ad0d70, cancellable=0x7f43340082d0, error=0x0) at camel-network-service.c:930
#11 0x00007f43f48898d5 in store_maybe_connect_sync (store=0x5ad0d70, cancellable=0x7f43340082d0, error=0x7f4360ff8b48) at camel-store.c:314
#12 0x00007f43f488c331 in camel_store_get_folder_info_sync (store=0x5ad0d70, top=0x0, flags=(CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_SUBSCRIBED), cancellable=0x7f43340082d0, error=0x7f4360ff8b48) at camel-store.c:1543
#13 0x00007f43f488c829 in store_get_folder_info_thread (task=0x69d41d0, source_object=0x5ad0d70, task_data=0x7297d00, cancellable=0x7f43340082d0) at camel-store.c:1676
#14 0x00007f43f4297a87 in g_task_thread_pool_thread (thread_data=0x69d41d0, pool_data=0x0) at gtask.c:1215
#15 0x00007f43f3cc8108 in g_thread_pool_thread_proxy (data=0x6815560) at gthreadpool.c:307
#16 0x00007f43f3cc7b2a in g_thread_proxy (data=0x7f43dc1b1ca0) at gthread.c:764
#17 0x000000324b80752a in start_thread (arg=0x7f4360ff9700) at pthread_create.c:310
#18 0x000000324ad0022d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
Version: 2.42.x