in reply to Re: Bug in perl, or X11::GUITest
in thread Bug in perl, or X11::GUITest

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Bug in perl, or X11::GUITest
by Joost (Canon) on Aug 01, 2005 at 00:53 UTC
    This is probably a bug in X11::GUITest.

    I can reproduce that on my setup. Here's some valgrind output that might help locate the bug.

    ==12233== Memcheck, a memory error detector for x86-linux. ==12233== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et +al. ==12233== Using valgrind-2.4.0, a program supervision framework for x8 +6-linux. ==12233== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et +al. ==12233== For more details, rerun with: -v ==12233== ==12233== Invalid read of size 4 ==12233== at 0x1B90C723: XS_X11__GUITest_GetRootWindow (in /usr/loc +al/lib/perl5/site_perl/5.8.6/i686-linux/auto/X11/GUITest/GUITest.so) ==12233== by 0x80D152C: Perl_pp_entersub (pp_hot.c:2890) ==12233== by 0x80B3991: Perl_runops_debug (dump.c:1449) ==12233== by 0x806332C: S_call_body (perl.c:2298) ==12233== by 0x8062F97: Perl_call_sv (perl.c:2216) ==12233== by 0x80672DB: S_call_list_body (perl.c:4732) ==12233== by 0x8066F1B: Perl_call_list (perl.c:4661) ==12233== by 0x8095EE6: Perl_newATTRSUB (op.c:4472) ==12233== by 0x80920F8: Perl_utilize (op.c:3048) ==12233== by 0x8089B5F: Perl_yyparse (perly.y:414) ==12233== by 0x8061F70: S_parse_body (perl.c:1778) ==12233== by 0x80610F1: perl_parse (perl.c:1282) ==12233== Address 0x8C is not stack'd, malloc'd or (recently) free'd ==12233== ==12233== Process terminating with default action of signal 11 (SIGSEG +V) ==12233== Access not within mapped region at address 0x8C ==12233== at 0x1B90C723: XS_X11__GUITest_GetRootWindow (in /usr/loc +al/lib/perl5/site_perl/5.8.6/i686-linux/auto/X11/GUITest/GUITest.so) ==12233== by 0x80D152C: Perl_pp_entersub (pp_hot.c:2890) ==12233== by 0x80B3991: Perl_runops_debug (dump.c:1449) ==12233== by 0x806332C: S_call_body (perl.c:2298) ==12233== by 0x8062F97: Perl_call_sv (perl.c:2216) ==12233== by 0x80672DB: S_call_list_body (perl.c:4732) ==12233== by 0x8066F1B: Perl_call_list (perl.c:4661) ==12233== by 0x8095EE6: Perl_newATTRSUB (op.c:4472) ==12233== by 0x80920F8: Perl_utilize (op.c:3048) ==12233== by 0x8089B5F: Perl_yyparse (perly.y:414) ==12233== by 0x8061F70: S_parse_body (perl.c:1778) ==12233== by 0x80610F1: perl_parse (perl.c:1282) ==12233== ==12233== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 29 from + 1) ==12233== malloc/free: in use at exit: 569628 bytes in 11354 blocks. ==12233== malloc/free: 20629 allocs, 9275 frees, 12754505 bytes alloca +ted. ==12233== For counts of detected errors, rerun with: -v ==12233== searching for pointers to 11354 not-freed blocks. ==12233== checked 901964 bytes. ==12233== ==12233== LEAK SUMMARY: ==12233== definitely lost: 0 bytes in 0 blocks. ==12233== possibly lost: 152 bytes in 1 blocks. ==12233== still reachable: 569476 bytes in 11353 blocks. ==12233== suppressed: 0 bytes in 0 blocks. ==12233== Reachable blocks (those to which a pointer was found) are no +t shown. ==12233== To see them, rerun with: --show-reachable=yes Segmentation fault

    You can report the bug at the cpan bugtracker for X11::GUITest.

Re^3: Bug in perl, or X11::GUITest
by hexmode (Novice) on Aug 01, 2005 at 01:09 UTC

    You can make your test even simpler if you read the source for FindWindowLike. You'll seeing that the first call is to GetRootWindow and a little testing will show that it is in fact crashing when it trys to execute that bit.

    So a simpler mod.pm is:

    use X11::GUITest; X11::GUITest::GetRootWindow;
    The source for GetRootWindow is in GUITest.xs and is pretty short and sweet:
    Window GetRootWindow() CODE: RETVAL = RootWindow(TheXDisplay, TheScreen); OUTPUT: RETVAL

    But... Where are TheXDisplay or TheScreen defined? This is C, after all, and things don't just auto-vivify. In fact, both are set up in SetupXDisplay.

    SetupXDisplay is called from the INIT block at the end of GUITest.pm. If the INIT block hasn't been called yet (INIT blocks aren't called until just before the main program is executed -- which would be after the statements in mod.pm are executed), then TheXDisplay is NULL when it is used in the above code and we get a segfault.

    The fix, then is to make sure that SetupXDisplay is called before TheXDisplay is used.

    To answer your question: this is a bug in X11::GUITest.

    A reply falls below the community's threshold of quality. You may see it by logging in.