<<< Date Index >>>     <<< Thread Index >>>

Re: Segmentation fault



Hello Alex,
I have made another patch ready which should get rid of this damn
segfault. (The last you reported).

Attached are two patches:
        a) delta (A fix which should fit on top of your current tree)
        b) patch (A fix against CVS HEAD)

Please apply and report back. Oh and please always report all 'invalid
read of size bla' when the backtrace differs (the point where they
appear).

@Brendan: Had you time to look at the backtraces and/or the patches?
Maybe you can just see what the problem is by looking at the backtraces?

        Thomas
diff-tree 708cf3e7095f0349d9f8dae9ff737ea3c1e46a14 (from 
0b25885af664fbee411cb8bcb433f152ce73bc24)
Author: Thomas Glanzmann <sithglan@xxxxxxxxxxxxxxxxxxxx>
Date:   Thu May 19 09:48:50 2005 +0200
    
    Try to fix hcache segfault by killing all references to this key

diff --git a/imap/message.c b/imap/message.c
--- a/imap/message.c
+++ b/imap/message.c
@@ -470,7 +470,7 @@ int imap_fetch_message (MESSAGE *msg, CO
   if (ctx->subj_hash && h->env->real_subj)
     hash_delete (ctx->subj_hash, h->env->real_subj, h, NULL);
   if (ctx->thread_hash && h->env->message_id)
-    hash_delete (ctx->thread_hash, h->env->message_id, h, NULL);
+    hash_delete (ctx->thread_hash, h->env->message_id, NULL, NULL);
   mutt_free_envelope (&h->env);
   h->env = mutt_read_rfc822_header (msg->fp, h, 0, 0);
   if (ctx->id_hash && h->env->message_id)

--- a/hash.c
+++ b/hash.c
@@ -123,12 +123,16 @@
      * required for the case where we have multiple entries with the same
      * key
      */
+again:
     if ((data == ptr->data) || (!data && mutt_strcmp (ptr->key, key) == 0))
     {
       *last = ptr->next;
       if (destroy) destroy (ptr->data);
       FREE (&ptr);
-      return;
+      ptr = *last;
+      if (! ptr)
+        return;
+      goto again;
     }
   }
 }
--- a/imap/message.c
+++ b/imap/message.c
@@ -469,6 +469,8 @@
     hash_delete (ctx->id_hash, h->env->message_id, h, NULL);
   if (ctx->subj_hash && h->env->real_subj)
     hash_delete (ctx->subj_hash, h->env->real_subj, h, NULL);
+  if (ctx->thread_hash && h->env->message_id)
+    hash_delete (ctx->thread_hash, h->env->message_id, NULL, NULL);
   mutt_free_envelope (&h->env);
   h->env = mutt_read_rfc822_header (msg->fp, h, 0, 0);
   if (ctx->id_hash && h->env->message_id)
--- a/imap/util.c
+++ b/imap/util.c
@@ -138,11 +138,11 @@
     {
       *c = '\0';
       strfcpy (mx->account.user, tmp, sizeof (mx->account.user));
-      strfcpy (tmp, c+1, sizeof (tmp));
+      c++;
       mx->account.flags |= M_ACCT_USER;
     }
   
-    if ((n = sscanf (tmp, "%127[^:/]%127s", mx->account.host, tmp)) < 1)
+    if ((n = sscanf (c, "%127[^:/]%127s", mx->account.host, c)) < 1)
     {
       dprint (1, (debugfile, "imap_parse_path: NULL host in %s\n", path));
       FREE (&mx->mbox);
@@ -150,11 +150,11 @@
     }
   
     if (n > 1) {
-      if (sscanf (tmp, ":%hu%127s", &(mx->account.port), tmp) >= 1)
+      if (sscanf (c, ":%hu%127s", &(mx->account.port), c) >= 1)
        mx->account.flags |= M_ACCT_PORT;
-      if (sscanf (tmp, "/%s", tmp) == 1)
+      if (sscanf (c, "/%s", c) == 1)
       {
-       if (!ascii_strncmp (tmp, "ssl", 3))
+       if (!ascii_strncmp (c, "ssl", 3))
          mx->account.flags |= M_ACCT_SSL;
        else
        {