After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 515744 - Evolution (IMAP) : Memory leak
Evolution (IMAP) : Memory leak
Status: RESOLVED FIXED
Product: evolution
Classification: Applications
Component: general
2.22.x (obsolete)
Other Linux
: Normal blocker
: ---
Assigned To: Evolution Shell Maintainers Team
Evolution QA team
Depends on:
Blocks:
 
 
Reported: 2008-02-11 12:20 UTC by Akhil Laddha
Modified: 2013-09-13 00:59 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
Valgind traces of evolution process (304.26 KB, text/plain)
2008-02-11 12:21 UTC, Akhil Laddha
  Details
proposed evo patch (23.02 KB, patch)
2008-02-12 21:50 UTC, Milan Crha
none Details | Review
proposed evo patch ][ (21.75 KB, patch)
2008-02-13 14:59 UTC, Milan Crha
committed Details | Review
proposed eex patch (1.93 KB, patch)
2008-02-13 19:27 UTC, Milan Crha
committed Details | Review
proposed evo patch ]I[ (2.19 KB, patch)
2008-02-20 12:19 UTC, Milan Crha
committed Details | Review

Description Akhil Laddha 2008-02-11 12:20:40 UTC
Evolution 2.21.91

Evolution with IMAP back end is eating residential memory.After performing some operation , residential memory consumption reached up to 308 MB and kept there.

Below is the list of operation i did during my observation

• receiving mails
• moved to calendar
• auto completion 
• recurrence meeting 
• change calendar view
• move to contact 
• create a contact 
• move to task
• create a task 
• create a task list 
• move to memo
• create a memo  - 268 MB 
• back to mailer
• send a mail
• scroll message list 
• mark as junk 
• make as not junk 

But i could clearly see increase in memory consumption during message list 
scroll and component switch.
Comment 1 Akhil Laddha 2008-02-11 12:21:31 UTC
Created attachment 104922 [details]
Valgind traces of evolution process

Attached are the valgrind traces which i collected during my observation.
Comment 2 Milan Crha 2008-02-12 18:45:45 UTC
I'm not sure what to do with this:
254 (40 direct, 214 indirect) bytes in 2 blocks are definitely lost in loss record 135 of 318

I see in code the FIXME this leaks, but I have no idea why is it there (e-cal-component.c) in such a way. I also noticed it uses attachment->attach once as a icalproperty, once as an icalattach. Very strange to me. Let Chen tell what he thinks.

About my change in evo/mail/mail-component.c:impl_finalize, it isn't called anyway, because of mail_component_peek... I would like to suggest some kind of centralized "static" object owner, in e-shell or somewhere, but that's other question, really. (btw, when I manage to call it, then evo crashes on quit for me (or did in time I was working on "disable imap account" bug)).

I added new bug #516080 for gtk possible leaks (it's still reachable, so possible). The pity thing is that many other leaks are from pango/cairo/X/regex which is partially because of evo static structs in the code, partially absolutely out of evo anyway.

BTW, Akhill, did it crashed or not for you? I guess it did.
Comment 3 Matthew Barnes 2008-02-12 19:05:28 UTC
Well, a "leak" is defined as _repeatedly_ allocating a resource and not properly releasing it, such that over time it could potentially drain that resource.  Like a leaky bucket: eventually all the water will drain out.

I don't consider bounded, one-time memory allocations for such things as static structures or strings to be leaks.  They're usually designed to survive until the process terminates and the kernel releases those resources.

  i.e.  This is a leak:

  void foo()
  {
       gchar *duped_string = g_strdup ("some-string");
  }


  This is not a leak:

  void foo()
  {
      static gchar *str_constant = NULL;

      if (str_constant == NULL)
          str_constant = g_strdup ("some-string");
  }
Comment 4 Milan Crha 2008-02-12 20:24:01 UTC
sure, fortunately only some of them are from static members, thus should be fine, but most of them are real leaks, out of evo code probably (from my point of view).
Comment 5 Milan Crha 2008-02-12 21:50:37 UTC
Created attachment 105096 [details] [review]
proposed evo patch

for evolution;

here's a patch for leaks I understood from Akhil's valgrind log.
Akhil, if you can, please try with this patch, it's possible I overlooked some usages with the memory I added free call on, so it will claim with double free or something similar in that case (I touched some of them already and reverted my changes.)
Comment 6 Akhil Laddha 2008-02-13 09:59:02 UTC
Milan, after applying your patch i got memory corruption during free busy and crash during appointment creation , i think both are referring to same problem.

Free-busy memory corruption - gdb traces of evolution process

[New Thread 0xb22ffb90 (LWP 16487)]
*** glibc detected *** /home/build/opt/gnome2/bin/evolution: free(): invalid pointer: 0x08b05cb0 ***

Program received signal SIGINT, Interrupt.
[Switching to Thread 0xb6699a80 (LWP 16368)]
0xffffe410 in __kernel_vsyscall ()
(gdb) thread apply all bt

Thread 36 (Thread 0xb22ffb90 (LWP 16487))

  • #0 __kernel_vsyscall
  • #1 __lll_mutex_lock_wait
    from /lib/libc.so.6
  • #2 _L_lock_5152
    from /lib/libc.so.6
  • #3 *__GI___libc_free
    at malloc.c line 3620
  • #4 g_free
    at gmem.c line 190
  • #5 value_free_string
    at gvaluetypes.c line 268
  • #6 g_value_unset
    at gvalue.c line 155
  • #7 g_signal_emit_valist
    at gsignal.c line 2228
  • #8 g_signal_emit
    at gsignal.c line 2243
  • #9 impl_notifyTimezoneRequested
    at e-cal-listener.c line 468
  • #10 _ORBIT_skel_small_GNOME_Evolution_Calendar_CalListener_notifyTimezoneRequested
    at Evolution-DataServer-Calendar-common.c line 208
  • #11 ORBit_POAObject_invoke
    at poa.c line 1142
  • #12 ORBit_OAObject_invoke
    at orbit-adaptor.c line 338
  • #13 ORBit_small_invoke_adaptor
    at orbit-small.c line 844
  • #14 ORBit_POAObject_handle_request
    at poa.c line 1351
  • #15 ORBit_POAObject_invoke_incoming_request
    at poa.c line 1421
  • #16 giop_thread_queue_process
    at giop.c line 771
  • #17 giop_request_handler_thread
    at giop.c line 481
  • #18 g_thread_pool_thread_proxy
    at gthreadpool.c line 265
  • #19 g_thread_create_proxy
    at gthread.c line 635
  • #20 start_thread
    at pthread_create.c line 296
  • #21 clone
    from /lib/libc.so.6

Thread 1 (Thread 0xb6699a80 (LWP 16368))

  • #0 __kernel_vsyscall
  • #1 __lll_mutex_lock_wait
    from /lib/libc.so.6
  • #2 _L_lock_5152
    from /lib/libc.so.6
  • #3 *__GI___libc_free
    at malloc.c line 3620
  • #4 _dl_map_object_deps
    at dl-deps.c line 495
  • #5 dl_open_worker
    at dl-open.c line 330
  • #6 _dl_catch_error
    at dl-error.c line 178
  • #7 _dl_open
    at dl-open.c line 596
  • #8 do_dlopen
    at dl-libc.c line 86
  • #9 _dl_catch_error
    at dl-error.c line 178
  • #10 dlerror_run
    at dl-libc.c line 47
  • #11 *__GI___libc_dlopen_mode
    at dl-libc.c line 160
  • #12 init
    at ../sysdeps/i386/backtrace.c line 43
  • #13 pthread_once
    from /lib/libpthread.so.0
  • #14 *__GI___backtrace
    at ../sysdeps/i386/backtrace.c line 116
  • #15 __libc_message
    at ../sysdeps/unix/sysv/linux/libc_fatal.c line 150
  • #16 malloc_printerr
  • #17 *__GI___libc_free
    at malloc.c line 3622
  • #18 icaltimezone_reset
    at icaltimezone.c line 240
  • #19 icaltimezone_free
    at icaltimezone.c line 229
  • #20 preview_recur
    at recurrence-page.c line 908
  • #21 g_cclosure_marshal_VOID__VOID
  • #22 g_closure_invoke
    at gclosure.c line 490
  • #23 signal_emit_unlocked_R
    at gsignal.c line 2440
  • #24 g_signal_emit_valist
    at gsignal.c line 2199
  • #25 gtk_signal_emit
    at gtksignal.c line 360
  • #26 e_calendar_item_signal_emission_idle_cb
    at e-calendar-item.c line 3877
  • #27 g_idle_dispatch
    at gmain.c line 4142
  • #28 g_main_context_dispatch
    at gmain.c line 2064
  • #29 g_main_context_iterate
    at gmain.c line 2697
  • #30 g_main_loop_run
    at gmain.c line 2905
  • #31 bonobo_main
    at bonobo-main.c line 311
  • #32 main
    at main.c line 719


Comment 7 Akhil Laddha 2008-02-13 09:59:43 UTC
Crash in evolution 

Gdb traces 


Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb666ea80 (LWP 17004)]
icaltimezone_ensure_coverage (zone=0x4a3d, end_year=2008) at icaltimezone.c:465
465         if (!zone->component)
(gdb) thread apply all bt

