MCJack123 / craftos2

A fast, modern, and feature-filled ComputerCraft emulator written in C++.
https://www.craftos-pc.cc
Other
217 stars 25 forks source link

Segmentation fault when raising an error from within a debug hook #326

Closed viluon closed 10 months ago

viluon commented 10 months ago

Describe the bug A segmentation fault in CraftOS-PC (not the LuaJIT version) involving line and instruction count debug hooks, likely when raising an error from a debug hook running in an xpcall context.

To reproduce Steps to reproduce the behaviour:

  1. Get bench
  2. Profile the hello program: bench hello (adjust the path as necessary)
  3. Repeat step 2. until CraftOS-PC crashes.

Expected behaviour Should not crash.

Screenshots bench-hello-crashing-craftos-pc.webm

Uh oh, CraftOS-PC has crashed! Reason: Segmentation fault (11). Please report this to https://www.craftos-pc.cc/bugreport. Paste the following text under the 'Screenshots' section:
OS: Linux
Address is (nil) from 0x7f8cd64f4fd8
Last C function: os_epoch
[bt]: (1) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(lua_pushlightuserdata+0x18) [0x7f8cd64f4fd8]
[bt]: (2) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(lua_pushlightuserdata+0x18) [0x7f8cd64f4fd8]
[bt]: (3) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x22718) [0x7f8cd650c718]
[bt]: (4) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x10147) [0x7f8cd64fa147]
[bt]: (5) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x1d865) [0x7f8cd6507865]
[bt]: (6) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0xfd98) [0x7f8cd64f9d98]
[bt]: (7) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(lua_vpcall+0xf5) [0x7f8cd64f5915]
[bt]: (8) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x20fa4) [0x7f8cd650afa4]
[bt]: (9) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x10798) [0x7f8cd64fa798]
[bt]: (10) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x1d2db) [0x7f8cd65072db]
[bt]: (11) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x10d88) [0x7f8cd64fad88]
[bt]: (12) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0xf9bb) [0x7f8cd64f99bb]
[bt]: (13) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(lua_resume+0xd5) [0x7f8cd64fae75]
[bt]: (14) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x21b28) [0x7f8cd650bb28]
[bt]: (15) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x21c31) [0x7f8cd650bc31]
[bt]: (16) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x10798) [0x7f8cd64fa798]
[bt]: (17) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x1d2db) [0x7f8cd65072db]
[bt]: (18) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x1041d) [0x7f8cd64fa41d]
[bt]: (19) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0xf9bb) [0x7f8cd64f99bb]
[bt]: (20) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(lua_resume+0xd5) [0x7f8cd64fae75]
[bt]: (21) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x21b28) [0x7f8cd650bb28]
[bt]: (22) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x21c31) [0x7f8cd650bc31]
[bt]: (23) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x10798) [0x7f8cd64fa798]
[bt]: (24) /nix/store/9rmm911zm54960jbhs83xlryz1aks1xf-craftos-pc-2.7.4/lib/liblua.so(+0x1d2db) [0x7f8cd65072db]
Segmentation fault (core dumped)

Environment (please complete the following information):

Additional context Works fine on CCEmuX.

MCJack123 commented 10 months ago

This has been fixed as of cd1e574b1f223b137fb78af7cdfd37d739591ce5.