Skip to content

"panic: free from wrong pool, ... during global destruction." on threaded Perl [rt.cpan.org #129984] #1

@hirooih

Description

@hirooih

Migrated from rt.cpan.org#129984 (status was 'open')

Requestors:

Attachments:

From daxim@cpan.org on 2019-07-05 07:15:27
:

Repro:

1. perl-5.30.0 brewed with -DDEBUGGING -Dusemorebits -Duseshrplib -Dusethreads -Accflags='-fPIC -DUSE_THREAD_SAFE_LOCALE'
2. run perl -mTerm::ReadLine -e'$0 = "trlg-debug"; $term = Term::ReadLine->new($0); while (defined ($_ = $term->readline("prompt>"))) {}'
3. while the prompt waits for input, resize terminal emulator window or run pkill -WINCH trlg-debug
4. ctrl+d to exit

Expect:

clean exit

Got:

panic: free from wrong pool, 70d000!=590260 during global destruction.

Terminal emulator is KDE Konsole 19.04. Other system information is attached.

From hayashi@cpan.org on 2020-04-24 14:29:25
:

Hi,

I am sorry I overlooked your report.

I cannot reproduce your fail on my environment.

Do you still have the error?
Can you try any other programs which uses the same GNU Readline Library, ex bash?
My module does not care about the WINCH signal.  The GNU Readline cares it.

And your report says TERM is set to dumb.
Do you use the same value on KDE Konsole?

Any other clues are welcome.

Thank you.

On Fri, 5 Jul 2019 07:15:27 GMT, DAXIM wrote:
> Repro:
> 
> 1. perl-5.30.0 brewed with -DDEBUGGING -Dusemorebits -Duseshrplib
> -Dusethreads -Accflags='-fPIC -DUSE_THREAD_SAFE_LOCALE'
> 2. run perl -mTerm::ReadLine -e'$0 = "trlg-debug"; $term =
> Term::ReadLine->new($0); while (defined ($_ = $term-
> >readline("prompt>"))) {}'
> 3. while the prompt waits for input, resize terminal emulator window
> or run pkill -WINCH trlg-debug
> 4. ctrl+d to exit
> 
> Expect:
> 
> clean exit
> 
> Got:
> 
> panic: free from wrong pool, 70d000!=590260 during global destruction.
> 
> Terminal emulator is KDE Konsole 19.04. Other system information is
> attached.




From daxim@cpan.org on 2020-04-24 19:51:20
:

> Do you still have the error?

Yes. It also shows with perl-5.31.9.

> Can you try any other programs

I have tested a few programs depending on libreadline8: bash, bc, fdisk, gpg2, lftp, parted, python3, sqlite3, units, xfs_db, zypper. When they show a prompt:

1. I verify that I am on a readline prompt by using the Home key (does nothing on a readline prompt, but would print ^[[H on a non-readline prompt);
2. I send a WINCH signal to the program;
3. I press ctrl+d to exit the prompt.

They all behave normally. What I mean is: they exit the same way whether I send the signal or not.

It's only Perl programs with T::RL::G that panic, and only after receiving the signal.

> your report says TERM is set to dumb

That's in line 211 of the report file. This is because the test file t/02test_use.t sets TERM=dumb on purpose. My normal value is shown above in line 199: TERM=xterm-256color

From daxim@cpan.org on 2020-04-24 23:24:00
:

> Any other clues are welcome.

ilmari commented in IRC:

| it might be a -DDEBUGGING-only panic
| indeed, it's in an # ifdef PERL_TRACK_MEMPOOL, which is only defined under PERL_IMPLICIT_CONTEXT && DEBUGGING
| PERL_IMPLICIT_CONTEXT is only defined by default under MULTIPLICITY, so you need threads _and_ debugging to trigger that
| and I can reproduce it on 5.30.0-thr-dbg on debian stable
| that error is from perl's safesysfree(), not readline or libc
| so it's a value beeing freed by a different interpreter than the one that allocated it


From hayashi@cpan.org on 2020-04-25 00:27:52
:

Hi,

Thank you for your info.  They help me a lot.

On Fri, 24 Apr 2020 23:24:00 GMT, DAXIM wrote:
> > Any other clues are welcome.
> 
> ilmari commented in IRC:
> 
> | it might be a -DDEBUGGING-only panic
> | indeed, it's in an # ifdef PERL_TRACK_MEMPOOL, which is only defined
> under PERL_IMPLICIT_CONTEXT && DEBUGGING
> | PERL_IMPLICIT_CONTEXT is only defined by default under MULTIPLICITY,
> so you need threads _and_ debugging to trigger that
> | and I can reproduce it on 5.30.0-thr-dbg on debian stable
> | that error is from perl's safesysfree(), not readline or libc
> | so it's a value beeing freed by a different interpreter than the one
> that allocated it

This makes sense to me.
T::RL::G has to handle strings which are allocated by Perl and GNU Readline Library.
They can be mixed.
I carefully choose Perl-free nor xfree (free used by GNU Readline Library).
And there are codes which frees strings when it received signal in the GNU Readline Library.
Strings allocated by perl may freed and may cause error by perl memory checker.

Does 5.30.0-thr-dbg mean perl-debug package?
https://packages.debian.org/search?lang=en&keywords=perl-debug

I am not sure I can fix, but I will try.


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