Bug 380656

Summary: libzypp crashes when the target is not loaded
Product: [openSUSE] openSUSE 11.0 Reporter: Ladislav Slezák <lslezak>
Component: libzyppAssignee: E-mail List <zypp-maintainers>
Status: RESOLVED FIXED QA Contact: Duncan Mac-Vicar <dmacvicar>
Severity: Critical    
Priority: P5 - None CC: schubi
Version: Beta 1   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Test case

Description Ladislav Slezák 2008-04-17 06:39:08 UTC
(The crash happens in the current SVN code so I selected Beta1 version.)

libzypp crashes when the target is not initialized:

bool PkgFunctions::AnyResolvableFrom(const std::string &alias)
{
    // check whether there is a known repository with the requested alias
    for (zypp::ResPool::repository_iterator it = zypp_ptr()->pool().knownRepositoriesBegin()
        ; it != zypp_ptr()->pool().knownRepositoriesEnd()
        ; ++it)
    {
        if (it->info().alias() == alias)
/// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/// HERE it crashes
        {
            return true;
        }
    }

    return false;
}


Backtrace:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x2b88f712f6e0 (LWP 15190)]
0x00002b88f870a3a7 in zypp::Repository::get (this=0x797469726f78)
    at /local/lslezak/ZYPP-opensuse.org/libzypp/zypp/Repository.cc:37
37          { return myPool().getRepo( _id ); }
Current language:  auto; currently c++
(gdb) bt
#0  0x00002b88f870a3a7 in zypp::Repository::get (this=0x797469726f78)
    at /local/lslezak/ZYPP-opensuse.org/libzypp/zypp/Repository.cc:37
#1  0x00002b88f870aafa in zypp::Repository::info (this=0x797469726f78)
    at /local/lslezak/ZYPP-opensuse.org/libzypp/zypp/Repository.cc:95
#2  0x00002b88f7fc104b in PkgFunctions::AnyResolvableFrom (this=0x68f2d8, 
    alias=@0x7fffb63f98f0) at Source_Resolvables.cc:59
#3  0x00002b88f7fbb707 in PkgFunctions::SourceLoadImpl (this=0x68f2d8, 
    progress=@0x7fffb63f99c0) at Source_Load.cc:216
Comment 1 Ladislav Slezák 2008-04-17 06:41:39 UTC
Created attachment 208504 [details]
Test case

Testing script, if Pkg::TargetInit() at beginning is not commented out it doesn't crash.
Comment 2 Ladislav Slezák 2008-04-17 06:45:01 UTC
I found the problem while testing the dirinstall yast module - it closes the current target ("/") does some actions and opens the target at another place.

But it crashes before the new target is opened.
Comment 3 Stefan Schubert 2008-04-17 09:45:41 UTC
I can reproduce this error with your script. Thanks
Comment 4 Stefan Schubert 2008-04-17 11:05:16 UTC
Fix in package bindings:
do not iterate over the repo's if the target does not exist.
But additional handling is needed in libzypp.