Closed Bug 608095 Opened 14 years ago Closed 5 years ago

Contacts needs to not spin nested event loops

Categories

(Mozilla Labs :: Contacts, defect)

defect
Not set
major

Tracking

(Not tracked)

RESOLVED INACTIVE

People

(Reporter: asuth, Unassigned)

Details

Contacts appears to use modules/ext/Sync.js to try and turn asynchronous operations into non-blocking synchronous operations by spinning nested event loops.  Namely, asynchronous database operations and some resource retrieval and parsing operations (via modules/ext/Resource.js) use the mechanism.

This is categorically a bad idea.  Some key reasons:
- Spinning nested event loops is a known source of security problems.
- If invoked inside a context with code on the stack that is not designed to be reentrant, said code could be unpleasantly surprised.
- May interact badly with other nested event loops with legitimate reasons for existing, such as modal dialogs.
- It does not appear that the logic makes any attempt to limit the depth to which it will nest event loops.  The stack could be blown if too many loops start nesting.
- It does not appear the logic makes any attempt to time-out or otherwise ensure the nested loop completes within a reasonable amount of time.
- Having JavaScript pump the event loop has performance implications.
Closing all inactive bugs in Mozilla labs :: *
Please reopen if this are still relevant.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.