Skip to content

Memory leak in version 0.2.3 when encoding an image #27

Description

@FireMasterK

This can be reproduced by running the convert example.

valgrind logs:

valgrind --tool=memcheck --leak-check=yes ./target/release/examples/convert
==312736== Memcheck, a memory error detector
==312736== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==312736== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info
==312736== Command: ./target/release/examples/convert
==312736==
==312736==
==312736== HEAP SUMMARY:
==312736==     in use at exit: 49,621,476 bytes in 249 blocks
==312736==   total heap usage: 10,265 allocs, 10,016 frees, 278,325,615 bytes allocated
==312736==
==312736== 4,608 bytes in 16 blocks are possibly lost in loss record 16 of 24
==312736==    at 0x48469B3: calloc (vg_replace_malloc.c:1554)
==312736==    by 0x4011792: calloc (rtld-malloc.h:44)
==312736==    by 0x4011792: allocate_dtv (dl-tls.c:375)
==312736==    by 0x40121D1: _dl_allocate_tls (dl-tls.c:634)
==312736==    by 0x4A29F87: allocate_stack (allocatestack.c:423)
==312736==    by 0x4A29F87: pthread_create@@GLIBC_2.34 (pthread_create.c:652)
==312736==    by 0x2B024E: std::sys::unix::thread::Thread::new (thread.rs:87)
==312736==    by 0x28CC5B: std::thread::Builder::spawn (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x288AA3: <rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x289EC1: rayon_core::registry::Registry::new (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x288D44: rayon_core::registry::default_global_registry (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x1262D5: std::sys_common::once::futex::Once::call (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x288BD3: rayon_core::registry::global_registry (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x28C147: rayon_core::current_num_threads (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==
==312736== 13,500,000 bytes in 1 blocks are possibly lost in loss record 23 of 24
==312736==    at 0x4841848: malloc (vg_replace_malloc.c:431)
==312736==    by 0x12F34A: WebPPictureAllocYUVA (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12D205: ImportYUVAFromRGBA (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12E733: WebPPictureARGBToYUVADithered (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12FFB2: WebPEncode (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12C648: webp::encoder::Encoder::encode_advanced (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12C4D7: webp::encoder::Encoder::encode (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12BB98: convert::main (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12B702: std::sys_common::backtrace::__rust_begin_short_backtrace (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12BF68: std::rt::lang_start::{{closure}} (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x2A66AD: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287)
==312736==    by 0x2A66AD: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:485)
==312736==    by 0x2A66AD: try<i32, &(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:449)
==312736==    by 0x2A66AD: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140)
==312736==    by 0x2A66AD: {closure#2} (rt.rs:148)
==312736==    by 0x2A66AD: do_call<std::rt::lang_start_internal::{closure_env#2}, isize> (panicking.rs:485)
==312736==    by 0x2A66AD: try<isize, std::rt::lang_start_internal::{closure_env#2}> (panicking.rs:449)
==312736==    by 0x2A66AD: catch_unwind<std::rt::lang_start_internal::{closure_env#2}, isize> (panic.rs:140)
==312736==    by 0x2A66AD: std::rt::lang_start_internal (rt.rs:148)
==312736==    by 0x12BDF4: main (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==
==312736== 36,000,124 bytes in 1 blocks are definitely lost in loss record 24 of 24
==312736==    at 0x4841848: malloc (vg_replace_malloc.c:431)
==312736==    by 0x12F56E: WebPPictureAlloc (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12EF54: WebPPictureImportRGBA (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12C5D6: webp::encoder::Encoder::encode_advanced (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12C4D7: webp::encoder::Encoder::encode (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12BB98: convert::main (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12B702: std::sys_common::backtrace::__rust_begin_short_backtrace (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x12BF68: std::rt::lang_start::{{closure}} (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==    by 0x2A66AD: call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (function.rs:287)
==312736==    by 0x2A66AD: do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panicking.rs:485)
==312736==    by 0x2A66AD: try<i32, &(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> (panicking.rs:449)
==312736==    by 0x2A66AD: catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> (panic.rs:140)
==312736==    by 0x2A66AD: {closure#2} (rt.rs:148)
==312736==    by 0x2A66AD: do_call<std::rt::lang_start_internal::{closure_env#2}, isize> (panicking.rs:485)
==312736==    by 0x2A66AD: try<isize, std::rt::lang_start_internal::{closure_env#2}> (panicking.rs:449)
==312736==    by 0x2A66AD: catch_unwind<std::rt::lang_start_internal::{closure_env#2}, isize> (panic.rs:140)
==312736==    by 0x2A66AD: std::rt::lang_start_internal (rt.rs:148)
==312736==    by 0x12BDF4: main (in /home/kavin/Workspace/webp/target/release/examples/convert)
==312736==
==312736== LEAK SUMMARY:
==312736==    definitely lost: 36,000,124 bytes in 1 blocks
==312736==    indirectly lost: 0 bytes in 0 blocks
==312736==      possibly lost: 13,504,608 bytes in 17 blocks
==312736==    still reachable: 116,744 bytes in 231 blocks
==312736==         suppressed: 0 bytes in 0 blocks
==312736== Reachable blocks (those to which a pointer was found) are not shown.
==312736== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==312736==
==312736== For lists of detected and suppressed errors, rerun with: -s
==312736== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions