himalaya icon indicating copy to clipboard operation
himalaya copied to clipboard

panic during envelope listing when envelope contains non-ASCII char

Open echo-bravo-yahoo opened this issue 1 year ago • 20 comments

~ ❯ himalaya
Cannot find configuration at /Users/REDACTED/Library/Application Support/himalaya/config.toml.
> Would you like to create one with the wizard? Yes

Configuring your default account

> Email address: [email protected]
> Account name: gmail
> Full display name: REDACTED
> Downloads directory: ~/Downloads

Warning: Google passwords cannot be used directly, see:
https://github.com/pimalaya/himalaya?tab=readme-ov-file#configuration

> Default backend: IMAP
> IMAP hostname: imap.gmail.com
> IMAP encryption: SSL/TLS
> IMAP port: 993
> IMAP login: [email protected]
> IMAP authentication strategy: Ask my password, then save it in the configuration file (not safe)
> IMAP password: REDACTED
> Backend for sending messages: SMTP
> SMTP hostname: smtp.gmail.com
> SMTP encryption: SSL/TLS
> SMTP port: 465
> SMTP login: [email protected]
> SMTP authentication strategy: Ask my password, then save it in the configuration file (not safe)
> SMTP password: REDACTED
> Where to save the configuration? /Users/REDACTED/Library/Application Support/himalaya/config.toml
Writing configuration to /Users/REDACTED/Library/Application Support/himalaya/config.toml…
Done! Exiting the wizard…

The application panicked (crashed).
Message:  assertion failed: self.is_char_boundary(new_len)
Location: /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/string.rs:1407
~ ❯ himalaya accounts list                                                                               task !2/385

| NAME                               | BACKENDS                               | DEFAULT                             |
|------------------------------------|----------------------------------------|-------------------------------------|
| gmail                              | IMAP, SMTP                             | yes                                 |
~ ❯ himalaya

The application panicked (crashed).
Message:  assertion failed: self.is_char_boundary(new_len)
Location: /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/string.rs:1407

echo-bravo-yahoo avatar Nov 07 '24 19:11 echo-bravo-yahoo

Looks like a char is breaking the table system managed by comfy-table. Could you try to identify which one by playing with pagination --page-size 1 and --page?

soywod avatar Nov 11 '24 20:11 soywod

i can no longer reproduce using the version installed from github - either the bug's fixed, or the problematic email's fallen out of my inbox. i'll keep an eye out for this in the future, but closing for now.

echo-bravo-yahoo avatar Nov 17 '24 14:11 echo-bravo-yahoo

Do you remember by any chance some subject with special char? Or an emoji?

soywod avatar Nov 17 '24 20:11 soywod

Regrettably, no, and moving a chunk of thing from archive back to inbox did not reproduce. I'll reply here if I can repro in the future!

echo-bravo-yahoo avatar Nov 18 '24 18:11 echo-bravo-yahoo

I just got this error from Himalaya and I'm quite confused as the resulting file doesn't seem to contain any special characters outside ASCII. Here's the full backtrace:

