Closed Bug 514946 Opened 15 years ago Closed 14 years ago

"Too much recursion" error and high CPU utilization in Thunderbird with Lightning

Categories

(Calendar :: Lightning Only, defect)

Lightning 0.9
x86
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 419490

People

(Reporter: artisticcheese, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.4; OfficeLivePatch.1.3)
Build Identifier: 2.0.0.23 (20090812)

I have TB with Lightening installed and every time I try open any email message my CPU goes 100% and error log is filled with errors below
Error: too much recursion
Source File: chrome://calendar/content/calendar-common-sets.js
Line: 172
It appears that code in JS file has infinite loop at that line specified. 

 default:
                if (this.defaultController && !this.isCalendarInForeground()) {
                    // The delete-button demands a special handling in mail-mode
                    // as it is supposed to delete an element of the focused pane
                    if (aCommand == "cmd_delete" || aCommand == "button_delete") {
                        var focusedElement = document.commandDispatcher.focusedElement;
                        if (focusedElement) {
                            if (focusedElement.getAttribute("id") == "agenda-listbox") {
                                 return agendaListbox.isEventSelected();
                            } else if (focusedElement.className == "calendar-task-tree") {
                                 return this.writable &&
                                        this.todo_items_selected &&
                                        this.todo_items_writable;
                            }
                        }
                    }

                    // If calendar is not in foreground, let the default controller take
                    // care. If we don't have a default controller (i.e sunbird), just
                    // continue.
                    if (this.defaultController.supportsCommand(aCommand)) {
                        return this.defaultController.isCommandEnabled(aCommand);
                    }

Reproducible: Always

Steps to Reproduce:
I have Lightening, TB and Funambol plugins installed. I can reproduce issue 100% on my current machine but not sure how can I make it reproduce somewhere else. For all I know looking at that JS file there is infinite loop there if aCommand parameter falls through to "default" clause
Also my Go menu looks very weird. Please see screenshot here http://dl.getdropbox.com/u/7307/Untitled.png
(In reply to comment #0)
> I have TB with Lightening installed and every time I try open any email message
> my CPU goes 100% and error log is filled with errors below
> Error: too much recursion
> Source File: chrome://calendar/content/calendar-common-sets.js
> Line: 172

I suppose you use Lighting 0.9, correct? What do you mean when saying "open any email message"? Is this in a standalone message windows or as preview inside the main window? Your screenshot suggests it is in the main window. Have you any additional add-ons installed?
Yes I use Lightening 0.9. I just click on any email message to see it in preview pane. I have funambol add-on installed. Nothing else.
I can see from code above regardless what I have open there is huge possibility of recursion there. See the code will fall through to default and then it'll call itself again in last line.
I see no recursion in the above code. If the Lightning controller doesn't handle the command it passes it to the parent Thunderbird controller.

Does this happens with only Lightning installed? Maybe the Funambol extension interferes with Lightning.
Version: unspecified → Lightning 0.9
You don't see recursion? So if calls falls through to default:
then this code is executed 
if (this.defaultController.supportsCommand(aCommand)) {
                        return
this.defaultController.isCommandEnabled(aCommand);
                    }
Which will call origina methid of isCommandEnabled where this piece of code located again.
Complete code is below, see if you can see recursion there 

isCommandEnabled: function cC_isCommandEnabled(aCommand) {
        switch (aCommand) {
            case "calendar_new_event_command":
                return this.writable && this.calendars_support_events;
            
            case "calendar_import_command":
                return this.writable;
            case "calendar_export_selection_command":
                return this.item_selected;

            case "calendar_publish_selected_events_command":
                return this.item_selected;

            case "calendar_reload_remote_calendar":
                return !this.no_network_calendars && !this.offline;
            default:
                if (this.defaultController && !this.isCalendarInForeground()) {
                    // The delete-button demands a special handling in mail-mode
                    // as it is supposed to delete an element of the focused pane
                    if (aCommand == "cmd_delete" || aCommand == "button_delete") {
                        var focusedElement = document.commandDispatcher.focusedElement;
                        if (focusedElement) {
                            if (focusedElement.getAttribute("id") == "agenda-listbox") {
                                 return agendaListbox.isEventSelected();
                            } else if (focusedElement.className == "calendar-task-tree") {
                                 return this.writable &&
                                        this.todo_items_selected &&
                                        this.todo_items_writable;
                            }
                        }
                    }

                    // If calendar is not in foreground, let the default controller take
                    // care. If we don't have a default controller (i.e sunbird), just
                    // continue.
                    if (this.defaultController.supportsCommand(aCommand)) {
                        return this.defaultController.isCommandEnabled(aCommand);
                    }
                }
It happens even after I uninstalled funambol as well.
But this.defaultController != calendarController.

Thunderbird itself has a controller that takes care of mail commands. This controller is put into calendarController.defaultController. The code you describe checks if the thunderbird controller supports the given command and then asks it if the command is enabled. This doesnt call the calendar controller again.
I'm just looking at the code without taking into account business logic.
Right now if aCommand is passed to isCommandEnabled function and it goes to switch statement and there is no match, it goes to default:
It can then fall through to if (){} statement and possibly call isCommandEnabled() function again with the same aCommand parameter again which brought it there in a first place and hence call infinite loop (too much recursion)
Please see this happening on my screen in this screen cast. This is huge show stopper since Thunderbird becomes completely unusable in this scenario. It happens on every system I installed Thunderbird with Lightening (total of 3 systems all showing the same issue).
http://dl.getdropbox.com/u/7307/e.wmv
You don't have to take any business logic into account, it is clear that the same function is NOT called, since this != this.defaultController. Just because both functions are called isCommandEnabled doesn't mean they are the same function! I don't know how else to explain this.

I can't seem to reproduce this on Linux, it may be a windows only issue?
Can you please take a look at the code below and tell me if it'll cause recursion? Becouse that's what current JS code is. Pass "1", "2", "3" and it'll be fine, but try to pass "4" and it'll cause infinite loop.
This is confirmed by JS console, by huge stack which you can see in video above plus expected behaviour (high CPU utilization).
It might me just my machine (but it happens on all 3 machines I have).
Right now I don't even feel there is any need to try to reproduce the issue since apparently from just looking at the code the last "if" statement causes the loop under certain conditiions (in my specific example if aCommand == 4) and in case of real life if this.defaultController.supportsCommand(aCommand)) since in this case this function will call itself with the same aCommand it come with.

function InfiniteLoop (aCommand)
{
switch aCommmand
{
case "1":
return "no loop";
case "2":
return "still no loop";
default:
if (aCommand==3)
{
return "we got lucky, still no loop";
}
if (aCommand==4){
return InfiniteLoop (aCommand)
}
}
Lightning 0.9 has been released almost one year ago. Currently you are the only one seeing this issue. Maybe you have some specific setup or unusual settings. It would help if you could provide detailed steps to reproduce the issue starting with a fresh Thunderbird profile.


And maybe you can test if reseting Thunderbirds extension cache helps. Remove "extensions.ini" "extensions.cache" and "extensions.rdf" from your Thunderbird original profile folder and let them recreate.


What Philip is trying to say: If you look at the code you'll see that it does something different (this.isCommandEnabled != this.defaultController.isCommandEnabled). In addition there is no need to post large sections of code here. You can link to them via mxr.mozilla.org, i.e. http://mxr.mozilla.org/mozilla1.8/source/calendar/base/content/calendar-common-sets.js#173
Here is steps to reproduce the problem with screenshots (clean TB install) http://dl.getdropbox.com/u/7307/saveed.zip
I don't know any other ways to import calendar events and tasks except to use Funambol add-on so I had to install it.
I understand that I'm the only one experiencing this issue but can you figure out who is responsible for this issue. You can see the issue starts already with "Go" menu being screwed up even before mailbox is open.
Each time I click on any email messages a new menu is created under GO, it adds another set of Mail/Calendar/Tasks/Address Book to already existing ones. So if I clicked 10 messages, then GO menu spans several screen heights all filled with the same information.
I think I found how to reproduce the issue. Create a new task and set recurrence to "every 5th Monday effective today. See screenshot in attachment for settings.
Attached image Screenshot of task —
This settings causing 100% CPU and recursion errors
(In reply to comment #15)

This is Bug 419490. I retested this bug using Lightning 1.0pre (20090911) with Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.4pre) Gecko/20090911 Shredder/3.0b4pre. I get the same NS_ERROR_OUT_OF_MEMORY error but nothing like "too much recursion" error.
After re-reading all comments in this bug report, I'm inclined to mark it as duplicate of bug 419490. Any opinions or objections?
Summary: "Too much recursion" error and high CPU utilization in Thunderbird with Lightening → "Too much recursion" error and high CPU utilization in Thunderbird with Lightning
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: