IDE: Water 10.0.0.2331
Version: Version 10.0.0.2331 (develop) built on talax, 20180928-142533. Commit 8e4eb02
Target: Island (Linux)
Description: An Island console application, if run as Linux init process, hangs without (apparently) even entering Main (or whatever entry point is defined).
Expected Behavior: As long as the application code does not rely on conditions which are not true at the time the init process starts (root filesystem being writable, proc and sys filesystems in place, etc.) it should be able to at least use Linux system calls via rtl.
Actual Behavior: Screen cleared. Flashing cursor. Forever.
I’ll outline the steps to reproduce this behavior on a Raspberry Pi 2B, 3B, or 3B+.
- Download the latest Raspbian Stretch Lite image from here
- Write the image to a MicroSD card, using Win32 Disk Imager or similar program of your choice
- Create a new C# Island project in Water, using the “Console Application (Linux)” template
- Build for
- Copy the resulting executable
ConsoleApplicationto the VFAT partition of the Raspbian MicroSD card
cmdline.txtwith a text editor, perform the following replacements, save and exit:
- Safely disconnect the MicroSD card and put it in the Raspberry Pi
- Turn on the raspberry Pi (which should have a monitor connected to its HDMI port)
- After the so-called “rainbow screen”, you should see the message printed by your application (“The magic happens here.”) followed by a kernel crash (which is expected, given that an init process should not terminate normally but reboot or shut down the system instead).
- Instead, the screen stays blank with a flashing cursor in the upper-right corner.
- This looks like a problem with the application startup code making some “dangerous” assumptions about the state of the system
- An init process is not necessarily a C program; a bash script can run as init, as long as you have bash available (which is not the case here, because the EXT4 partition is not mounted at application startup time)
- A compiled Go program can run as init process. It has been done by these guys on a Raspberry Pi 2B and I personally verified it works on a 3B+ too.
- I’m aware that using the VFAT partition as root makes any assumption about the system even more dangerous.
Unfortunately, root is the only filesystem mounted at init startup time, and the application cannot be copied on the EXT4 partition from Windows.