The application panicked (crashed).
Message:  assertion failed: self.is_char_boundary(new_len)
Location: /private/tmp/rust-20241128-8064-v5d6qj/rustc-1.83.0-src/library/alloc/src/string.rs:1472

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 9 frames hidden ⋮
  10: core::panicking::panic::h9889520f556572c5
      at <unknown source file>:<unknown line>
  11: comfy_table::utils::formatting::content_format::format_row::h67a0e3142574c94a
      at <unknown source file>:<unknown line>
  12: comfy_table::utils::formatting::content_format::format_content::hb5b881fb511b6da2
      at <unknown source file>:<unknown line>
  13: comfy_table::utils::build_table::hbd151f5ec2f6f694
      at <unknown source file>:<unknown line>
  14: <comfy_table::table::Table as core::fmt::Display>::fmt::h0c1d9e6a112bf7aa
      at <unknown source file>:<unknown line>
  15: core::fmt::write::h40c2acd4666eb4d3
      at <unknown source file>:<unknown line>
  16: <pimalaya_tui::himalaya::config::EnvelopesTable as core::fmt::Display>::fmt::h315768dee37fdfac
      at <unknown source file>:<unknown line>
  17: core::fmt::write::h40c2acd4666eb4d3
      at <unknown source file>:<unknown line>
  18: <&std::io::stdio::Stdout as std::io::Write>::write_fmt::h93e115a4222d5ee0
      at <unknown source file>:<unknown line>
  19: <std::io::stdio::Stdout as std::io::Write>::write_fmt::h799426fa44dcc531
      at <unknown source file>:<unknown line>
  20: <pimalaya_tui::terminal::cli::printer::StdoutPrinter as pimalaya_tui::terminal::cli::printer::Printer>::out::hf3d6c922225ef7d9
      at <unknown source file>:<unknown line>
  21: himalaya::email::envelope::command::list::EnvelopeListCommand::execute::{{closure}}::h482f2e0b44508598
      at <unknown source file>:<unknown line>
  22: tokio::runtime::park::CachedParkThread::block_on::h7e96193c5fb85341
      at <unknown source file>:<unknown line>
  23: tokio::runtime::context::runtime::enter_runtime::h7d85df5fa09ad85a
      at <unknown source file>:<unknown line>
  24: himalaya::main::h574575333fd0f3b6
      at <unknown source file>:<unknown line>
  25: std::sys::backtrace::__rust_begin_short_backtrace::h6af89625baf75aa1
      at <unknown source file>:<unknown line>
  26: std::rt::lang_start::{{closure}}::h19f1674ba8d457f5
      at <unknown source file>:<unknown line>
  27: std::rt::lang_start_internal::hadea728b8c40134b
      at <unknown source file>:<unknown line>
  28: _main<unknown>
      at <unknown source file>:<unknown line>

Update: I was able to reliably reproduce this by setting the terminal width under 100 characters, which causes the comfy_table to panic.

BasixKOR avatar Dec 21 '24 08:12 BasixKOR

Update: I was able to reliably reproduce this by setting the terminal width under 100 characters, which causes the comfy_table to panic.

No matter the content, do you confirm?

soywod avatar Dec 24 '24 01:12 soywod

No matter the content, do you confirm?

Oops, yeah I missed that I had some CJK titled messages coming in. It seems like comfy_table is unable to calculate the width properly when Unicode letters are involved. When only ASCII characters are displayed the bug wasn't reproducible.

BasixKOR avatar Dec 31 '24 12:12 BasixKOR

@BasixKOR

Can you print the content of the table that breaks when squashed into a narrow terminal? Best case scenario would be a minimal reproducable input.

Furthermore, it would be good to know which OS you're on and maybe even what terminal emulator you're using.

What's interesting is, is that that panic doesn't originate from inside comfy-table but rather from inside the standard library on self.is_char_boundary(new_len) even though the content doesn't have any UTF-8 symbols. Are the borders utf-8 chars?

Nukesor avatar Jan 01 '25 14:01 Nukesor

@Nukesor not the person you asked, but I have a repro for you:

-> % stty size
34 100

-> % himalaya envelope list --page-size 1 --page 1
2025-01-17T08:36:03.483020Z  WARN imap_codec::response: Rectified missing `text` to "..."
2025-01-17T08:36:03.483457Z  WARN imap_client::tasks::resolver: received unsolicited unsolicited=Status(Untagged(StatusBody { kind: Ok, code: Some(Other(CodeOther(b"HIGHESTMODSEQ 15570725"))), text: Text("...") }))
2025-01-17T08:36:03.484561Z  WARN imap_client::tasks::tasks::select: missing required UNSEEN OK untagged response

The application panicked (crashed).
Message:  assertion failed: self.is_char_boundary(new_len)
Location: /private/tmp/rust-20250109-8032-r89n27/rustc-1.84.0-src/library/alloc/src/string.rs:1472
-> % stty size
34 150

