emsec / hal

HAL – The Hardware Analyzer
MIT License
618 stars 75 forks source link

Empty VHDL Port Map crashes HAL #124

Closed swallat closed 3 years ago

swallat commented 5 years ago

Describe the bug When parsing an incorrect VHDL netlist, with empty port maps of gates HAL crashes.

Expected behavior hal should print an error and continue working.

issue-label-bot[bot] commented 5 years ago

Issue-Label Bot is automatically applying the label Type: Bug to this issue, with a confidence of 0.98. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

swallat commented 5 years ago

@devhoffmann What would you suggest? Error message or crash?

not-a-trojan commented 5 years ago

I think we should depend on correct input, i.e. on any error we abort parsing and return a nullptr which will result in an error message.

RenWal commented 5 years ago

I think this is happening in this piece of code: https://github.com/emsec/hal/blob/777a911ad2a0d11dc4c5b983812d6e5ea6a5a478/src/hdl_parser/hdl_parser_vhdl.cpp#L437 The code expects either a generic map or port map and sets pos accordingly. If neither map exists, then type.substr(pos) with pos=MAX_INT is called, causing substr to abort.

Minimal example for the crash:

begin
end;
swallat commented 4 years ago

@RenWal @devhoffmann What is the state of this issue?

RenWal commented 4 years ago

I can't reproduce this issue anymore and assume it has been fixed as a side-effect of restructuring the VHDL parser. @swallat do you happen to still have the netlist that caused the crash back when you reported this? If so, do you mind re-testing against the current master?