mono / mono

Mono open source ECMA CLI, C# and .NET implementation.
https://www.mono-project.com
Other
11.14k stars 3.82k forks source link

Problem with mailkit on raspbian mono #17891

Open RQuinve opened 4 years ago

RQuinve commented 4 years ago

Steps to Reproduce

Hello, I have a little program (c#) that works with Imap client (MailKit). This app works very well on my windows 10 x64. I want to use it on my raspberry pi 3+, but it hangs when it gets messages.

My app manage messages in my email box. Currently it gets configuration from web server, so there is no interaction with system. It get messages from a custom folder "My Anti-Spam/A_Bannir". If message is in black list, it deletes it.

Here is my test class:

`


internal class Toto { internal void Clean() { string serveurAdresse = "my_server"; int serveurPort = 993; bool useSsl = true; string utilisateur = "my_account"; string motDePasse = "my_password";

  try
  {
    using (ImapClient client = new ImapClient(new ProtocolLogger("mailkit.log")))
    //using (ImapClient client = new ImapClient())
    {
      // For demo-purposes, accept all SSL certificates
      client.ServerCertificateValidationCallback = (s, c, h, e1) => true;
      client.Timeout = 20000;
      //client.Connect(serveurAdresse, serveurPort, useSsl);

      if (useSsl)
      {
        client.Connect(serveurAdresse, serveurPort, SecureSocketOptions.SslOnConnect);
      }
      else
      {
        client.Connect(serveurAdresse, serveurPort, SecureSocketOptions.None);
      }

      if (!client.IsConnected)
      {
        return;
      }

      // Note: since we don't have an OAuth2 token, disable
      // the XOAUTH2 authentication mechanism.
      client.AuthenticationMechanisms.Remove("XOAUTH2");
      client.Authenticate(utilisateur, motDePasse);

if DEBUG

      if (client.Capabilities.HasFlag(ImapCapabilities.Id))
      {
        var clientImplementation = new ImapImplementation { Name = "MailKit", Version = "1.0" };
        var serverImplementation = client.Identify(clientImplementation);

        Console.WriteLine("Server implementation details:");

        foreach (var property in serverImplementation.Properties)
        {
          Console.WriteLine("  {0} = {1}", property.Key, property.Value);
        }
      }

endif

      // on définit la destination Inbox
      IMailFolder inbox = client.GetFolder("INBOX");

      // on définit la destination poubelle
      IMailFolder poubelle = client.GetFolder("Trash");

      // on traite le dossier à bannir
      ABannirProcess(client, inbox, poubelle);

      // on ouvre le dossier INBOX
      inbox.Open(FolderAccess.ReadWrite);

      // on traite le dossier réception
      //InboxProcess(client, inbox, poubelle);  <= disabled for the test

      client.Disconnect(true);
    }
  }
  catch (Exception ex)
  {
    Console.WriteLine(ex.Message);
  }
}

private void ABannirProcess(ImapClient client, IMailFolder inbox, IMailFolder poubelle)
{
  Console.WriteLine("00"); // to test where progression in my code

  // on définit le dossier à récupérer
  IMailFolder aBannir = client.GetFolder("My Anti-Spam/A_Bannir");
  aBannir.Open(FolderAccess.ReadWrite);

  Console.WriteLine("01");

  var range = new UniqueIdRange(UniqueId.MinValue, UniqueId.MaxValue);

  IList<UniqueId> uids = aBannir.Search(range, SearchQuery.NotSeen);

  // on quitte si la liste de ids est vide
  if (uids.Count == 0)
  {
    return;
  }

  Console.WriteLine("02");

  try
  {
    // get messages
    var items = aBannir.Fetch(uids, MessageSummaryItems.UniqueId | MessageSummaryItems.Envelope);

    Console.WriteLine("03");

    foreach (var item in items)
    {
      // get sender
      InternetAddressList froms = item.Envelope.From;

      foreach (InternetAddress ia in froms)
      {
        if (!(ia is MailboxAddress ma))
        {
          continue;
        }

        Console.WriteLine("04");

        // get sender address
        string adresse = ma.Address.ToLower();

        if (LesListes.IsInWhite(adresse))
        {
          aBannir.MoveTo(item.UniqueId, inbox);

if DEBUG

          Console.WriteLine("Adresse '{0}' remise dans le dossier de réception.", adresse);
          // message moved to reception

endif

          continue;
        }

        if (!LesListes.IsInBlack(adresse))
        {
          // on ajoute l'adresse dans la liste noire
          Expediteur exped = new Expediteur()
          {
            CompteId = 2,
            Adresse = adresse
          };

          Console.WriteLine("05");

          lock (LesListes.Noire)
          {
            LesListes.Noire.Add(exped);
          }

if DEBUG

          Console.WriteLine("Adresse '{0}' ajoutée à la liste noire.", adresse);

endif

        }

        Console.WriteLine("06");

        // don't currently move the message
        //aBannir.MoveTo(item.UniqueId, poubelle);

if DEBUG

        Console.WriteLine("Adresse '{0}' jetée à la poubelle.", adresse);

endif

      }
    }
  }
  catch (ImapCommandException ex)
  {
    Console.WriteLine(ex.Message);
  }

  aBannir.Close();

  // update remote server
  LesListes.SetServerLists();
}

}


`

Current Behavior

The app hangs at line

`


// get messages var items = aBannir.Fetch(uids, MessageSummaryItems.UniqueId | MessageSummaryItems.Envelope);


`

instead having messages

On which platforms did you notice this

[ ] macOS [X] Linux [ ] Windows

Versions

pi@raspberrypi:~/Documents/Test $ lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 9.11 (stretch) Release: 9.11 Codename: stretch

pi@raspberrypi:~/Documents/Test $ mono --version Mono JIT compiler version 4.6.2 (Debian 4.6.2.7+dfsg-1) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: normal SIGSEGV: normal Notifications: epoll Architecture: armel,vfp+hard Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: sgen

Tools version :

Visual studio 15.9.17 .Net Framework 4.7.1 MailKit.2.4.1 MimeKit 2.4.1 BouncyCastle 1.8.5

Stacktrace

Server implementation details:
  NAME = Zimbra
  VERSION = 7.2.0-GA2598
  RELEASE = 20160107134148
  USER = quinveros.raphael@free.fr
  SERVER = 96a935a9-1971-42c5-a488-172bd00125bf
00  <== my progression
01
02
Stacktrace:

  at <unknown> <0xffffffff>
  at System.Collections.Generic.Dictionary`2<string, int>.Insert (string,int,bool) <0x0006b>
  at System.Collections.Generic.Dictionary`2<string, int>.Add (string,int) <0x00027>
  at MimeKit.Utils.CharsetUtils.AddAliases (System.Collections.Generic.Dictionary`2<string, int>,int,int,string[]) <0x00077>
  at MimeKit.Utils.CharsetUtils..cctor () <0x001d3>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0x0006f>
  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) object.__icall_wrapper_mono_generic_class_init (intptr) <0x00037>
  at MimeKit.ParserOptions..ctor () <0x00077>
  at MimeKit.ParserOptions..cctor () <0x0005f>
  at (wrapper runtime-invoke) object.runtime_invoke_void (object,intptr,intptr,intptr) <0x0006f>
  at <unknown> <0xffffffff>
  at MimeKit.Utils.Rfc2047.DecodeText (byte[]) <0x00023>
  at MailKit.Net.Imap.ImapUtils/<ReadNStringTokenAsync>d__19.MoveNext () <0x0048b>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<string>.Start<MailKit.Net.Imap.ImapUtils/<ReadNStringTokenAsync>d__19> (MailKit.Net.Imap.ImapUtils/<ReadNStringTokenAsync>d__19&) <0x000d7>
  at MailKit.Net.Imap.ImapUtils.ReadNStringTokenAsync (MailKit.Net.Imap.ImapEngine,string,bool,bool,System.Threading.CancellationToken) <0x0014f>
  at MailKit.Net.Imap.ImapUtils/<ParseEnvelopeAsync>d__34.MoveNext () <0x00543>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<MailKit.Envelope>.Start<MailKit.Net.Imap.ImapUtils/<ParseEnvelopeAsync>d__34> (MailKit.Net.Imap.ImapUtils/<ParseEnvelopeAsync>d__34&) <0x000d7>
  at MailKit.Net.Imap.ImapUtils.ParseEnvelopeAsync (MailKit.Net.Imap.ImapEngine,bool,System.Threading.CancellationToken) <0x0011f>
  at MailKit.Net.Imap.ImapFolder/<FetchSummaryItemsAsync>d__150.MoveNext () <0x038a7>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<MailKit.Net.Imap.ImapFolder/<FetchSummaryItemsAsync>d__150> (MailKit.Net.Imap.ImapFolder/<FetchSummaryItemsAsync>d__150&) <0x000d7>
  at MailKit.Net.Imap.ImapFolder.FetchSummaryItemsAsync (MailKit.Net.Imap.ImapEngine,MailKit.Net.Imap.ImapCommand,int,bool) <0x0014b>
  at MailKit.Net.Imap.ImapEngine/<ProcessUntaggedResponseAsync>d__167.MoveNext () <0x01fe7>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<MailKit.Net.Imap.ImapUntaggedResult>.Start<MailKit.Net.Imap.ImapEngine/<ProcessUntaggedResponseAsync>d__167> (MailKit.Net.Imap.ImapEngine/<ProcessUntaggedResponseAsync>d__167&) <0x000d7>
  at MailKit.Net.Imap.ImapEngine.ProcessUntaggedResponseAsync (bool,System.Threading.CancellationToken) <0x00117>
  at MailKit.Net.Imap.ImapCommand/<StepAsync>d__68.MoveNext () <0x01e13>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>.Start<MailKit.Net.Imap.ImapCommand/<StepAsync>d__68> (MailKit.Net.Imap.ImapCommand/<StepAsync>d__68&) <0x000d7>
  at MailKit.Net.Imap.ImapCommand.StepAsync (bool) <0x00107>
  at MailKit.Net.Imap.ImapEngine/<IterateAsync>d__168.MoveNext () <0x00373>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<MailKit.Net.Imap.ImapEngine/<IterateAsync>d__168> (MailKit.Net.Imap.ImapEngine/<IterateAsync>d__168&) <0x0010b>
  at MailKit.Net.Imap.ImapEngine.IterateAsync (bool) <0x00163>
  at MailKit.Net.Imap.ImapEngine/<RunAsync>d__169.MoveNext () <0x00097>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<MailKit.Net.Imap.ImapEngine/<RunAsync>d__169> (MailKit.Net.Imap.ImapEngine/<RunAsync>d__169&) <0x000d7>
  at MailKit.Net.Imap.ImapEngine.RunAsync (MailKit.Net.Imap.ImapCommand,bool) <0x0011f>
  at MailKit.Net.Imap.ImapFolder/<FetchAsync>d__157.MoveNext () <0x003fb>
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<System.Collections.Generic.IList`1<MailKit.IMessageSummary>>.Start<MailKit.Net.Imap.ImapFolder/<FetchAsync>d__157> (MailKit.Net.Imap.ImapFolder/<FetchAsync>d__157&) <0x000d7>
  at MailKit.Net.Imap.ImapFolder.FetchAsync (System.Collections.Generic.IList`1<MailKit.UniqueId>,MailKit.MessageSummaryItems,bool,System.Threading.CancellationToken) <0x00147>
  at MailKit.Net.Imap.ImapFolder.Fetch (System.Collections.Generic.IList`1<MailKit.UniqueId>,MailKit.MessageSummaryItems,System.Threading.CancellationToken) <0x0003f>
  at Test.Toto.ABannirProcess (MailKit.Net.Imap.ImapClient,MailKit.IMailFolder,MailKit.IMailFolder) <0x00353>
  at Test.Toto.Clean () <0x004bb>
  at Test.Program.Main (string[]) <0x000c3>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <0x000cf>

Native stacktrace:

Debug info from gdb:

[New LWP 8346]
[New LWP 8347]
[New LWP 8348]
[New LWP 8349]
[New LWP 8350]
[New LWP 8351]
[New LWP 8352]
[New LWP 8353]
[New LWP 8354]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
0x76df451c in __waitpid (pid=8357, stat_loc=0x7ee32d98, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
29  ../sysdeps/unix/sysv/linux/waitpid.c: Aucun fichier ou dossier de ce type.
  Id   Target Id         Frame 
* 1    Thread 0x76f0b000 (LWP 8345) "Main" 0x76df451c in __waitpid (pid=8357, stat_loc=0x7ee32d98, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
  2    Thread 0x763ff470 (LWP 8346) "SGen worker" 0x76def9a4 in __pthread_cond_wait (cond=0x3258f0, mutex=0x3258bc) at pthread_cond_wait.c:188
  3    Thread 0x76a0b470 (LWP 8347) "Finalizer" 0x76df2068 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=1, futex_word=0x31d8c0) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
  4    Thread 0x740ff470 (LWP 8348) "Timer-Scheduler" 0x76defd3c in __pthread_cond_timedwait (cond=0x1c01710, mutex=0x1c016f4, abstime=0x740fe35c) at pthread_cond_timedwait.c:200
  5    Thread 0x74948470 (LWP 8349) "Main" 0x76defd3c in __pthread_cond_timedwait (cond=0x3260c0, mutex=0x3260a8, abstime=0x74947d54) at pthread_cond_timedwait.c:200
  6    Thread 0x73bff470 (LWP 8350) "Threadpool work" 0x76defd3c in __pthread_cond_timedwait (cond=0x1e6a050, mutex=0x1e6a080, abstime=0x73bfed60) at pthread_cond_timedwait.c:200
  7    Thread 0x73afe470 (LWP 8351) "Threadpool work" 0x76defd3c in __pthread_cond_timedwait (cond=0x1e6a050, mutex=0x1e6a080, abstime=0x73afdd60) at pthread_cond_timedwait.c:200
  8    Thread 0x74222470 (LWP 8352) "Threadpool work" 0x76d6c120 in poll () at ../sysdeps/unix/syscall-template.S:84
  9    Thread 0x735ff470 (LWP 8353) "Threadpool work" 0x76defd3c in __pthread_cond_timedwait (cond=0x1e6a050, mutex=0x1e6a080, abstime=0x735fed60) at pthread_cond_timedwait.c:200
  10   Thread 0x734fe470 (LWP 8354) "Threadpool work" 0x76defd3c in __pthread_cond_timedwait (cond=0x1e6a050, mutex=0x1e6a080, abstime=0x734fdd60) at pthread_cond_timedwait.c:200

Thread 10 (Thread 0x734fe470 (LWP 8354)):
#0  0x76defd3c in __pthread_cond_timedwait (cond=0x1e6a050, mutex=0x1e6a080, abstime=0x734fdd60) at pthread_cond_timedwait.c:200
#1  0x001918c0 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 9 (Thread 0x735ff470 (LWP 8353)):
#0  0x76defd3c in __pthread_cond_timedwait (cond=0x1e6a050, mutex=0x1e6a080, abstime=0x735fed60) at pthread_cond_timedwait.c:200
#1  0x001918c0 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 8 (Thread 0x74222470 (LWP 8352)):
#0  0x76d6c120 in poll () at ../sysdeps/unix/syscall-template.S:84
#1  0x00193504 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 7 (Thread 0x73afe470 (LWP 8351)):
#0  0x76defd3c in __pthread_cond_timedwait (cond=0x1e6a050, mutex=0x1e6a080, abstime=0x73afdd60) at pthread_cond_timedwait.c:200
#1  0x001918c0 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 6 (Thread 0x73bff470 (LWP 8350)):
#0  0x76defd3c in __pthread_cond_timedwait (cond=0x1e6a050, mutex=0x1e6a080, abstime=0x73bfed60) at pthread_cond_timedwait.c:200
#1  0x001918c0 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 5 (Thread 0x74948470 (LWP 8349)):
#0  0x76defd3c in __pthread_cond_timedwait (cond=0x3260c0, mutex=0x3260a8, abstime=0x74947d54) at pthread_cond_timedwait.c:200
#1  0x002488f4 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 4 (Thread 0x740ff470 (LWP 8348)):
#0  0x76defd3c in __pthread_cond_timedwait (cond=0x1c01710, mutex=0x1c016f4, abstime=0x740fe35c) at pthread_cond_timedwait.c:200
#1  0x0021caf8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 3 (Thread 0x76a0b470 (LWP 8347)):
#0  0x76df2068 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=1, futex_word=0x31d8c0) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  do_futex_wait (sem=sem@entry=0x31d8c0, abstime=0x0) at sem_waitcommon.c:115
#2  0x76df21ac in __new_sem_wait_slow (sem=0x31d8c0, abstime=0x0) at sem_waitcommon.c:282
#3  0x001ac174 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 2 (Thread 0x763ff470 (LWP 8346)):
#0  0x76def9a4 in __pthread_cond_wait (cond=0x3258f0, mutex=0x3258bc) at pthread_cond_wait.c:188
#1  0x002158e8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 0x76f0b000 (LWP 8345)):
#0  0x76df451c in __waitpid (pid=8357, stat_loc=0x7ee32d98, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:29
#1  0x000bbb44 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Abandon

Can you help me please?

Regards

Raphaël

directhex commented 4 years ago

That's a very, very old version of Mono. Can you try updating?

RQuinve commented 4 years ago

Hi, Thank you for your response. I am surprised because I just typed : sudo apt-get install mono-complete So where is my problem please ?

Regards.

Raphaël

⁣Télécharger TypeApp pour Android ​

Le 25 nov. 2019 16:05, à 16:05, Jo Shields notifications@github.com a écrit:

That's a very, very old version of Mono. Can you try updating?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/mono/mono/issues/17891#issuecomment-558195865

directhex commented 4 years ago

Follow the download instructions on mono-project.com to download our latest builds, not the version in your distribution repository (which may be several years old)

RQuinve commented 4 years ago

Ok. Thank you very much.

Raphaël.

⁣Télécharger TypeApp pour Android ​

Le 25 nov. 2019 18:49, à 18:49, Jo Shields notifications@github.com a écrit:

Follow the download instructions on mono-project.com to download our latest builds, not the version in your distribution repository (which may be several years old)

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/mono/mono/issues/17891#issuecomment-558266463