-> % himalaya envelope list --page-size 1 --page 1
2025-01-17T08:35:47.049700Z  WARN imap_codec::response: Rectified missing `text` to "..."
2025-01-17T08:35:47.050056Z  WARN imap_client::tasks::resolver: received unsolicited unsolicited=Status(Untagged(StatusBody { kind: Ok, code: Some(Other(CodeOther(b"HIGHESTMODSEQ 15570725"))), text: Text("...") }))
2025-01-17T08:35:47.050702Z  WARN imap_client::tasks::tasks::select: missing required UNSEEN OK untagged response

| ID              | FLAGS          | SUBJECT                                               | FROM                   | DATE                           |
|-----------------|----------------|-------------------------------------------------------|------------------------|--------------------------------|
| 106443          |  *             | 【九州温泉特集】5,200円~!心と身体に安らぎを         | さくらトラベル         | 2025-01-17 17:19+09:00         |
  • Subject: 【九州温泉特集】5,200円~!心と身体に安らぎを
  • From: さくらトラベル
  • macOS 15.2
  • Ghostty 1.0.1 (also confirmed on Terminal 2.14 / iTrem2 3.4.15)
  • himalaya v1.1.0 +maildir +sendmail +pgp-commands +wizard +smtp +imap; build: macos aarch64; git: unknown, rev unknown

uasi avatar Jan 17 '25 08:01 uasi

Hello, looks like the issue still occurs, but not always reproducible. The issue was on some of email in Polish language. After opening it in gmail the issue stopped occuring entirely. Then I marked this email as unread but couldn't reproduce it later.

Here is my command on this email (that now looks like it works): [nix-shell:~]$ himalaya envelope list --page-size 1 --page 7 --trace

Part of the output: Image

Not sure if it will help now, if I will get the issue once again, I will try to retrieve some more logs without trying to "read" in gmail.

Terminal size doesn't matter from my tests.

My system:

  • NixOS (kernel 6.17)
  • KDE
  • Alacritty terminal emulator

wazart0 avatar Oct 27 '25 19:10 wazart0

In terminal history I managed to find the preliminary error mentioned in post.

Command: [nix-shell:~]$ himalaya --trace

Here are the logs:

