<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [GTK][Stable] Crashes when SoupSession is destroyed in exit handler"
href="https://bugs.webkit.org/show_bug.cgi?id=145347">145347</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[GTK][Stable] Crashes when SoupSession is destroyed in exit handler
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>528+ (Nightly build)
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>WebKit Gtk
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mcatanzaro@igalia.com
</td>
</tr></table>
<p>
<div>
<pre>We have a couple downstream reports of crashes that occur when g_object_unref destroys a SoupSession in an exit handler. E.g.
Truncated backtrace:
Thread no. 1 (10 frames)
#0 free at /lib64/libc.so.6
#1 _gnutls_free_dh_info at /lib64/libgnutls.so.28
#2 _gnutls_free_auth_info at /lib64/libgnutls.so.28
#3 gnutls_deinit at /lib64/libgnutls.so.28
#4 g_tls_connection_gnutls_finalize at /usr/lib64/gio/modules/libgiognutls.so
#6 soup_io_stream_finalize at /lib64/libsoup-2.4.so.1
#8 soup_socket_finalize at /lib64/libsoup-2.4.so.1
#10 soup_connection_disconnect at /lib64/libsoup-2.4.so.1
#11 soup_session_abort at /lib64/libsoup-2.4.so.1
#12 soup_session_dispose at /lib64/libsoup-2.4.so.1
(Truncated, but soup_session_dispose is called by g_object_unref is called by __run_exit_handlers.)
I spent some time checking libsoup, WebKit, Epiphany, and even GLib for all uses of atexit and on_exit, but didn't find anything suspicious. So my suspicion falls on SoupNetworkSession::defaultSession(). I guess that will be destroyed in an exit handler because it is static? Maybe we should leak it using NeverDestroyed<SoupNetworkSession> instead? This is kind of wild speculation, but it seems reasonable....
We have another backtrace where __run_exit_handlers calls g_object_unref calls soup_session_dispose (as in the backtrace above), then soup_session_dispose calls g_source_destroy calls g_source_destroy_internal calls g_mutex_lock, then boom. That surely is happening because the mutex is already locked, so it's some thread-safety issue for sure.
Full backtraces downstream (in the See Also field).</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>