Thread 1 (Thread 0xb666ea80 (LWP 17004))

  • #0 icaltimezone_ensure_coverage
    at icaltimezone.c line 465
  • #1 icaltimezone_get_utc_offset
    at icaltimezone.c line 814
  • #2 icaltimezone_convert_time
    at icaltimezone.c line 769
  • #3 icaltime_as_timet_with_zone
    at icaltime.c line 410
  • #4 prepare_tag
    at tag-calendar.c line 80
  • #5 tag_calendar_by_comp
    at tag-calendar.c line 208
  • #6 preview_recur
    at recurrence-page.c line 904
  • #7 recurrence_page_set_dates
    at recurrence-page.c line 1992
  • #8 comp_editor_page_set_dates
    at comp-editor-page.c line 401
  • #9 page_dates_changed_cb
    at comp-editor.c line 2990
  • #10 g_cclosure_marshal_VOID__POINTER
    at gmarshal.c line 601
  • #11 g_closure_invoke
    at gclosure.c line 490
  • #12 signal_emit_unlocked_R
    at gsignal.c line 2440
  • #13 g_signal_emit_valist
    at gsignal.c line 2199
  • #14 gtk_signal_emit
    at gtksignal.c line 360
  • #15 comp_editor_page_notify_dates_changed
    at comp-editor-page.c line 469
  • #16 times_changed_cb
    at schedule-page.c line 569
  • #17 g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #18 g_closure_invoke
    at gclosure.c line 490
  • #19 signal_emit_unlocked_R
    at gsignal.c line 2440
  • #20 g_signal_emit_valist
    at gsignal.c line 2199
  • #21 gtk_signal_emit
    at gtksignal.c line 360
  • #22 e_meeting_time_selector_set_meeting_time
    at e-meeting-time-sel.c line 1115
  • #23 e_meeting_time_selector_item_event
    at e-meeting-time-sel-item.c line 928
  • #24 gnome_canvas_marshal_BOOLEAN__BOXED
    at gnome-canvas-marshal.c line 125
  • #25 g_type_class_meta_marshal
    at gclosure.c line 567
  • #26 g_closure_invoke
    at gclosure.c line 490
  • #27 signal_emit_unlocked_R
    at gsignal.c line 2478
  • #28 g_signal_emit_valist
    at gsignal.c line 2209
  • #29 g_signal_emit
    at gsignal.c line 2243
  • #30 emit_event
    at gnome-canvas.c line 2578
  • #31 _gtk_marshal_BOOLEAN__BOXED
    at gtkmarshalers.c line 84
  • #32 g_type_class_meta_marshal
    at gclosure.c line 567
  • #33 g_closure_invoke
    at gclosure.c line 490
  • #34 signal_emit_unlocked_R
    at gsignal.c line 2478
  • #35 g_signal_emit_valist
    at gsignal.c line 2209
  • #36 g_signal_emit
    at gsignal.c line 2243
  • #37 gtk_widget_event_internal
    at gtkwidget.c line 4678
  • #38 gtk_propagate_event
    at gtkmain.c line 2336
  • #39 gtk_main_do_event
    at gtkmain.c line 1556
  • #40 gdk_event_dispatch
    at gdkevents-x11.c line 2351
  • #41 g_main_context_dispatch
    at gmain.c line 2064
  • #42 g_main_context_iterate
    at gmain.c line 2697
  • #43 g_main_loop_run
    at gmain.c line 2905
  • #44 bonobo_main
    at bonobo-main.c line 311
  • #45 main
    at main.c line 719

