How to correctly free a double-linked list

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

How to correctly free a double-linked list

Ulf Zibis
Hi,

when running my code, at the end I irregularly get messages like this:
[.....]
[Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] start freeing memory ...
[Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] filler and shifts freed!
[Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] now start freeing
shifts_sums ...
corrupted double-linked list
debug/lineshiftrecover.sh: Zeile 99: 13359 Abgebrochen            
(Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
lineshiftrecover${options[o]} -q 5 $output

debug/lineshiftrecover.sh: Zeile 99: 10524 Abgebrochen            
(Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
lineshiftrecover${options[o]} -q 5 $output


As you can see I'm running my code from the script debug/lineshiftrecover.sh
lineshiftrecover is a new filter I'm working on. It's purpose is to
repair shifted line glitches in videos recoded from VHS tape.

The code runs fine until I'm coming to free the allocated memory in
function "uninit". The code is:
static av_cold void uninit(AVFilterContext *ctx)
{
    LineShiftContext *s = ctx->priv;
    av_log(ctx, s->report >= R_SHIFTS ? AV_LOG_WARNING : AV_LOG_INFO,
"start freeing memory ...\n");
    for (int p = 0; p < s->nb_planes; p++)
        av_freep(&s->filler[p]);
    av_freep(&s->shifts);
/*
    printf("printf(): filler and shifts freed!\n");
*/
    av_log(ctx, s->report >= R_SHIFTS ? AV_LOG_WARNING : AV_LOG_INFO,
"filler and shifts freed!\n");
    if (s->report >= R_SHIFTS) {
/*
        printf("do printf() before statistic of found shifts!\n");
        av_log(ctx, AV_LOG_WARNING, "statistic of found shifts ...\n");
        av_log(NULL, AV_LOG_WARNING, "shift:    "); // * increment);
        for (int shift = 0; shift <= s->span_r -  s->span_l; shift++)
            av_log(NULL, AV_LOG_WARNING, "%6d", s->span_l + shift);
        for (int l = 0; l <= s->lines; l++) {
            av_log(NULL, AV_LOG_WARNING, "\nline %4d:", s->start + l);
            for (int shift = 0; shift <= s->span_r -  s->span_l; shift++)
                av_log(NULL, AV_LOG_WARNING, "%6d",
s->shifts_sums[l][shift]);
            av_log(NULL, AV_LOG_WARNING, "\n");
        }
*/
/*
        printf("printf(): now start freeing shifts_sums ...\n");
*/
        av_log(ctx, AV_LOG_WARNING, "now start freeing shifts_sums ...\n");
        for (int l = 0; l <= s->lines; l++) {
            av_freep(&(s->shifts_sums[l]));
        }
        av_log(ctx, AV_LOG_WARNING, "lines of shifts_sums freed!\n");
        av_freep(&(s->shifts_sums));
/*
        printf("printf(): shifts_sums freed!\n");
*/
        av_log(ctx, AV_LOG_WARNING, "shifts_sums freed!\n");
    }
}

The out-commented printf() lines are to check if there is a problem if
the av_log print buffer is not flushed already, but this seems not the case.

The definition is:
    int16_t **shifts_sums;
The initialization is:
static int config_props(AVFilterLink *inlink)
{
    [.....]
    if (s->report >= R_SHIFTS) {
        s->shifts_sums = av_malloc((s->lines + 1) *
sizeof(*s->shifts_sums));
        for (int l = s->lines; l >= 0; l--) {
            s->shifts_sums[l] = av_malloc((s->span_r - s->span_l + 1) *
sizeof(**s->shifts_sums));
            memset(s->shifts_sums[l], 0, (s->span_r - s->span_l + 1) *
sizeof(**s->shifts_sums));
        }
    }
}


--
Von meinem Seibert gesendet

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Paul B Mahol
On 7/7/19, Ulf Zibis <[hidden email]> wrote:

> Hi,
>
> when running my code, at the end I irregularly get messages like this:
> [.....]
> [Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] start freeing memory ...
> [Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] filler and shifts freed!
> [Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] now start freeing
> shifts_sums ...
> corrupted double-linked list
> debug/lineshiftrecover.sh: Zeile 99: 13359 Abgebrochen
> (Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
> lineshiftrecover${options[o]} -q 5 $output
>
> debug/lineshiftrecover.sh: Zeile 99: 10524 Abgebrochen
> (Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
> lineshiftrecover${options[o]} -q 5 $output
>
>
> As you can see I'm running my code from the script debug/lineshiftrecover.sh
> lineshiftrecover is a new filter I'm working on. It's purpose is to
> repair shifted line glitches in videos recoded from VHS tape.
>
> The code runs fine until I'm coming to free the allocated memory in
> function "uninit". The code is:
> static av_cold void uninit(AVFilterContext *ctx)
> {
>     LineShiftContext *s = ctx->priv;
>     av_log(ctx, s->report >= R_SHIFTS ? AV_LOG_WARNING : AV_LOG_INFO,
> "start freeing memory ...\n");
>     for (int p = 0; p < s->nb_planes; p++)
>         av_freep(&s->filler[p]);
>     av_freep(&s->shifts);
> /*
>     printf("printf(): filler and shifts freed!\n");
> */
>     av_log(ctx, s->report >= R_SHIFTS ? AV_LOG_WARNING : AV_LOG_INFO,
> "filler and shifts freed!\n");
>     if (s->report >= R_SHIFTS) {
> /*
>         printf("do printf() before statistic of found shifts!\n");
>         av_log(ctx, AV_LOG_WARNING, "statistic of found shifts ...\n");
>         av_log(NULL, AV_LOG_WARNING, "shift:    "); // * increment);
>         for (int shift = 0; shift <= s->span_r -  s->span_l; shift++)
>             av_log(NULL, AV_LOG_WARNING, "%6d", s->span_l + shift);
>         for (int l = 0; l <= s->lines; l++) {
>             av_log(NULL, AV_LOG_WARNING, "\nline %4d:", s->start + l);
>             for (int shift = 0; shift <= s->span_r -  s->span_l; shift++)
>                 av_log(NULL, AV_LOG_WARNING, "%6d",
> s->shifts_sums[l][shift]);
>             av_log(NULL, AV_LOG_WARNING, "\n");
>         }
> */
> /*
>         printf("printf(): now start freeing shifts_sums ...\n");
> */
>         av_log(ctx, AV_LOG_WARNING, "now start freeing shifts_sums ...\n");
>         for (int l = 0; l <= s->lines; l++) {
>             av_freep(&(s->shifts_sums[l]));
>         }
>         av_log(ctx, AV_LOG_WARNING, "lines of shifts_sums freed!\n");
>         av_freep(&(s->shifts_sums));
> /*
>         printf("printf(): shifts_sums freed!\n");
> */
>         av_log(ctx, AV_LOG_WARNING, "shifts_sums freed!\n");
>     }
> }
>
> The out-commented printf() lines are to check if there is a problem if
> the av_log print buffer is not flushed already, but this seems not the case.
>
> The definition is:
>     int16_t **shifts_sums;
> The initialization is:
> static int config_props(AVFilterLink *inlink)
> {
>     [.....]
>     if (s->report >= R_SHIFTS) {
>         s->shifts_sums = av_malloc((s->lines + 1) *
> sizeof(*s->shifts_sums));
>         for (int l = s->lines; l >= 0; l--) {
>             s->shifts_sums[l] = av_malloc((s->span_r - s->span_l + 1) *
> sizeof(**s->shifts_sums));
>             memset(s->shifts_sums[l], 0, (s->span_r - s->span_l + 1) *
> sizeof(**s->shifts_sums));
>         }

There is av_calloc, it calls memset for you after allocation.

It looks like you access unallocated array in uninit because your
allocation is under condition.
Before freeing lines you need to check if array is not NULL.


>     }
> }
>
>
> --
> Von meinem Seibert gesendet
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Ulf Zibis
In reply to this post by Ulf Zibis

Am 07.07.19 um 12:42 schrieb Ulf Zibis:

> Hi,
>
> when running my code, at the end I irregularly get messages like this:
> [.....]
> [Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] start freeing memory ...
> [Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] filler and shifts freed!
> [Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] now start freeing
> shifts_sums ...
> corrupted double-linked list
> debug/lineshiftrecover.sh: Zeile 99: 13359 Abgebrochen            
> (Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
> lineshiftrecover${options[o]} -q 5 $output
>
> debug/lineshiftrecover.sh: Zeile 99: 10524 Abgebrochen            
> (Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
> lineshiftrecover${options[o]} -q 5 $output
>
>
> As you can see I'm running my code from the script debug/lineshiftrecover.sh
> lineshiftrecover is a new filter I'm working on. It's purpose is to
> repair shifted line glitches in videos recoded from VHS tape.
>
> The code runs fine until I'm coming to free the allocated memory in
> function "uninit". The code is:
> static av_cold void uninit(AVFilterContext *ctx)
> {
>     LineShiftContext *s = ctx->priv;
>     av_log(ctx, s->report >= R_SHIFTS ? AV_LOG_WARNING : AV_LOG_INFO,
> "start freeing memory ...\n");
>     for (int p = 0; p < s->nb_planes; p++)
>         av_freep(&s->filler[p]);
>     av_freep(&s->shifts);
> /*
>     printf("printf(): filler and shifts freed!\n");
> */
>     av_log(ctx, s->report >= R_SHIFTS ? AV_LOG_WARNING : AV_LOG_INFO,
> "filler and shifts freed!\n");
>     if (s->report >= R_SHIFTS) {
> /*
>         printf("do printf() before statistic of found shifts!\n");
>         av_log(ctx, AV_LOG_WARNING, "statistic of found shifts ...\n");
>         av_log(NULL, AV_LOG_WARNING, "shift:    "); // * increment);
>         for (int shift = 0; shift <= s->span_r -  s->span_l; shift++)
>             av_log(NULL, AV_LOG_WARNING, "%6d", s->span_l + shift);
>         for (int l = 0; l <= s->lines; l++) {
>             av_log(NULL, AV_LOG_WARNING, "\nline %4d:", s->start + l);
>             for (int shift = 0; shift <= s->span_r -  s->span_l; shift++)
>                 av_log(NULL, AV_LOG_WARNING, "%6d",
> s->shifts_sums[l][shift]);
>             av_log(NULL, AV_LOG_WARNING, "\n");
>         }
> */
> /*
>         printf("printf(): now start freeing shifts_sums ...\n");
> */
>         av_log(ctx, AV_LOG_WARNING, "now start freeing shifts_sums ...\n");
>         for (int l = 0; l <= s->lines; l++) {
>             av_freep(&(s->shifts_sums[l]));
>         }
>         av_log(ctx, AV_LOG_WARNING, "lines of shifts_sums freed!\n");
>         av_freep(&(s->shifts_sums));
> /*
>         printf("printf(): shifts_sums freed!\n");
> */
>         av_log(ctx, AV_LOG_WARNING, "shifts_sums freed!\n");
>     }
> }
>
> The out-commented printf() lines are to check if there is a problem if
> the av_log print buffer is not flushed already, but this seems not the case.
>
> The definition is:
>     int16_t **shifts_sums;
> The initialization is:
> static int config_props(AVFilterLink *inlink)
> {
>     [.....]
>     if (s->report >= R_SHIFTS) {
>         s->shifts_sums = av_malloc((s->lines + 1) *
> sizeof(*s->shifts_sums));
>         for (int l = s->lines; l >= 0; l--) {
>             s->shifts_sums[l] = av_malloc((s->span_r - s->span_l + 1) *
> sizeof(**s->shifts_sums));
>             memset(s->shifts_sums[l], 0, (s->span_r - s->span_l + 1) *
> sizeof(**s->shifts_sums));
>         }
>     }
> }
Now I have added an additional log here:
        for (int l = 0; l <= s->lines; l++) {
            av_log(ctx, AV_LOG_WARNING, "freeing line %d ...\n", l);
            av_freep(&(s->shifts_sums[l]));
        }

Sometimes I now get (there are 10 lines existing):
[Parsed_lineshiftrecover_0 @ 0x560c176b6e80] start freeing memory ...
[Parsed_lineshiftrecover_0 @ 0x560c176b6e80] filler and shifts freed!
[Parsed_lineshiftrecover_0 @ 0x560c176b6e80] now start freeing
shifts_sums ...
[Parsed_lineshiftrecover_0 @ 0x560c176b6e80] freeing line 0 ...
[Parsed_lineshiftrecover_0 @ 0x560c176b6e80] freeing line 1 ...
[Parsed_lineshiftrecover_0 @ 0x560c176b6e80] freeing line 2 ...
[Parsed_lineshiftrecover_0 @ 0x560c176b6e80] freeing line 3 ...
corrupted double-linked list
debug/lineshiftrecover.sh: Zeile 99: 16389 Abgebrochen            
(Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
lineshiftrecover${options[o]} -q 5 $output

... but sometimes only:
[Parsed_lineshiftrecover_0 @ 0x560c176b6e80] start freeing memory ...
corrupted double-linked list
debug/lineshiftrecover.sh: Zeile 99: 16389 Abgebrochen            
(Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
lineshiftrecover${options[o]} -q 5 $output

Weird random result! I don't get a clue whats the cause for the error.

Please help,

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Paul B Mahol
On 7/7/19, Ulf Zibis <[hidden email]> wrote:

>
> Am 07.07.19 um 12:42 schrieb Ulf Zibis:
>> Hi,
>>
>> when running my code, at the end I irregularly get messages like this:
>> [.....]
>> [Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] start freeing memory ...
>> [Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] filler and shifts freed!
>> [Parsed_lineshiftrecover_0 @ 0x55e5afb83e80] now start freeing
>> shifts_sums ...
>> corrupted double-linked list
>> debug/lineshiftrecover.sh: Zeile 99: 13359 Abgebrochen
>> (Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
>> lineshiftrecover${options[o]} -q 5 $output
>>
>> debug/lineshiftrecover.sh: Zeile 99: 10524 Abgebrochen
>> (Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
>> lineshiftrecover${options[o]} -q 5 $output
>>
>>
>> As you can see I'm running my code from the script
>> debug/lineshiftrecover.sh
>> lineshiftrecover is a new filter I'm working on. It's purpose is to
>> repair shifted line glitches in videos recoded from VHS tape.
>>
>> The code runs fine until I'm coming to free the allocated memory in
>> function "uninit". The code is:
>> static av_cold void uninit(AVFilterContext *ctx)
>> {
>>     LineShiftContext *s = ctx->priv;
>>     av_log(ctx, s->report >= R_SHIFTS ? AV_LOG_WARNING : AV_LOG_INFO,
>> "start freeing memory ...\n");
>>     for (int p = 0; p < s->nb_planes; p++)
>>         av_freep(&s->filler[p]);
>>     av_freep(&s->shifts);
>> /*
>>     printf("printf(): filler and shifts freed!\n");
>> */
>>     av_log(ctx, s->report >= R_SHIFTS ? AV_LOG_WARNING : AV_LOG_INFO,
>> "filler and shifts freed!\n");
>>     if (s->report >= R_SHIFTS) {
>> /*
>>         printf("do printf() before statistic of found shifts!\n");
>>         av_log(ctx, AV_LOG_WARNING, "statistic of found shifts ...\n");
>>         av_log(NULL, AV_LOG_WARNING, "shift:    "); // * increment);
>>         for (int shift = 0; shift <= s->span_r -  s->span_l; shift++)
>>             av_log(NULL, AV_LOG_WARNING, "%6d", s->span_l + shift);
>>         for (int l = 0; l <= s->lines; l++) {
>>             av_log(NULL, AV_LOG_WARNING, "\nline %4d:", s->start + l);
>>             for (int shift = 0; shift <= s->span_r -  s->span_l; shift++)
>>                 av_log(NULL, AV_LOG_WARNING, "%6d",
>> s->shifts_sums[l][shift]);
>>             av_log(NULL, AV_LOG_WARNING, "\n");
>>         }
>> */
>> /*
>>         printf("printf(): now start freeing shifts_sums ...\n");
>> */
>>         av_log(ctx, AV_LOG_WARNING, "now start freeing shifts_sums
>> ...\n");
>>         for (int l = 0; l <= s->lines; l++) {
>>             av_freep(&(s->shifts_sums[l]));
>>         }
>>         av_log(ctx, AV_LOG_WARNING, "lines of shifts_sums freed!\n");
>>         av_freep(&(s->shifts_sums));
>> /*
>>         printf("printf(): shifts_sums freed!\n");
>> */
>>         av_log(ctx, AV_LOG_WARNING, "shifts_sums freed!\n");
>>     }
>> }
>>
>> The out-commented printf() lines are to check if there is a problem if
>> the av_log print buffer is not flushed already, but this seems not the
>> case.
>>
>> The definition is:
>>     int16_t **shifts_sums;
>> The initialization is:
>> static int config_props(AVFilterLink *inlink)
>> {
>>     [.....]
>>     if (s->report >= R_SHIFTS) {
>>         s->shifts_sums = av_malloc((s->lines + 1) *
>> sizeof(*s->shifts_sums));
>>         for (int l = s->lines; l >= 0; l--) {
>>             s->shifts_sums[l] = av_malloc((s->span_r - s->span_l + 1) *
>> sizeof(**s->shifts_sums));
>>             memset(s->shifts_sums[l], 0, (s->span_r - s->span_l + 1) *
>> sizeof(**s->shifts_sums));
>>         }
>>     }
>> }
> Now I have added an additional log here:
>         for (int l = 0; l <= s->lines; l++) {
>             av_log(ctx, AV_LOG_WARNING, "freeing line %d ...\n", l);
>             av_freep(&(s->shifts_sums[l]));
>         }
>
> Sometimes I now get (there are 10 lines existing):
> [Parsed_lineshiftrecover_0 @ 0x560c176b6e80] start freeing memory ...
> [Parsed_lineshiftrecover_0 @ 0x560c176b6e80] filler and shifts freed!
> [Parsed_lineshiftrecover_0 @ 0x560c176b6e80] now start freeing
> shifts_sums ...
> [Parsed_lineshiftrecover_0 @ 0x560c176b6e80] freeing line 0 ...
> [Parsed_lineshiftrecover_0 @ 0x560c176b6e80] freeing line 1 ...
> [Parsed_lineshiftrecover_0 @ 0x560c176b6e80] freeing line 2 ...
> [Parsed_lineshiftrecover_0 @ 0x560c176b6e80] freeing line 3 ...
> corrupted double-linked list
> debug/lineshiftrecover.sh: Zeile 99: 16389 Abgebrochen
> (Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
> lineshiftrecover${options[o]} -q 5 $output
>
> ... but sometimes only:
> [Parsed_lineshiftrecover_0 @ 0x560c176b6e80] start freeing memory ...
> corrupted double-linked list
> debug/lineshiftrecover.sh: Zeile 99: 16389 Abgebrochen
> (Speicherabzug geschrieben) ./ffmpeg -y -v warning -i debug/$sample -vf
> lineshiftrecover${options[o]} -q 5 $output
>
> Weird random result! I don't get a clue whats the cause for the error.

You need to memset/av_calloc array after allocation that hold pointers to lines.
Otherwise you use uninitialized memory.

If you can, install and use valgrind to help you debug such problems.


>
> Please help,
>
> -Ulf
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Ulf Zibis

Am 07.07.19 um 13:51 schrieb Paul B Mahol:
> There is av_calloc, it calls memset for you after allocation
Thanks for the hint. I now have:
    if (s->report >= R_SHIFTS) {
        s->shifts_sums = av_malloc((s->lines + 1) *
sizeof(*s->shifts_sums));
        for (int l = s->lines; l >= 0; l--)
            s->shifts_sums[l] = av_calloc(s->span_r - s->span_l + 1,
sizeof(**s->shifts_sums));
    }

> It looks like you access unallocated array in uninit because your
> allocation is under condition.
You mean this? :
    if (s->report >= R_SHIFTS)
It's always the same, so it should always hold.

> Before freeing lines you need to check if array is not NULL.
OK, now I have:
        av_log(ctx, AV_LOG_WARNING, "now start freeing shifts_sums ...\n");
        for (int l = 0; l <= s->lines; l++) {
            av_log(ctx, AV_LOG_WARNING, "freeing line %d ...\n", l);
            if (s->shifts_sums[l])
                av_freep(&(s->shifts_sums[l]));
        }
        av_log(ctx, AV_LOG_WARNING, "lines of shifts_sums freed!\n");
        av_freep(&(s->shifts_sums));

        av_log(ctx, AV_LOG_WARNING, "shifts_sums freed!\n");

Unfortunately it doesn't help :-(


> You need to memset/av_calloc array after allocation that hold pointers to lines.
> Otherwise you use uninitialized memory.
I'm not sure if I understand correctly. Isn't this enough initialization? :
        for (int l = s->lines; l >= 0; l--)
            s->shifts_sums[l] = av_calloc(s->span_r - s->span_l + 1,
sizeof(**s->shifts_sums));
I don't get, why I first should write NULLs in there.

> If you can, install and use valgrind to help you debug such problems.

Good idea, I will do that ... guess it needs some time to understand how
it works.

-Ulf


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Paul B Mahol
On 7/7/19, Ulf Zibis <[hidden email]> wrote:
>
> Am 07.07.19 um 13:51 schrieb Paul B Mahol:
>> There is av_calloc, it calls memset for you after allocation
> Thanks for the hint. I now have:
>     if (s->report >= R_SHIFTS) {
>         s->shifts_sums = av_malloc((s->lines + 1) *
> sizeof(*s->shifts_sums));

This above needs to be calloc.

>         for (int l = s->lines; l >= 0; l--)
>             s->shifts_sums[l] = av_calloc(s->span_r - s->span_l + 1,
> sizeof(**s->shifts_sums));
>     }
>
>> It looks like you access unallocated array in uninit because your
>> allocation is under condition.
> You mean this? :
>     if (s->report >= R_SHIFTS)
> It's always the same, so it should always hold.
>
>> Before freeing lines you need to check if array is not NULL.
> OK, now I have:
>         av_log(ctx, AV_LOG_WARNING, "now start freeing shifts_sums ...\n");
>         for (int l = 0; l <= s->lines; l++) {
>             av_log(ctx, AV_LOG_WARNING, "freeing line %d ...\n", l);
>             if (s->shifts_sums[l])
>                 av_freep(&(s->shifts_sums[l]));
>         }
>         av_log(ctx, AV_LOG_WARNING, "lines of shifts_sums freed!\n");
>         av_freep(&(s->shifts_sums));
>
>         av_log(ctx, AV_LOG_WARNING, "shifts_sums freed!\n");
>
> Unfortunately it doesn't help :-(
>
>
>> You need to memset/av_calloc array after allocation that hold pointers to
>> lines.
>> Otherwise you use uninitialized memory.
> I'm not sure if I understand correctly. Isn't this enough initialization? :
>         for (int l = s->lines; l >= 0; l--)
>             s->shifts_sums[l] = av_calloc(s->span_r - s->span_l + 1,
> sizeof(**s->shifts_sums));
> I don't get, why I first should write NULLs in there.
>
>> If you can, install and use valgrind to help you debug such problems.
>
> Good idea, I will do that ... guess it needs some time to understand how
> it works.
>
> -Ulf
>
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Ulf Zibis

Am 07.07.19 um 14:29 schrieb Paul B Mahol:
> On 7/7/19, Ulf Zibis <[hidden email]> wrote:
>> Am 07.07.19 um 13:51 schrieb Paul B Mahol:
>>> There is av_calloc, it calls memset for you after allocation
>> Thanks for the hint. I now have:
>>     if (s->report >= R_SHIFTS) {
>>         s->shifts_sums = av_malloc((s->lines + 1) *
>> sizeof(*s->shifts_sums));
> This above needs to be calloc.

Unfortunately this doesn't help. So I ask:

Isn't this enough initialization? :
        for (int l = s->lines; l >= 0; l--)
            s->shifts_sums[l] = av_calloc(s->span_r - s->span_l + 1,
sizeof(**s->shifts_sums));
I don't get, why I first should write NULLs into the elements of
s->shifts_sums[l].

-Ulf


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Paul B Mahol
On 7/7/19, Ulf Zibis <[hidden email]> wrote:

>
> Am 07.07.19 um 14:29 schrieb Paul B Mahol:
>> On 7/7/19, Ulf Zibis <[hidden email]> wrote:
>>> Am 07.07.19 um 13:51 schrieb Paul B Mahol:
>>>> There is av_calloc, it calls memset for you after allocation
>>> Thanks for the hint. I now have:
>>>     if (s->report >= R_SHIFTS) {
>>>         s->shifts_sums = av_malloc((s->lines + 1) *
>>> sizeof(*s->shifts_sums));
>> This above needs to be calloc.
>
> Unfortunately this doesn't help. So I ask:

Maybe:

s->shifts_sums = av_calloc(s->lines + 1, sizeof(**s->shifts_sums));

>
> Isn't this enough initialization? :
>         for (int l = s->lines; l >= 0; l--)
>             s->shifts_sums[l] = av_calloc(s->span_r - s->span_l + 1,
> sizeof(**s->shifts_sums));
> I don't get, why I first should write NULLs into the elements of
> s->shifts_sums[l].
>
> -Ulf
>
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Ulf Zibis

Am 07.07.19 um 15:07 schrieb Paul B Mahol:

> On 7/7/19, Ulf Zibis <[hidden email]> wrote:
>> Am 07.07.19 um 14:29 schrieb Paul B Mahol:
>>> On 7/7/19, Ulf Zibis <[hidden email]> wrote:
>>>> Am 07.07.19 um 13:51 schrieb Paul B Mahol:
>>>>> There is av_calloc, it calls memset for you after allocation
>>>> Thanks for the hint. I now have:
>>>>     if (s->report >= R_SHIFTS) {
>>>>         s->shifts_sums = av_malloc((s->lines + 1) *
>>>> sizeof(*s->shifts_sums));
>>> This above needs to be calloc.
>> Unfortunately this doesn't help. So I ask:
> Maybe:
>
> s->shifts_sums = av_calloc(s->lines + 1, sizeof(**s->shifts_sums));
With this I get "corrupted size vs. prev_size" immediately after start.
IMHO this is completely wrong as "sizeof(**s->shifts_sums)" is
"sizeof(int16_t)" wich is 2.

So it should be "sizeof(*s->shifts_sums)" aka "sizeof(*int16_t)" which is 8.

So please give me a short answer on this ...

>> Isn't this enough initialization? :
>>         for (int l = s->lines; l >= 0; l--)
>>             s->shifts_sums[l] = av_calloc(s->span_r - s->span_l + 1,
>> sizeof(**s->shifts_sums));
>> I don't get, why I first should write NULLs into the elements of
>> s->shifts_sums[l] by help of memset or calloc.

-Ulf
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Ulf Zibis

Am 07.07.19 um 15:31 schrieb Ulf Zibis:
> So it should be "sizeof(*s->shifts_sums)" aka "sizeof(*int16_t)" which
> is 8.

Sorry, typo, I meant (**s->shifts_sums).

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Paul B Mahol
On 7/7/19, Ulf Zibis <[hidden email]> wrote:
>
> Am 07.07.19 um 15:31 schrieb Ulf Zibis:
>> So it should be "sizeof(*s->shifts_sums)" aka "sizeof(*int16_t)" which
>> is 8.
>
> Sorry, typo, I meant (**s->shifts_sums).
>

Could you just send whole patch?

> -Ulf
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Ulf Zibis

Am 07.07.19 um 15:45 schrieb Paul B Mahol:
> Could you just send whole patch?
Here it is
Please excuse the "under construction" state. The command line t use:

./ffmpeg -y -v warning -i in.mp4 -vf
lineshiftrecover=10:-564:60:-60:report=shifts -q 5 out.mp4

I can send you the in.mp4 I use.

-Ulf


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

vf_lineshift_memory-fault_1.patch (45K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Ulf Zibis
In reply to this post by Ulf Zibis

Am 07.07.19 um 14:20 schrieb Ulf Zibis:
>> If you can, install and use valgrind to help you debug such problems.
> Good idea, I will do that ... guess it needs some time to understand how
> it works.

I now also have tried valgrind. To me this seems, that the cause is
outside of my code:

valgrind: m_mallocfree.c:307 (get_bszB_as_is): Assertion 'bszB_lo ==
bszB_hi' failed.
valgrind: Heap block lo/hi size mismatch: lo = 113, hi = 114.
This is probably caused by your program erroneously writing past the
end of a heap block and corrupting heap metadata.  If you fix any
invalid writes reported by Memcheck, this assertion failure will
probably go away.  Please try that before reporting this as a bug.


host stacktrace:
==19306==    at 0x580441BA: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==19306==    by 0x580442D4: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==19306==    by 0x58044459: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==19306==    by 0x5805184C: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==19306==    by 0x58053B56: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==19306==    by 0x5800B8CC: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==19306==    by 0x5800BAD7: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==19306==    by 0x5800BDA4: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==19306==    by 0x5809F5DC: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
==19306==    by 0x580AED50: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable (lwpid 19306)
==19306==    at 0x4C31E76: memalign (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19306==    by 0x4C31F91: posix_memalign (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19306==    by 0xF3F0B2: av_malloc (mem.c:87)
==19306==    by 0xF3F2B8: av_mallocz (mem.c:238)
==19306==    by 0xF2D83D: av_buffer_ref (buffer.c:95)
==19306==    by 0xF37D41: av_frame_ref (frame.c:478)
==19306==    by 0x2851D1: do_video_out (ffmpeg.c:1344)
==19306==    by 0x28A1EA: reap_filters (ffmpeg.c:1504)
==19306==    by 0x28E7DD: transcode_step (ffmpeg.c:4648)
==19306==    by 0x28E7DD: transcode (ffmpeg.c:4692)
==19306==    by 0x26B51D: main (ffmpeg.c:4894)

Thread 2: status = VgTs_WaitSys (lwpid 19309)
==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
==19306==    by 0x58339F3: __pthread_cond_wait_common
(pthread_cond_wait.c:502)
==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
(pthread_cond_wait.c:655)
==19306==    by 0x865205: frame_worker_thread (pthread_frame.c:177)
==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
==19306==    by 0x5B6688E: clone (clone.S:95)

Thread 3: status = VgTs_WaitSys (lwpid 19310)
==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
==19306==    by 0x58339F3: __pthread_cond_wait_common
(pthread_cond_wait.c:502)
==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
(pthread_cond_wait.c:655)
==19306==    by 0x865205: frame_worker_thread (pthread_frame.c:177)
==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
==19306==    by 0x5B6688E: clone (clone.S:95)

Thread 4: status = VgTs_WaitSys (lwpid 19311)
==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
==19306==    by 0x58339F3: __pthread_cond_wait_common
(pthread_cond_wait.c:502)
==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
(pthread_cond_wait.c:655)
==19306==    by 0x865205: frame_worker_thread (pthread_frame.c:177)
==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
==19306==    by 0x5B6688E: clone (clone.S:95)

Thread 5: status = VgTs_WaitSys (lwpid 19312)
==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
==19306==    by 0x58339F3: __pthread_cond_wait_common
(pthread_cond_wait.c:502)
==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
(pthread_cond_wait.c:655)
==19306==    by 0xF5799D: thread_worker (slicethread.c:78)
==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
==19306==    by 0x5B6688E: clone (clone.S:95)

Thread 6: status = VgTs_WaitSys (lwpid 19313)
==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
==19306==    by 0x58339F3: __pthread_cond_wait_common
(pthread_cond_wait.c:502)
==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
(pthread_cond_wait.c:655)
==19306==    by 0xF5799D: thread_worker (slicethread.c:78)
==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
==19306==    by 0x5B6688E: clone (clone.S:95)

Thread 7: status = VgTs_WaitSys (lwpid 19314)
==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
==19306==    by 0x58339F3: __pthread_cond_wait_common
(pthread_cond_wait.c:502)
==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
(pthread_cond_wait.c:655)
==19306==    by 0xF5799D: thread_worker (slicethread.c:78)
==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
==19306==    by 0x5B6688E: clone (clone.S:95)

Thread 8: status = VgTs_WaitSys (lwpid 19316)
==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
==19306==    by 0x58339F3: __pthread_cond_wait_common
(pthread_cond_wait.c:502)
==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
(pthread_cond_wait.c:655)
==19306==    by 0xF5799D: thread_worker (slicethread.c:78)
==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
==19306==    by 0x5B6688E: clone (clone.S:95)

Thread 9: status = VgTs_WaitSys (lwpid 19318)
==19306==    at 0x58371AA: __lll_unlock_wake (lowlevellock.S:371)
==19306==    by 0x58317DE: __pthread_mutex_unlock_usercnt
(pthread_mutex_unlock.c:54)
==19306==    by 0x58317DE: pthread_mutex_unlock (pthread_mutex_unlock.c:345)
==19306==    by 0xF57A18: thread_worker (slicethread.c:89)
==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
==19306==    by 0x5B6688E: clone (clone.S:95)

Thread 10: status = VgTs_WaitSys (lwpid 19319)
==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
==19306==    by 0x58339F3: __pthread_cond_wait_common
(pthread_cond_wait.c:502)
==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
(pthread_cond_wait.c:655)
==19306==    by 0xF5799D: thread_worker (slicethread.c:78)
==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
==19306==    by 0x5B6688E: clone (clone.S:95)


Note: see also the FAQ in the source distribution.
It contains workarounds to several common problems.
In particular, if Valgrind aborted or crashed after
identifying problems in your program, there's a good chance
that fixing those problems will prevent Valgrind aborting or
crashing, especially if it happened in m_mallocfree.c.

If that doesn't help, please report this bug to: www.valgrind.org

In the bug report, send all the above text, the valgrind
version, and what OS and version you are using.  Thanks.

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Ulf Zibis
In reply to this post by Ulf Zibis

Am 07.07.19 um 16:30 schrieb Ulf Zibis:
> Here it is
> Please excuse the "under construction" state. The command line t use:
>
> ./ffmpeg -y -v warning -i CYD_1.5m_x264.mp4 -vf
> lineshiftrecover=10:-564:60:-60:report=shifts -q 5 out.mp4
>
> I can send you the in.mp4 I use.
Here is the video for my test:

http://jugkoeln.de/Projects/ffmpeg/CYD_1.5m_x264.mp4

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Paul B Mahol
In reply to this post by Ulf Zibis
On 7/7/19, Ulf Zibis <[hidden email]> wrote:
>
> Am 07.07.19 um 14:20 schrieb Ulf Zibis:
>>> If you can, install and use valgrind to help you debug such problems.
>> Good idea, I will do that ... guess it needs some time to understand how
>> it works.
>
> I now also have tried valgrind. To me this seems, that the cause is
> outside of my code:

Nope, bug is in your code.

Build ffmpeg with address sanitizer and you will see it.


>
> valgrind: m_mallocfree.c:307 (get_bszB_as_is): Assertion 'bszB_lo ==
> bszB_hi' failed.
> valgrind: Heap block lo/hi size mismatch: lo = 113, hi = 114.
> This is probably caused by your program erroneously writing past the
> end of a heap block and corrupting heap metadata.  If you fix any
> invalid writes reported by Memcheck, this assertion failure will
> probably go away.  Please try that before reporting this as a bug.
>
>
> host stacktrace:
> ==19306==    at 0x580441BA: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
> ==19306==    by 0x580442D4: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
> ==19306==    by 0x58044459: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
> ==19306==    by 0x5805184C: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
> ==19306==    by 0x58053B56: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
> ==19306==    by 0x5800B8CC: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
> ==19306==    by 0x5800BAD7: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
> ==19306==    by 0x5800BDA4: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
> ==19306==    by 0x5809F5DC: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
> ==19306==    by 0x580AED50: ??? (in /usr/lib/valgrind/memcheck-amd64-linux)
>
> sched status:
>   running_tid=1
>
> Thread 1: status = VgTs_Runnable (lwpid 19306)
> ==19306==    at 0x4C31E76: memalign (in
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==19306==    by 0x4C31F91: posix_memalign (in
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==19306==    by 0xF3F0B2: av_malloc (mem.c:87)
> ==19306==    by 0xF3F2B8: av_mallocz (mem.c:238)
> ==19306==    by 0xF2D83D: av_buffer_ref (buffer.c:95)
> ==19306==    by 0xF37D41: av_frame_ref (frame.c:478)
> ==19306==    by 0x2851D1: do_video_out (ffmpeg.c:1344)
> ==19306==    by 0x28A1EA: reap_filters (ffmpeg.c:1504)
> ==19306==    by 0x28E7DD: transcode_step (ffmpeg.c:4648)
> ==19306==    by 0x28E7DD: transcode (ffmpeg.c:4692)
> ==19306==    by 0x26B51D: main (ffmpeg.c:4894)
>
> Thread 2: status = VgTs_WaitSys (lwpid 19309)
> ==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
> ==19306==    by 0x58339F3: __pthread_cond_wait_common
> (pthread_cond_wait.c:502)
> ==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
> (pthread_cond_wait.c:655)
> ==19306==    by 0x865205: frame_worker_thread (pthread_frame.c:177)
> ==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
> ==19306==    by 0x5B6688E: clone (clone.S:95)
>
> Thread 3: status = VgTs_WaitSys (lwpid 19310)
> ==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
> ==19306==    by 0x58339F3: __pthread_cond_wait_common
> (pthread_cond_wait.c:502)
> ==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
> (pthread_cond_wait.c:655)
> ==19306==    by 0x865205: frame_worker_thread (pthread_frame.c:177)
> ==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
> ==19306==    by 0x5B6688E: clone (clone.S:95)
>
> Thread 4: status = VgTs_WaitSys (lwpid 19311)
> ==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
> ==19306==    by 0x58339F3: __pthread_cond_wait_common
> (pthread_cond_wait.c:502)
> ==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
> (pthread_cond_wait.c:655)
> ==19306==    by 0x865205: frame_worker_thread (pthread_frame.c:177)
> ==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
> ==19306==    by 0x5B6688E: clone (clone.S:95)
>
> Thread 5: status = VgTs_WaitSys (lwpid 19312)
> ==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
> ==19306==    by 0x58339F3: __pthread_cond_wait_common
> (pthread_cond_wait.c:502)
> ==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
> (pthread_cond_wait.c:655)
> ==19306==    by 0xF5799D: thread_worker (slicethread.c:78)
> ==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
> ==19306==    by 0x5B6688E: clone (clone.S:95)
>
> Thread 6: status = VgTs_WaitSys (lwpid 19313)
> ==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
> ==19306==    by 0x58339F3: __pthread_cond_wait_common
> (pthread_cond_wait.c:502)
> ==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
> (pthread_cond_wait.c:655)
> ==19306==    by 0xF5799D: thread_worker (slicethread.c:78)
> ==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
> ==19306==    by 0x5B6688E: clone (clone.S:95)
>
> Thread 7: status = VgTs_WaitSys (lwpid 19314)
> ==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
> ==19306==    by 0x58339F3: __pthread_cond_wait_common
> (pthread_cond_wait.c:502)
> ==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
> (pthread_cond_wait.c:655)
> ==19306==    by 0xF5799D: thread_worker (slicethread.c:78)
> ==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
> ==19306==    by 0x5B6688E: clone (clone.S:95)
>
> Thread 8: status = VgTs_WaitSys (lwpid 19316)
> ==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
> ==19306==    by 0x58339F3: __pthread_cond_wait_common
> (pthread_cond_wait.c:502)
> ==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
> (pthread_cond_wait.c:655)
> ==19306==    by 0xF5799D: thread_worker (slicethread.c:78)
> ==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
> ==19306==    by 0x5B6688E: clone (clone.S:95)
>
> Thread 9: status = VgTs_WaitSys (lwpid 19318)
> ==19306==    at 0x58371AA: __lll_unlock_wake (lowlevellock.S:371)
> ==19306==    by 0x58317DE: __pthread_mutex_unlock_usercnt
> (pthread_mutex_unlock.c:54)
> ==19306==    by 0x58317DE: pthread_mutex_unlock (pthread_mutex_unlock.c:345)
> ==19306==    by 0xF57A18: thread_worker (slicethread.c:89)
> ==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
> ==19306==    by 0x5B6688E: clone (clone.S:95)
>
> Thread 10: status = VgTs_WaitSys (lwpid 19319)
> ==19306==    at 0x58339F3: futex_wait_cancelable (futex-internal.h:88)
> ==19306==    by 0x58339F3: __pthread_cond_wait_common
> (pthread_cond_wait.c:502)
> ==19306==    by 0x58339F3: pthread_cond_wait@@GLIBC_2.3.2
> (pthread_cond_wait.c:655)
> ==19306==    by 0xF5799D: thread_worker (slicethread.c:78)
> ==19306==    by 0x582D6DA: start_thread (pthread_create.c:463)
> ==19306==    by 0x5B6688E: clone (clone.S:95)
>
>
> Note: see also the FAQ in the source distribution.
> It contains workarounds to several common problems.
> In particular, if Valgrind aborted or crashed after
> identifying problems in your program, there's a good chance
> that fixing those problems will prevent Valgrind aborting or
> crashing, especially if it happened in m_mallocfree.c.
>
> If that doesn't help, please report this bug to: www.valgrind.org
>
> In the bug report, send all the above text, the valgrind
> version, and what OS and version you are using.  Thanks.
>
> -Ulf
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Ulf Zibis

Am 07.07.19 um 21:16 schrieb Paul B Mahol:
> Nope, bug is in your code.
> Build ffmpeg with address sanitizer and you will see it.
Thanks, no problem.

What is an address sanitizer, and how can I build with that?

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Reindl Harald


Am 07.07.19 um 21:23 schrieb Ulf Zibis:
>
> Am 07.07.19 um 21:16 schrieb Paul B Mahol:
>> Nope, bug is in your code.
>> Build ffmpeg with address sanitizer and you will see it.
> Thanks, no problem.
>
> What is an address sanitizer, and how can I build with that?

https://stackoverflow.com/questions/37970758/how-to-use-addresssanitizer-in-gcc
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Ulf Zibis

Am 07.07.19 um 21:27 schrieb Reindl Harald:
>
> Am 07.07.19 um 21:23 schrieb Ulf Zibis:
>> Am 07.07.19 um 21:16 schrieb Paul B Mahol:
>>> Nope, bug is in your code.
>>> Build ffmpeg with address sanitizer and you will see it.
>> Thanks, no problem.
>>
>> What is an address sanitizer, and how can I build with that?
> https://stackoverflow.com/questions/37970758/how-to-use-addresssanitizer-in-gcc

OK thanks, I have to add |-fsanitize=address to CFLAGS and LDFLAGS| but
where in the build files do I have to add them?

Sorry, I have no clue about MAKE files.

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Paul B Mahol
On 7/7/19, Ulf Zibis <[hidden email]> wrote:

>
> Am 07.07.19 um 21:27 schrieb Reindl Harald:
>>
>> Am 07.07.19 um 21:23 schrieb Ulf Zibis:
>>> Am 07.07.19 um 21:16 schrieb Paul B Mahol:
>>>> Nope, bug is in your code.
>>>> Build ffmpeg with address sanitizer and you will see it.
>>> Thanks, no problem.
>>>
>>> What is an address sanitizer, and how can I build with that?
>> https://stackoverflow.com/questions/37970758/how-to-use-addresssanitizer-in-gcc
>
> OK thanks, I have to add |-fsanitize=address to CFLAGS and LDFLAGS| but
> where in the build files do I have to add them?
>
> Sorry, I have no clue about MAKE files.

./configure --toolchain=gcc-asan

>
> -Ulf
>
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to correctly free a double-linked list

Ulf Zibis

Am 07.07.19 um 22:12 schrieb Paul B Mahol:
> ./configure --toolchain=gcc-asan
I get:
$ ./configure --toolchain=gcc-asan
gcc is unable to create an executable file.
If gcc is a cross-compiler, use the --enable-cross-compile option.
Only do this if you know what cross compiling means.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
[hidden email] mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this
will help

solve the problem.

What to do next?

-Ulf

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
12