rayarachelian / lisaem-1.2.x

Apple Lisa Emulator v1.2.x
http://lisaem.sunder.net
Other
36 stars 11 forks source link

LisaEm crashes on boot #13

Closed debounce2 closed 4 years ago

debounce2 commented 4 years ago

I built the latest code on Linux but when trying to boot LOS, the emulator crashes with SIGSEGV (Address boundary error). It will boot from a LOS floppy but the cursor does not work properly. Regardless of where the Host Cursor is, the Lisa cursor will only show along the bottom or right side of the screen along with some graphical artifacts of the menu bar. The cursor works properly on the boot device selection screen.

I am running 1.2.6.2 instead and aside from having to add a CXX flag -Wno-narrowing to build.sh, it boots without problems. I had some issues on 1.2.6.2 as well. I was never able to get Double X, Triple Y screen mode to work. I could never get the serial port working either. I made sure I had permissions for the device, I set Lisa Terminal to 9600 baud, but after pressing a few keys, I'd get stuck on an hour glass. I tried using a local device, loopback device, and a serial device connected to a console server but they all seemed to have the same problem.

debounce2 commented 4 years ago

This is what I get from the debugger on the latest code when trying to boot LOS.

Thread 1 "lisaem" received signal SIGSEGV, Segmentation fault.
cpu68k_ipc (addr68k=524758, iib=0x0, ipc=0x7fffc892d1a0) at cpu68k.c:348
348     ipc->clks    = iib->clocks;
debounce2 commented 4 years ago

It's trying to dereference a null iib. There's a check for that in cpu68k.c but it's behind #ifdef DEBUG. If I define DEBUG I get a compiler error. If I remove the #ifdef at cpu68k.c:L331, I do get EXIT(123,0,"Received NULL IIB!");

rayarachelian commented 4 years ago

Hi, so I'm probably not going to work on the 1.2.6 branch anymore as 1.2.7 is eating up most of my free time. That said IIB errors are a sign of either the LOS floppy being corrupted or something having gone catastrophically wrong with compiler #defines (i.e. misjudging uint32 byte size, or something like that), or memory getting corrupted. I did fix some MMU issues that were in 1.2.6 in 1.2.7, so it's possible that's what you're seeing, but you should be able to boot off of LOS and run the installer, so this is a bit weird.

2X3Y is broken in 1.2.6 and the currently pushed 1.2.7, though I just fixed 2X3Y locally as well as some crashes around enabling/disabling skins and switching scale, though there might be more such edge cases,

I'm currently fixing some other bugs around the hqx upscaler, and I need to test drag and drop, after which I'll push to github again. I intended to push to 1.2.7 last week, but found more bugs, so want to fix those first.

I'll see about testing the serial port code when I get a chance - are you trying to access a physical USB<->serial port device, telnetd, or a pty or something else?

Can you tell me what C compiler (gcc vs llvm/clang) and version you're using, and also which wxWidgets versions, and did you compile it yourself or was it a package? Might help to know which Linux you're running as well, though that's likely less of an issue.

Also if you recall, where did you get the LOS image? Is it 2.x? 3.0? 3.1?

Thanks.

debounce2 commented 4 years ago

Thank you for the help. The IIB crashes are on 1.2.7 (latest master) so if I can get that working, then I don't have a need for running 1.2.6. I am using gcc 7.4.0 and wxWidgets 3.0.4, both installed via apt-get on Xubuntu 18.04. I also built 1.2.6 from source on the same system and it does not have the IIB crash. I am using LOS 3.1. I do not have any issues booting from the same ProFile image or install floppy on 1.2.6.

For the serial port, I tried using a USB serial device connected to a console server, I tried a loopback serial device using socat, and a pty device. I had no success in seeing anything sent by the emulator. I am using the default Lisa Terminal config except with baud rate set to 9600.

debounce2 commented 4 years ago

I built wxWidgets 3.1.3 from source and compiled against that. No change.

debounce2 commented 4 years ago

Before the seg fault, I see

reg68k.c:reg68k_external_execute:1416:Invalid instruction @ 000801D6

I checked and found fetchword(reg68k_pc) returns 252.

rayarachelian commented 4 years ago