...
2025-10-27T19:01:56.150783Z DEBUG list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}: email::imap: client 1/1 is free, locking it
2025-10-27T19:01:56.150809Z DEBUG list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}: email::email::envelope::list::imap: UTF7-encoded mailbox name="INBOX"
2025-10-27T19:01:56.150858Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:select_mailbox{client=1}: imap_client::tasks: enqueue task command=Command { tag: Tag("0.2.UXQsFgCP"), body: Select { mailbox: Inbox } }
2025-10-27T19:01:56.150941Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:select_mailbox{client=1}: imap_client::stream: wrote 27/27 bytes
2025-10-27T19:01:56.393763Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:select_mailbox{client=1}: imap_client::stream: read 408/1024 bytes
2025-10-27T19:01:56.393888Z  WARN list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:select_mailbox{client=1}: imap_codec::response: Rectified missing `text` to "..."
2025-10-27T19:01:56.393903Z  WARN list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:select_mailbox{client=1}: imap_client::tasks::resolver: received unsolicited unsolicited=Status(Untagged(StatusBody { kind: Ok, code: Some(Other(CodeOther(b"HIGHESTMODSEQ 5313967"))), text: Text("...") }))
2025-10-27T19:01:56.393952Z  WARN list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:select_mailbox{client=1}: imap_client::tasks::tasks::select: missing required UNSEEN OK untagged response
2025-10-27T19:01:56.393975Z DEBUG list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}: email::email::envelope::list::imap: mailbox selected name="INBOX" data=SelectDataUnvalidated { flags: Some([Answered, Flagged, Draft, Deleted, Seen, Keyword(Atom("$NotPhishing")), Keyword(Atom("$Phishing")), Keyword(Atom("Junk")), Keyword(Atom("NonJunk"))]), exists: Some(34706), recent: Some(0), unseen: None, permanent_flags: Some([Flag(Answered), Flag(Flagged), Flag(Draft), Flag(Deleted), Flag(Seen), Flag(Keyword(Atom("$NotPhishing"))), Flag(Keyword(Atom("$Phishing"))), Flag(Keyword(Atom("Junk"))), Flag(Keyword(Atom("NonJunk"))), Asterisk]), uid_next: Some(54281), uid_validity: Some(641540847) }
2025-10-27T19:01:56.394031Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::tasks: enqueue task command=Command { tag: Tag("0.3.HLTT3Fem"), body: Fetch { sequence_set: SequenceSet([Range(Value(34706), Value(34697))]+), macro_or_item_names: MessageDataItemNames([Uid, Flags, Envelope, BodyStructure]), uid: false } }
2025-10-27T19:01:56.394121Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: wrote 67/67 bytes
2025-10-27T19:01:56.551224Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 514/1024 bytes
2025-10-27T19:01:56.551268Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.551515Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 1024/1024 bytes
2025-10-27T19:01:56.551628Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.551636Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 2/1024 bytes
2025-10-27T19:01:56.551645Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.552692Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 1024/1024 bytes
2025-10-27T19:01:56.552861Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.552873Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 354/1024 bytes
2025-10-27T19:01:56.552900Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.552973Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 672/1024 bytes
2025-10-27T19:01:56.553019Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.554730Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 1024/1024 bytes
2025-10-27T19:01:56.554770Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.554775Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 354/1024 bytes
2025-10-27T19:01:56.554796Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.554977Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 1024/1024 bytes
2025-10-27T19:01:56.555001Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.555006Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 354/1024 bytes
2025-10-27T19:01:56.555011Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.555746Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 1024/1024 bytes
2025-10-27T19:01:56.555829Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.555840Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 318/1024 bytes
2025-10-27T19:01:56.555849Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: more input needed
2025-10-27T19:01:56.558302Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}:fetch_envelopes_by_sequence{client=1}: imap_client::stream: read 44/1024 bytes
2025-10-27T19:01:56.558520Z DEBUG list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}: email::email::envelope::list::imap: found 10 imap envelopes
2025-10-27T19:01:56.558528Z TRACE list_envelopes{folder="INBOX" opts=ListEnvelopesOptions { page_size: 10, page: 0, query: None }}: email::email::envelope::list::imap: Envelopes(
    [
        Envelope {
            id: "54280",
            message_id: "<[email protected]>",
            in_reply_to: None,
            flags: Flags(
                {},
            ),
            from: Address {
                name: Some(
                    "Google",
                ),
                addr: "[email protected]",
            },
            to: Address {
                name: None,
                addr: "[email protected]",
            },
            subject: "Security alert",
            date: 2025-10-27T18:59:15+00:00,
            has_attachment: false,
        },
        Envelope {
            id: "54279",
            message_id: "<CAP90qEuJ9Ga_iypbN3Kku=XsHt4FWgKs0zQoMyApJXL4G01=vg@mail.gmail.com>",
            in_reply_to: None,
            flags: Flags(
                {},
            ),
            from: Address {
                name: Some(
                    "Priyanshu Agarwal",
                ),
                addr: "[email protected]",
            },
            to: Address {
                name: None,
                addr: "[email protected]",
            },
            subject: "[robotics-worldwide]  [jobs] Postdoctoral Fellow - Wearable Robotics",
            date: 2025-10-27T22:41:42+05:30,
            has_attachment: false,
        },
        Envelope {
            id: "54277",
            message_id: "<CACsiDzydpf9HFT+uZ3zNnQ_V9YW35N3EsvQU4FVRAFF82bHYRQ@mail.gmail.com>",
            in_reply_to: None,
            flags: Flags(
                {},
            ),
            from: Address {
                name: Some(
                    "Mahdi Tavakoli",
                ),
                addr: "[email protected]",
            },
            to: Address {
                name: None,
                addr: "[email protected]",
            },
            subject: "[robotics-worldwide] [meetings] [CFP] IEEE BioRob 2026 | 1-4 August 2026 | Edmonton, Canada | Call for Papers and Workshop/Tutorial Proposals",
            date: 2025-10-27T10:30:53-06:00,
            has_attachment: false,
        },
        Envelope {
            id: "54274",
            message_id: "<[email protected]>",
            in_reply_to: None,
            flags: Flags(
                {},
            ),
            from: Address {
                name: Some(
                    "Portfel Tradera",
                ),
                addr: "[email protected]",
            },
            to: Address {
                name: None,
                addr: "[email protected]",
            },
            subject: "Jak bezpiecznie przechowywać swoje środki? - nowe nagranie z sesji Q&A już dostępne",
            date: 2025-10-27T17:02:07+01:00,
            has_attachment: false,
        },
        Envelope {
            id: "54273",
            message_id: "<[email protected]>",
            in_reply_to: None,
            flags: Flags(
                {},
            ),
            from: Address {
                name: Some(
                    "Google Alerts",
                ),
                addr: "[email protected]",
            },
            to: Address {
                name: None,
                addr: "[email protected]",
            },
            subject: "Google Alert - satellite procurement",
            date: 2025-10-27T08:42:33-07:00,
            has_attachment: false,
        },
        Envelope {
            id: "54272",
            message_id: "<fFONsdw2EKrLmQC6t_qRHZ82FkdXL4B5DjSlhkWEaflSHWqFFw8AYON3JtZG_XqXe48sRoQjaHGKjLmBhJnf4lyukC2vPV1F_KRmNtXCgwivfI_uGS-8OOeCNmUIBXMMzoapwia6AAECAA==@t1.msgid.quoramail.com>",
            in_reply_to: None,
            flags: Flags(
                {},
            ),
            from: Address {
                name: Some(
                    "Quora Digest",
                ),
                addr: "[email protected]",
            },
            to: Address {
                name: None,
                addr: "[email protected]",
            },
            subject: "What is socially acceptable in Denmark that would be horrifying in the U.S.?",
            date: 2025-10-27T15:41:06+00:00,
            has_attachment: false,
        },
        Envelope {
            id: "54271",
            message_id: "<[email protected]>",
            in_reply_to: None,
            flags: Flags(
                {},
            ),
            from: Address {
                name: Some(
                    "Portfel Tradera",
                ),
                addr: "[email protected]",
            },
            to: Address {
                name: None,
                addr: "[email protected]",
            },
            subject: "Choroby, badania, suplementacja - nowe nagranie z sesji Q&A już dostępne",
            date: 2025-10-27T13:40:08+01:00,
            has_attachment: false,
        },
        Envelope {
            id: "54278",
            message_id: "<[email protected]>",
            in_reply_to: None,
            flags: Flags(
                {},
            ),
            from: Address {
                name: Some(
                    "NAGEOTTE Florent",
                ),
                addr: "[email protected]",
            },
            to: Address {
                name: None,
                addr: "[email protected]",
            },
            subject: "[robotics-worldwide] [News] Application open for HealthTech Master's track with fellowships at the University of Strasbourg",
            date: 2025-10-27T12:28:58+01:00,
            has_attachment: false,
        },
        Envelope {
            id: "54276",
            message_id: "<[email protected]>",
            in_reply_to: None,
            flags: Flags(
                {},
            ),
            from: Address {
                name: Some(
                    "Quentin Peyron",
                ),
                addr: "[email protected]",
            },
            to: Address {
                name: None,
                addr: "[email protected]",
            },
            subject: "[robotics-worldwide] [Jobs] 2 master internships and 1 PhD position in soft robotics and HMI at Inria Lille, France",
            date: 2025-10-27T10:28:37+01:00,
            has_attachment: false,
        },
        Envelope {
            id: "54275",
            message_id: "<[email protected]>",
            in_reply_to: None,
            flags: Flags(
                {},
            ),
            from: Address {
                name: Some(
                    "Morten Fjeld",
                ),
                addr: "[email protected]",
            },
            to: Address {
                name: Some(
                    "[email protected]",
                ),
                addr: "[email protected]",
            },
            subject: "[robotics-worldwide]  [Jobs] Postdoc Opportunity at the University of Bergen, Norway",
            date: 2025-10-27T08:31:09+00:00,
            has_attachment: false,
        },
    ],
)

