mkvtoolnix/tests/test-558segfaults_issue_1780_part_1.rb
Moritz Bunkus 3055738c02 mkvmerge: make global destruction phase more deterministic
Several classes rely on other classes' and variables' presence during
their destruction. The most prominent case is various sub-classes of
mm_io_c using the debugging facilities, e.g. debugging_c. Therefore
debugging_c must still work when mm_io_c instances are closed.

Otherwise access to invalid memory will occur (a use after free),
e.g. by the destructor of mm_io_c calling debugging_c::operator()
accessing a std::vector or std::unordered_map that's already been
destructed.

For mkvmerge this means that ::exit() must not be called before all
instances of mm_io_c have been closed. This commit moves in that
direction by explicitly closing several resources stored in global
variables in the proper order before calling ::exit().

Fixes the following cases of #1780:

explorer🆔000000,sig:11,src:000000,op:flip1,pos:1
explorer🆔000001,sig:11,src:000000,op:flip1,pos:2
explorer🆔000608,sig:06,src:001761,op:int8,pos:135,val:-128
explorer🆔000738,sig:11,src:002531,op:int32,pos:126,val:be:+1
explorer🆔000740,sig:06,src:002531,op:ext_AO,pos:99
2016-09-06 23:01:23 +02:00

18 lines
612 B
Ruby
Executable File

#!/usr/bin/ruby -w
# T_558segfaults_issue_1780_part_1
describe "mkvmerge / various test cases for segfaults collected in issue 1780 part 1"
dir = "data/segfaults-assertions/issue-1780"
# "mkvmerge: make global destruction phase more deterministic"
%w{
explorer:id:000000,sig:11,src:000000,op:flip1,pos:1
explorer:id:000001,sig:11,src:000000,op:flip1,pos:2
explorer:id:000608,sig:06,src:001761,op:int8,pos:135,val:-128
explorer:id:000738,sig:11,src:002531,op:int32,pos:126,val:be:+1
explorer:id:000740,sig:06,src:002531,op:ext_AO,pos:99
}.each do |file|
test_merge "#{dir}/#{file}", :exit_code => :error
end