Skip to content

Commit 9f05a15

Browse files
committed
Fixing seg fault when attempting to read a non-existant attribute several times.
This issue was introduced by 030e7c9
1 parent e117e02 commit 9f05a15

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/IECore/SceneCache.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ class SceneCache::ReaderImplementation : public SceneCache::Implementation
535535
}
536536
if ( !it.first->second )
537537
{
538+
m_attributeSampleTimes.erase( it.first );
538539
throw Exception( ( boost::format( "No samples for attribute %s available" ) % name.value() ).str() );
539540
}
540541
return *(it.first->second);

test/IECore/SceneCacheThreadingTest.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ struct SceneCacheThreadingTest
112112
parallel_reduce( blocked_range<size_t>( 0, 100 ), task );
113113
BOOST_CHECK( task.errors() == 0 );
114114
}
115+
116+
void testFakeAttributeRead()
117+
{
118+
task_scheduler_init scheduler( 100 );
119+
120+
TestSceneCache task( "fake" );
121+
122+
parallel_reduce( blocked_range<size_t>( 0, 100 ), task );
123+
BOOST_CHECK( task.errors() == 100000 );
124+
}
115125

116126
};
117127

@@ -123,6 +133,7 @@ struct SceneCacheThreadingTestSuite : public boost::unit_test::test_suite
123133
boost::shared_ptr<SceneCacheThreadingTest> instance( new SceneCacheThreadingTest() );
124134

125135
add( BOOST_CLASS_TEST_CASE( &SceneCacheThreadingTest::testAttributeRead, instance ) );
136+
add( BOOST_CLASS_TEST_CASE( &SceneCacheThreadingTest::testFakeAttributeRead, instance ) );
126137
}
127138
};
128139

0 commit comments

Comments
 (0)