The application panicked (crashed).
Message:  assertion failed: self.is_char_boundary(new_len)
Location: /build/rustc-1.86.0-src/library/alloc/src/string.rs:1472

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 7 frames hidden ⋮
   8: core::panicking::panic::he6cc393dce485baf
      at <unknown source file>:<unknown line>
   9: comfy_table::utils::formatting::content_format::format_row::hb93a8f585b42ba8e
      at <unknown source file>:<unknown line>
  10: comfy_table::utils::formatting::content_format::format_content::h1b6fd38f199977fb
      at <unknown source file>:<unknown line>
  11: comfy_table::utils::build_table::hb255914d60a95a9f
      at <unknown source file>:<unknown line>
  12: <comfy_table::table::Table as core::fmt::Display>::fmt::haf9ed5a2e5d1bfcc
      at <unknown source file>:<unknown line>
  13: core::fmt::write::h7b1248e5e0c79c78
      at <unknown source file>:<unknown line>
  14: <pimalaya_tui::himalaya::config::EnvelopesTable as core::fmt::Display>::fmt::hf9b3cb4508087433
      at <unknown source file>:<unknown line>
  15: core::fmt::write::h7b1248e5e0c79c78
      at <unknown source file>:<unknown line>
  16: <&std::io::stdio::Stdout as std::io::Write>::write_fmt::h916d2f215fc915d5
      at <unknown source file>:<unknown line>
  17: <std::io::stdio::Stdout as std::io::Write>::write_fmt::hd2733370ba29cf97
      at <unknown source file>:<unknown line>
  18: <pimalaya_tui::terminal::cli::printer::StdoutPrinter as pimalaya_tui::terminal::cli::printer::Printer>::out::hf39f371b0e3d9690
      at <unknown source file>:<unknown line>
  19: himalaya::email::envelope::command::list::EnvelopeListCommand::execute::{{closure}}::hc6362119c6818b93
      at <unknown source file>:<unknown line>
  20: tokio::runtime::park::CachedParkThread::block_on::h5dfa71a4de2a2f65
      at <unknown source file>:<unknown line>
  21: tokio::runtime::context::runtime::enter_runtime::h4bd7e30ea92f1cf6
      at <unknown source file>:<unknown line>
  22: tokio::runtime::runtime::Runtime::block_on::h0b5b03060489dc40
      at <unknown source file>:<unknown line>
  23: himalaya::main::h526c634094d82a70
      at <unknown source file>:<unknown line>
  24: std::sys::backtrace::__rust_begin_short_backtrace::h60f37a6d200aa12d
      at <unknown source file>:<unknown line>
  25: std::rt::lang_start::{{closure}}::he7c4f89fd8779771
      at <unknown source file>:<unknown line>
  26: std::rt::lang_start_internal::he3cad277a2bdfe30
      at <unknown source file>:<unknown line>
  27: main<unknown>
      at <unknown source file>:<unknown line>
  28: __libc_start_call_main<unknown>
      at <unknown source file>:<unknown line>
  29: __libc_start_main_alias_1<unknown>
      at <unknown source file>:<unknown line>
  30: _start<unknown>
      at <unknown source file>:<unknown line>

