d-iii-s / msim

Light-weight MIPS R4000 and RISC-V system simulator
https://d3s.mff.cuni.cz/software/msim/
GNU General Public License v2.0
5 stars 5 forks source link

Segfault on macOS #75

Open HanyzPAPU opened 1 month ago

HanyzPAPU commented 1 month ago

The clear_history() call in input.c:188 segfaults when msim is compiled on mac.

I found out that this is caused because instead of GNU Readline, macOS is distributed with BSD editline, which provides a mock implementation if the readline API. There is one crucial difference: the editline mock does not call the using_history() (link) function and thus does not initialize the history state.

Adding the using_history() call to the initializer solves the issue. An alternative solution would be to manually link msim with readline instead of relying on the system library.

HanyzPAPU commented 1 month ago

Would it be safe to call using_history() even with GNU Readline? The history would technically get initialized twice.

vhotspur commented 3 weeks ago

Looking at the documentation and into the official examples I think we should call using_history ourselves and it is a bug to not call it.

Generally I would prefer if we would be able to work with the editline to simplify the building process a bit.

Perhaps we should add building on Mac to our GitHub Actions too?

HanyzPAPU commented 3 weeks ago

From what I've seen, there were one or two students using Mac each year. I think it would be a good idea to have MSIM prebuilt for them.