Comment 8 Milan Crha 2008-02-13 14:59:04 UTC
Created attachment 105154 [details] [review]
proposed evo patch  ][

for evolution;

this has removed offending part in recurrence-page.c, it really returns time zones from the local store, not new one.
Comment 9 Milan Crha 2008-02-13 19:27:17 UTC
Created attachment 105176 [details] [review]
proposed eex patch

for evolution-exchange;

Here are a few bits to let eex leak a bit less than before.
Comment 10 Srinivasa Ragavan 2008-02-15 20:18:17 UTC
(In reply to comment #8)
> Created an attachment (id=105154) [edit]
> proposed evo patch  ][
> 
> for evolution;
> 
> this has removed offending part in recurrence-page.c, it really returns time
> zones from the local store, not new one.
> 

I'm not sure of this. (2 places comp-editor-factory and e-calendar-table.c ?)
 		tedit = COMP_EDITOR (task_editor_new (client, flags));
 		comp_editor_edit_comp (tedit, comp);
+		g_object_unref (comp);

Otherwise looks fine. Push it fast. This we can check with chen and commit.
Comment 11 Srinivasa Ragavan 2008-02-15 20:19:49 UTC
(In reply to comment #9)
> Created an attachment (id=105176) [edit]
> proposed eex patch
> 
> for evolution-exchange;
> 
> Here are a few bits to let eex leak a bit less than before.
> 

Looks fine to commit
Comment 12 Milan Crha 2008-02-18 10:12:31 UTC
(In reply to comment #10)
>                 tedit = COMP_EDITOR (task_editor_new (client, flags));
>                 comp_editor_edit_comp (tedit, comp);
> +               g_object_unref (comp);
> 
This is correct, int comp_editor.c: real_edit_comp it clones the component. And for example same as in obj_modified_cb in same source, the comp is unreffed there too. Or in e-calendar-view.c: open_event_with_flags.
Comment 13 Milan Crha 2008-02-18 11:15:03 UTC
Evo part committed to trunk. Committed revision 35044.
EEx part committed to trunk. Committed revision 1575.
Comment 14 Matthew Barnes 2008-02-19 19:47:58 UTC
Reopening.

Milan, the e-msg-composer.c:drop_action() hunk causes a "memory freed twice" crash when dragging files into the attachment bar of a composer window.

I like that you're using g_strfreev(urls) but you need to remove the two g_free(str) calls above it ('str' is an element of 'urls').

This line is somewhat misleading, and probably what caused the confusion:

   str = g_strstrip (urls[i]);

The resulting string is not a new string.  It's equivalent to:

   g_strstrip (urls[i]);
   str = urls[i];

Marking this as a blocker so we don't forget about it.
Comment 15 Matthew Barnes 2008-02-19 20:01:55 UTC
Same goes for the calendar/gui/dialogs/comp-editor.c hunk.

Crash dragging an attachment into a new appointment.
Comment 16 Srinivasa Ragavan 2008-02-20 04:15:44 UTC
Nice catch. I didnt realise g_strstrip modifies it inline.
Comment 17 Milan Crha 2008-02-20 12:19:41 UTC
Created attachment 105638 [details] [review]
proposed evo patch ]I[

for evolution;

I checked in code and these are hopefully the only places where I did it wrong with g_strsplit.
Comment 18 Srinivasa Ragavan 2008-02-20 14:47:03 UTC
Seems fine Milan.
Comment 19 Milan Crha 2008-02-20 14:57:29 UTC
Committed to trunk. Committed revision 35063.
Comment 20 Matthew Barnes 2008-02-20 15:56:10 UTC
(In reply to comment #18)
> Seems fine Milan.

I second that; looks correct now.  Thanks Milan.