So I downloaded and installed Xubuntu 18.04.3 in a VM (I'm on ubuntu 18.04.3, so probably overkill to test these issues), and I've compiled a fresh wxWidgets 3.1.3 and LisaEm 1.2.7 in the VM.

wx3.1.3 is throwing tons of warnings about fonts and pango and g_object_unref: assertion 'G_IS_OBJECT (object)' failed , so it's slowing it down quite a bit even at 128Mhz.

I probably need to recompile wx3.1.3 and ensure that debug is disabled.

I also downloaded a fresh H ROM from bitsavers and a fresh copy of LOS from the Apple_Lisa_TOSEC_2012_04_23.zip off archive.org. (For some reason bitsavers doesn't seem to have LOS 3.1, and the TOSEC doesn't contain ROMs.)

It ran the first disk of the LOS 3.1 installer just fine, but I see output errors saying COPS queue overflow, so something somewhere is messing up the keyboard/mouse buffer which explains your mouse issue (well there's two bugs there, one if you run skinless and this new one.)

The COPS overflow might be a new bug that's not in the code here on github - I've rewritten the clipboard paste routines to support dragging and dropping text from, say, a text editor, into LPW Edit...

Once, I did get a segfault when I tried to do File->Preferences, not sure what's going on there, but will test that too. I didn't see that on Ubuntu 18.04 with wx3.1.2.

Now, that returned value of 252 is one of the F-line trap instructions. Now, if you run ROMless, LisaEm has just enough code to do HLE to be able to boot Lisa Office System 3.x without a ROM, but if you're using another OS, or maybe LOS 1.x or LOS 2.x, it possibly called something unhandled, but more likely it went off the deep end.

I'd check to make sure you have a known good copy of LOS 3.x and a known good H ROM. You can play with other versions later, but just as a sanity check start with these.

rayarachelian commented 4 years ago

About the serial ports, the baud rate from LisaTerminal is ignored, and will run much faster than a normal serial port can handle if you push the CPU throttle all the way up to whatever your machine can handle without overheating. However, on the HOST side, it doesn't understand anything about TTYs, so it's not going to stty the baud rate or anything like that, but it can open the port and talk to it bidirectionally, so might need some bash script to setup the USB serial port ahead of time, and then point the device in preferences to it. If that doesn't work, I'll see about adding actual serial port support. (I mostly used the telnetd server in LisaEm to talk to LisaTerm and also as a way to dump a text file out, but the uucp cu command and the like should work, I think.)

debounce2 commented 4 years ago

I downloaded 341-0175-H and 341-0176-H from bitsavers and LOS 3.0 from TOSEC. I deleted my conf file to start over and created a new ProFile. I get the cursor issue when booting LOS 3.0 from floppy. The mouse doesn't work so I can't install LOS. After this I tried my old ProFile image of LOS 3.1 and it crashes the same as before.

I mainly want serial access to a shell on the host. If I could get a shell, then I can use screen or whatever from there.

rayarachelian commented 4 years ago

So I was able to replicate the crash you're seeing, looks like there's some new fairly serious IPCT free/used bugs that I hadn't caught before. Somehow to used list becomes negative, which it should never do. So it's not the LOS disk image at all.

Working on those now. Rolling back cops.c to the version from 1.2.6.2.1 fixes the mouse issue in skinned mode (though skinless is still broken due to location calculation issues). (An error or two was introduced in cops.c when I attempted to get rid of all the may-fallthrough and other warnings, but now I'll need to carefully diff the two files and see where the actual bug is.)

I'll push to github again once I fix most of these, the IPCT ones are a total blocker as with that bug the emulator won't work for very long.

In terms of attaching LisaTerm to a real serial port, I'll see about adding some calls to poll to the serial port FILE method, or add another method for directly talking to TTYs/PTYs; FILE is the closest thing that would work, but it's going to pause the emulator on a real port when there's no incoming bytes.

Linking socat between your USB serial device and the telnetd port LisaEm listens to is the most likely to work right now, but I've not tested it. Something like: socat /dev/ttyUSB0,raw,echo=0,crnl TCP4:127.0.0.1:9300 might work assuming that socat is bidirectional - I'm basing this on: http://technostuff.blogspot.com/2008/10/some-useful-socat-commands.html

But long term, I agree with you that I should add direct support for this within LisaEm instead.

Many thanks for the bug report as it helped me uncover a few nasty bugs in addition to what you originally reported.

rayarachelian commented 4 years ago

Hi, just pushed to v1.2.7-DEV (and shadowed the same to master), please try it out. Thanks -- Ray.

debounce2 commented 4 years ago

Hey, I didn't have a chance to test until now. Thank you for the updates. I can boot LOS from a ProFile image and the install disk.

New issue compared to 1.2.6.2 is I see is graphical artifacts around the cursor like flashing parts of the menu bar and the top of the screen. 2X3Y has the image shifted to the right cutting off the right side of the image.

I tried using telnetd option for the serial port. I can connect via telnet but when I type within LisaTerminal, for example asdf, I will see on the telnet client only the second letter, in this case s and then the emulator freezes. If I try to type anything to send to the Lisa, it also freezes.

rayarachelian commented 4 years ago

Thanks, I will look into this in a few days to another week, after I get the current changes in a stable state. I'm currently rewriting the build script system to a newer version, as I have to do that anyway for windows support, since wxdsgn seems to have been abandoned.

Off the top of my head all the skinless modes (including 2x3y) have broken mouse locations currently, not sure why you're still seeing display artifacts from the menu bar - perhaps some calculation in the LisaEmFrame::OnPaint_skinless method is off. I did see the skinless modes are shifted a bit to the right as well. Pls use the HQX, raw, or AAG mode with skins for now if you can.

I've opened another issue to track the serial port issues, so will look into the telnetd as well. Not sure what's causing it to fail. Last I tested the telnetd code, I was on macos 10.7 or 10.8 or so, so perhaps something is incompatible with modern Linux in that code.