[nix-shell:~]$

Hopefully this will help.

wazart0 avatar Oct 27 '25 19:10 wazart0

Could be interesting to bump comfy-table to the latest version and see if the issue still occurs with your data. What you can do meanwhile is to install Himalaya from sources and bump comfy-table manually from within a [patch.crates-io] inside Cargo.toml. Sth like:

[patch.crates-io]
comfy-table = "7.2.1"

soywod avatar Oct 27 '25 21:10 soywod

Hm. Nothing really significant changed from v7.2.0 to v7.2.1, so if that happened on v7.2.0, it's probably a bug.

Tbh. I don't really know how to debug this, as this seems to only trigger in very specific circumstances 🤔 . I tried to break comfy-table with a few tests based on that polish mail subject, but I couldn't reproduce the issue :|

As far as I can see, there're no other emojis/non-ascii UTF-8 chars displayed anywhere else in that table, right? So it has to be that mail subject?

Nukesor avatar Oct 28 '25 00:10 Nukesor

The actual version on master is the v7.1.4, it may not contain your last fix?

https://github.com/pimalaya/himalaya/blob/cf008c0ca7aec69e3263c63e7adbbed9e380c549/Cargo.lock#L701-L702

As far as I can see, there're no other emojis/non-ascii UTF-8 chars displayed anywhere else in that table, right? So it has to be that mail subject?

