nightstyles / alembic

Automatically exported from code.google.com/p/alembic
Other
1 stars 0 forks source link

Shared HDF5 File Handle #336

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
User can't store the Alembic::Abc::IArchive, e.g. the varaible of 
Alembic::Abc::IArchive must be local, if user store that as a member of a 
class, HDF5 will generates a lot of exception on H5OClose() because the file 
handle has been already closed, the file handle number is invalid at that time.

What is the expected output? What do you see instead?
No exception from HDF5.

HDF5-DIAG: Error detected in HDF5 (1.8.9) thread 0:
  #000: ..\..\hdf5-1.8.9\src\H5O.c line 1059 in H5Oclose(): not a valid object
    major: Invalid arguments to routine
    minor: Bad value
HDF5-DIAG: Error detected in HDF5 (1.8.9) thread 0:
  #000: ..\..\hdf5-1.8.9\src\H5O.c line 1059 in H5Oclose(): not a valid object
    major: Invalid arguments to routine
    minor: Bad value
HDF5-DIAG: Error detected in HDF5 (1.8.9) thread 0:
  #000: ..\..\hdf5-1.8.9\src\H5F.c line 394 in H5Fget_obj_count(): not a file i

    major: Invalid arguments to routine
    minor: Bad value
HDF5-DIAG: Error detected in HDF5 (1.8.9) thread 0:
  #000: ..\..\hdf5-1.8.9\src\H5F.c line 394 in H5Fget_obj_count(): not a file i

    major: Invalid arguments to routine
    minor: Bad value
HDF5-DIAG: Error detected in HDF5 (1.8.9) thread 0:
  #000: ..\..\hdf5-1.8.9\src\H5F.c line 394 in H5Fget_obj_count(): not a file i

    major: Invalid arguments to routine
    minor: Bad value
HDF5-DIAG: Error detected in HDF5 (1.8.9) thread 0:
  #000: ..\..\hdf5-1.8.9\src\H5F.c line 394 in H5Fget_obj_count(): not a file i

    major: Invalid arguments to routine
    minor: Bad value

What version of the product are you using? On what operating system?
Alembic 1.5.3
HDF5 1.5.9

Please provide any additional information below.
Ogawa doesn't have this issue.

Original issue reported on code.google.com by Bo.Schwa...@gmail.com on 13 Mar 2014 at 3:13

GoogleCodeExporter commented 9 years ago
HDF5 1.8.9

Original comment by Bo.Schwa...@gmail.com on 13 Mar 2014 at 3:13

GoogleCodeExporter commented 9 years ago
Do you really mean you can't store IArchive as a global variable?

If it is try putting  H5dont_atexit():
http://www.hdfgroup.org/HDF5/doc/RM/RM_H5.html#Library-DontAtExit

In your custom tool, this should prevent the unwinding issues you are seeing.

Original comment by miller.lucas on 13 Mar 2014 at 3:24

GoogleCodeExporter commented 9 years ago
Hi Lucas

Let me show you the issue.

Very easy, I have a PRMAN procedural, and I don't want to open the archive file 
to read the file once to read single object during the rendering (maybe a lot 
of objects), so that I will open the archive and store it into a global map.

static std::map< std::string , ArchiveRef > g_allIArchives ;

class Archive
{
public :

    Archive()
    {
    }

    ~Archive()
    {
    }

    bool ReadFile( const std::string & filePath ) ;

    bool ReadObject( const ReadOptions & ReadOptions ) ;

private :

    Alembic::Abc::IArchive m_iArchive ;
} ;

bool Archive::ReadFile( const std::string & filePath )
{
    try
    {
        Alembic::AbcCoreFactory::IFactory iFactory ;
        Alembic::Abc::IArchive iArchive = iFactory.getArchive( filePath ) ;
        if ( ! iArchive.valid() )
        {
            return false ;
        }
        m_iArchive = iArchive ; // THIS LINE
    }
    catch ( const std::exception & e )
    {
        std::cerr << e.what() << std::endl ;
        return false ;
    }
    catch ( ... )
    {
        return false ;
    }

    return true ;
}

I'm sure this problem once I commented out that line, the procedural exited 
properly without any error but once I want to store that archive, exception 
raised. Ogawa don't have this issue, so I have converted the all files into 
Ogawa format. Any ideas ? Thanks !

Original comment by Bo.Schwa...@gmail.com on 13 Mar 2014 at 3:32

GoogleCodeExporter commented 9 years ago
Yeah since g_allIArchives is a static global, you will need to call 
H5dont_at_exit() once.

Original comment by miller.lucas on 13 Mar 2014 at 3:41

GoogleCodeExporter commented 9 years ago
Seems fine now.

Original comment by Bo.Schwa...@gmail.com on 20 Mar 2014 at 2:42

GoogleCodeExporter commented 9 years ago

Original comment by miller.lucas on 20 Mar 2014 at 5:10