diwakergupta / stacks-blockchain-tob-audit

GNU General Public License v3.0
0 stars 0 forks source link

Panic in `DefinitionSorter::run` #16

Open smoelius opened 4 years ago

smoelius commented 4 years ago

The panic occurs at the unwrap in the following lines: https://github.com/trailofbits/x-audit-blockstack-core/blob/e2d3d5bae539d242851620e28129af6c4a9de642/src/vm/analysis/definition_sorter/mod.rs#L60-L63 The panic can be witnessed by adding the line

(a 0)

at the end of the following test contract: https://github.com/trailofbits/x-audit-blockstack-core/blob/e2d3d5bae539d242851620e28129af6c4a9de642/src/vm/analysis/definition_sorter/tests.rs#L58-L62 The problem appears to be: get_cycling_dependencies identifies the line (a 0) as contributing to a cycle, but the following line expects all such contributors to parse as definitions: https://github.com/trailofbits/x-audit-blockstack-core/blob/e2d3d5bae539d242851620e28129af6c4a9de642/src/vm/analysis/definition_sorter/mod.rs#L203 One way to resolve this issue is to remove the unwrap and change the above map to a filter_map.

lgalabru commented 4 years ago

Ha! I found out about this panic while working on the implementation of the traits, and fixed it. I just added and pushed a test case here: https://github.com/blockstack/blockstack-core/pull/1246/commits/0cc0da6f627fd752bf6b7edc4943237b4437b324