Technically you can have it in the email name ("Hello 🌞" <[email protected]>), so it could break the FROM column.

soywod avatar Oct 28 '25 07:10 soywod

To be honest, now i can use himalaya without issues, as I wrote, after opening the problematic mail in gmail I do not have any issues 🙃. Just logged it to give you full details.

Anyway, maybe there is some way to make some workaround or use other lib in the future to make it working no matter the character. I will take a look in some free time if i can propose some solution. If I get the issue next time, I will try to debug it.

wazart0 avatar Oct 28 '25 07:10 wazart0

The actual version on master is the v7.1.4, it may not contain your last fix?

Yeah, that should be fine as well. 7.2 only bumped to Rust 2024 edition and updated crossterm. The UTF-8 grapheme handling was all done in 7.1.4.

I have a feeling that this will be a tough one. There seems to be a very specific edge-case where grapheme splitting doesn't work as expected. The source for this could be in comfy-table or in unicode-width/unicode-segmentation, although I assume comfy-table as a source for now.

@soywod 👍. So it looks like it had to somehow be that polish string. Weeeird. I cannot reproduce it. What's bugging me the most is that, according to @wazart0, it's unrelated to table width. That would mean that this happens even if no splitting takes place.

Nukesor avatar Oct 28 '25 10:10 Nukesor

@Nukesor maybe it has to be very specific table width where the split is being done. I haven't tested every possible position, like increase width by one, check if crash, etc... Just checked 4-5 widths.

If I will get the issue again, I will look at it try to retrieve some more useful info and get back to you. At the moment I will keep version from Nix repo (https://search.nixos.org/packages?channel=25.05&query=himalaya) as it works perfectly now for the time being. If the problem occur again, it will be much easier to find the root cause.

wazart0 avatar Oct 28 '25 11:10 wazart0

I also added a test that checks whether things break with the same setup as pimalaya tui (https://github.com/pimalaya/tui/blob/master/src/himalaya/config.rs#L1328)

That test checks that all tables render correctly, based on your provided input, between 0-300 chars width.

That didn't catch anything though.

Maybe it really is something that has been fixed in the meantime in the upstream unicode crates, although I couldn't find a bugfix while skimming their latest releases.

Nukesor avatar Oct 28 '25 11:10 Nukesor

@wazart0 where did you get the previous version from that failed :)? I.e. how did you install that one and what version was it?

This could help us pin down any potential dependency discrepancies

Nukesor avatar Oct 31 '25 00:10 Nukesor

@Nukesor its not the newest, i took it from nix packages: https://search.nixos.org/packages?channel=25.05&query=himalaya

[art@v7nix:~]$ himalaya --version
himalaya v1.1.0 +maildir +sendmail +imap +pgp-commands +wizard +smtp
build: linux gnu x86_64
git: unknown, rev unknown

I haven't had any issues with the app since then. So I believe it is some kind of freaking edge case.

wazart0 avatar Oct 31 '25 11:10 wazart0