Hi again,

sorry for answering to my own post. Despite general incompetence at debugging C/XS issues, managed to track this down slightly further by inserting printouts in the AUI.c code after it was generated and before it was compiled.

Given the segmentation fault quoted below and the following change to AUI.c:

-------
XS(XS_Wx__AuiManager_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_Wx__AuiManager_DESTROY)
{
#ifdef dVAR
    dVAR; dXSARGS;
#else
    dXSARGS;
#endif
    if (items != 1)
Perl_croak(aTHX_ "Usage: %s(%s)", "Wx::AuiManager::DESTROY", "THIS");
    PERL_UNUSED_VAR(cv); /* -W */
    {
      printf("FIRST\n");
wxAuiManager * THIS = (wxAuiManager *) wxPli_sv_2_object( aTHX_ ST(0), "Wx::AuiManager" );
      printf("SECOND\n");
      wxPli_thread_sv_unregister( aTHX_ "Wx::AuiManager", THIS, ST(0) );
      printf("THIRD\n");
                 delete THIS;
      printf("FOURTH\n");
    }
    XSRETURN_EMPTY;
}
-------

(Guess which lines I inserted!)

I get the following output on global cleanup:
FIRST
SECOND
THIRD
FOURTH
FIRST
SECOND
THIRD

So obviously, the AuiManager object's DESTROY is called multiple times.

Best regards,
Steffen

Steffen Mueller wrote:
Keedi Kim wrote:
I use Padre and glibc detects dobule free or corruption in AUIManager.

$ ./dev.pl
*** glibc detected *** /usr/bin/perl: double free or corruption (!prev):

let me add a few bits of information.
First, Padre uses iThreads. Some of the Padre developers seem to point in that direction whenever a segmentation fault occurrs. It's not the problem at hand, as far as I can tell.

Here's how you can reproduce a segmentation fault like the one Keedi Kim reported. This happens on Ubuntu on x86_64, perl 5.8.8, Alien::wxWidgets 0.41 (with its own wxWidgets compiled), Wx 0.89, current Padre trunk (r2680 http://svn.perlide.org/padre/trunk/Padre).

$ cd padre/trunk/Padre
$ perl Makefile.PL

# Step probably needed to get all the dependencies:
$ sudo cpan .

$ perl Makefile.PL; make
$ gdb perl
(gdb) run -Iblib/lib t/71-perl.t
Starting program: /usr/bin/perl -Iblib/lib t/71-perl.t
[Thread debugging using libthread_db enabled]
[New Thread 0x7f2a7b4476e0 (LWP 25872)]
1..12
[New Thread 0x41995950 (LWP 25879)]
[Thread 0x41995950 (LWP 25879) exited]
[New Thread 0x42196950 (LWP 25880)]
[Thread 0x42196950 (LWP 25880) exited]
ok 1
ok 2 - The object isa Padre::Document
ok 3 - The object isa Padre::Document::Perl
ok 4 - filename
ok 5 - The object isa PPI::Document
ok 6 - The object isa PPI::Token::Symbol
ok 7 - find_token_at_location returns the same token as a manual search
ok 8 - The object isa PPI::Statement::Variable
ok 9 - find_token_at_location returns the same token as a manual search
ok 10 - Correct declaration found
ok 11
ok 12 - no warnings

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f2a7b4476e0 (LWP 25872)]
0x00007f2a7a872bf0 in ?? () from /lib/libc.so.6
(gdb) bt
#0  0x00007f2a7a872bf0 in ?? () from /lib/libc.so.6
#1 0x00007f2a6fc5d91d in XS_Wx__AuiManager_DESTROY () from /usr/local/lib/perl/5.8.8/auto/Wx/AUI/AUI.so
#2  0x00007f2a7afa82b3 in Perl_pp_entersub () from /usr/lib/libperl.so.5.8
#3  0x00007f2a7af4f837 in ?? () from /usr/lib/libperl.so.5.8
#4  0x00007f2a7af50580 in Perl_call_sv () from /usr/lib/libperl.so.5.8
#5  0x00007f2a7afb432f in Perl_sv_clear () from /usr/lib/libperl.so.5.8
#6  0x00007f2a7afb4b7e in Perl_sv_free () from /usr/lib/libperl.so.5.8
#7  0x00007f2a7afb4644 in Perl_sv_clear () from /usr/lib/libperl.so.5.8
#8  0x00007f2a7afb4b7e in Perl_sv_free () from /usr/lib/libperl.so.5.8
#9  0x00007f2a7afa15cc in Perl_hv_free_ent () from /usr/lib/libperl.so.5.8
#10 0x00007f2a7afa31a8 in ?? () from /usr/lib/libperl.so.5.8
#11 0x00007f2a7afa3489 in Perl_hv_delete_ent () from /usr/lib/libperl.so.5.8
#12 0x00007f2a7afc7e56 in Perl_pp_delete () from /usr/lib/libperl.so.5.8
#13 0x00007f2a7afa6b1e in Perl_runops_standard () from /usr/lib/libperl.so.5.8
#14 0x00007f2a7af50580 in Perl_call_sv () from /usr/lib/libperl.so.5.8
#15 0x00007f2a7afb432f in Perl_sv_clear () from /usr/lib/libperl.so.5.8
#16 0x00007f2a7afb4b7e in Perl_sv_free () from /usr/lib/libperl.so.5.8
#17 0x00007f2a7afaf989 in ?? () from /usr/lib/libperl.so.5.8
#18 0x00007f2a7afaf9e1 in Perl_sv_clean_objs () from /usr/lib/libperl.so.5.8
#19 0x00007f2a7af553a5 in perl_destruct () from /usr/lib/libperl.so.5.8
#20 0x0000000000401883 in main ()

I know, no debugging perl or wxWidgets. I'm sorry.

Cheers,
Steffen



--
Steffen Mueller ([email protected])
Institut für Kernphysik, Forschungszentrum Karlsruhe

Reply via email to