Closed Bug 2091482 Opened 17 days ago Closed 16 days ago

MIME stream initialization failures are incorrectly reported as out of memory

Categories

(MailNews Core :: MIME, defect)

Thunderbird 81
defect

Tracking

(Not tracked)

RESOLVED FIXED
162 Branch

People

(Reporter: welpy-cw, Assigned: welpy-cw)

References

Details

Attachments

(1 external file)

This is a separate follow-up to bug 2088260.

When MIME stream initialization fails, nsStreamConverter::Init() reports NS_ERROR_OUT_OF_MEMORY regardless of the underlying error. This obscures failures such as message-service lookup or message URL resolution and makes compose failures difficult to diagnose.

Bug 2088260 fixed the escaped IMAP folder lookup that triggered the original forwarding failure. The MIME error reporting issue remains independently of that fix.

Reproduction

Initialize an nsIMimeStreamConverter for nsMimeMessageDraftOrTemplate, then call nsIStreamConverter::asyncConvertData() with an nsIURI for https://example.invalid/message. There is no message service for the HTTPS scheme; no network request is needed.

Actual result: NS_ERROR_OUT_OF_MEMORY.
Expected result: preserve the message-service lookup error, NS_ERROR_FACTORY_NOT_REGISTERED.

The same loss of error information occurs when GetUrlForUri() fails or creation of the text-to-HTML converter fails.

Proposed change

  • Return nsresult and a typed nsMIMESession output from the draft and display stream factories.
  • Propagate XPCOM initialization errors through nsStreamConverter::Init().
  • Map explicit libmime MIME_OUT_OF_MEMORY results to NS_ERROR_OUT_OF_MEMORY, and ambiguous parser failures to NS_ERROR_FAILURE.
  • Release partially initialized parser objects, options, converter references, URL strings, and session storage on failure.

Validation

Extend mailnews/mime/test/unit/test_streamConverterErrors.js to cover service lookup, message URL lookup, text-converter creation, and late draft/display parser startup failures. The late failure tests also check that the draft identity and text-converter references are released. Deliberately disabling the corresponding cleanup makes those lifetime assertions fail.

The complete build and the focused MIME tests pass. Temporary native fault injection also exercised allocation-failure cleanup; that instrumentation is excluded from the patch.

Return nsresult and typed stream outputs from the draft and display factories,
propagate startup errors, and clean up partially initialized state. Report
ambiguous parser failures without assuming memory exhaustion.

Add regression tests for message-service lookup, message URL lookup,
text-converter creation, and draft/display parser startup failures, including
release of retained references.

Follow-up to bug 2088260, which fixed escaped IMAP folder lookup. Bug 2088209
was marked as its duplicate.

Attachment #9678884 - Attachment description: WIP: Bug 2091482 - Preserve MIME stream initialization errors. r=#thunderbird-back-end-reviewers → Bug 2091482 - Preserve MIME stream initialization errors. r=#thunderbird-back-end-reviewers
Target Milestone: --- → 162 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/c035df5b9062
Preserve MIME stream initialization errors. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 16 days ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: