Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation Fault #82

Closed
jgeboski opened this issue May 6, 2016 · 4 comments
Closed

Segmentation Fault #82

jgeboski opened this issue May 6, 2016 · 4 comments
Labels

Comments

@jgeboski
Copy link
Member

jgeboski commented May 6, 2016

Program received signal SIGSEGV, Segmentation fault.
0xb7cbe9b4 in gnutls_bye () from /usr/lib/libgnutls.so.28
(gdb) bt
#0  0xb7cbe9b4 in gnutls_bye () from /usr/lib/libgnutls.so.28
#1  0x8003a773 in ssl_disconnect (conn_=0x80278c50) at ssl_gnutls.c:454
#2  0xb76605af in fb_mqtt_close (mqtt=0x800c0830) at facebook-mqtt.c:239
#3  0xb766018c in fb_mqtt_dispose (obj=0x800c0830) at facebook-mqtt.c:63
#4  0xb7439c14 in g_object_unref (_object=0x800c0830) at /var/tmp/portage/dev-libs/glib-2.48.0/work/glib-2.48.0/gobject/gobject.c:3146
#5  0xb745292d in g_signal_emit_valist (instance=instance@entry=0x800c0830, signal_id=signal_id@entry=15, detail=detail@entry=0, var_args=<optimized out>, var_args@entry=0xbffff098 "\240\311\"\200\374\360\377\277\240\320\034\200f\252\375\267\211lf\267\060\b\f\200") at /var/tmp/portage/dev-libs/glib-2.48.0/work/glib-2.48.0/gobject/gsignal.c:3344
#6  0xb74533a9 in g_signal_emit_by_name (instance=0x800c0830, detailed_signal=0xb7666c1d "error") at /var/tmp/portage/dev-libs/glib-2.48.0/work/glib-2.48.0/gobject/gsignal.c:3481
#7  0xb76606e6 in fb_mqtt_error (mqtt=0x800c0830, error=FB_MQTT_ERROR_GENERAL, format=0xb7666c89 "Connection timed out") at facebook-mqtt.c:264
#8  0xb7660750 in fb_mqtt_cb_timeout (data=0x800c0830, fd=-1, cond=(unknown: 0)) at facebook-mqtt.c:275
#9  0x80030172 in b_event_passthrough (fd=-1, event=1, data=0x80180538) at events_libevent.c:143
#10 0xb7dfa1a4 in event_process_active_single_queue () from /usr/lib/libevent-2.1.so.5
#11 0xb7dfae93 in event_base_loop () from /usr/lib/libevent-2.1.so.5
#12 0xb7dfb181 in event_base_dispatch () from /usr/lib/libevent-2.1.so.5
#13 0x80030031 in b_main_run () at events_libevent.c:84
#14 0x8002db7b in main (argc=3, argv=0xbffff4b4) at unix.c:172
@jgeboski jgeboski added the bug label May 6, 2016
@dequis
Copy link
Member

dequis commented May 9, 2016

Decent valgrind log thanks to aam:

==9651== Invalid free() / delete / delete[] / realloc()
==9651==    at 0x4C2EDEB: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9651==    by 0x1449BC: ssl_disconnect (ssl_gnutls.c:463)
==9651==    by 0x144741: ssl_handshake (ssl_gnutls.c:359)
==9651==    by 0x139CCB: gaim_io_invoke (events_glib.c:86)
==9651==    by 0x5390FD9: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.0)
==9651==    by 0x539137F: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.0)
==9651==    by 0x53916A1: g_main_loop_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.0)
==9651==    by 0x139C3B: b_main_run (events_glib.c:59)
==9651==    by 0x1375DC: main (unix.c:178)
==9651==  Address 0x7d66150 is 0 bytes inside a block of size 56 free'd
==9651==    at 0x4C2EDEB: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9651==    by 0x1449BC: ssl_disconnect (ssl_gnutls.c:463)
==9651==    by 0x83DEC19: fb_mqtt_close (facebook-mqtt.c:239)
==9651==    by 0x83DEC7F: fb_mqtt_dispose (facebook-mqtt.c:63)
==9651==    by 0x8BAFD24: g_object_unref (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.0)
==9651==    by 0x8BC5A11: g_signal_emit_valist (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.0)
==9651==    by 0x8BC6554: g_signal_emit_by_name (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.0)
==9651==    by 0x83DEDA0: fb_mqtt_error (facebook-mqtt.c:264)
==9651==    by 0x83DEF15: fb_mqtt_cb_open (facebook-mqtt.c:568)
==9651==    by 0x144735: ssl_handshake (ssl_gnutls.c:357)
==9651==    by 0x139CCB: gaim_io_invoke (events_glib.c:86)
==9651==    by 0x5390FD9: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.0)
==9651==  Block was alloc'd at
==9651==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9651==    by 0x5396700: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.0)
==9651==    by 0x143F6B: ssl_connect (ssl_gnutls.c:116)
==9651==    by 0x83DEFB5: fb_mqtt_open (facebook-mqtt.c:588)
==9651==    by 0x8BADDBD: g_cclosure_marshal_VOID__BOXEDv (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.0)
==9651==    by 0x8BAB1D3: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.0)
==9651==    by 0x8BC59A5: g_signal_emit_valist (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.0)
==9651==    by 0x8BC6554: g_signal_emit_by_name (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.4800.0)
==9651==    by 0x83DEDA0: fb_mqtt_error (facebook-mqtt.c:264)
==9651==    by 0x83DFC4D: fb_mqtt_cb_read (facebook-mqtt.c:358)
==9651==    by 0x139CCB: gaim_io_invoke (events_glib.c:86)
==9651==    by 0x5390FD9: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.0)

@dequis
Copy link
Member

dequis commented May 9, 2016

aam simulator 2016

diff --git a/lib/ssl_gnutls.c b/lib/ssl_gnutls.c
index d720095..9422340 100644
--- a/lib/ssl_gnutls.c
+++ b/lib/ssl_gnutls.c
@@ -344,16 +344,22 @@ static gboolean ssl_connected(gpointer data, gint source, b_input_condition cond
 static gboolean ssl_handshake(gpointer data, gint source, b_input_condition cond)
 {
    struct scd *conn = data;
    int st, stver;

    /* This function returns false, so avoid calling b_event_remove again */
    conn->inpa = -1;

+   if (rand() < (RAND_MAX * 0.5)) {
+       conn->func(conn->data, 0, NULL, cond);
+       ssl_disconnect(conn);
+       return FALSE;
+   }
+
    if ((st = gnutls_handshake(conn->session)) < 0) {
        if (st == GNUTLS_E_AGAIN || st == GNUTLS_E_INTERRUPTED) {
            conn->inpa = b_input_add(conn->fd, ssl_getdirection(conn),
                                     ssl_handshake, data);
        } else {
            conn->func(conn->data, 0, NULL, cond);

            ssl_disconnect(conn);

@andreimarcu
Copy link

ty

1 similar comment
@dequis
Copy link
Member

dequis commented May 9, 2016

ty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants