Closed X4 closed 8 years ago
Does this problem only replicate when running as a systemd service? Can you get a core dump and look at a backtrace?
Shortin uses mlockall() (master_server.c:146) to lock its memory into physical RAM to prevent it from using the swap file. Maybe it fails to allocate the memory due to some limit (http://sanketpadawe.blogspot.se/2012/06/prevent-page-locking-when-using.html)?
I think the mlockall() warning is a red herring. The master server continues on, and should behave fine without mlockall() succeeding, as far as I can see. @X4 I believe by default systemd throws corefiles into the journal, and you can access them with systemd-coredumpctl.
I have some reservations about shortfin using mlockall() at all. Especially MCL_FUTURE | MCL_CURRENT. That is expensive. I'd rely on the OS to properly handle paging.
It also happens when I run shortfin without systemd.
systemd-coredumpctl ✱ ◼ No coredumps found
I don't have coredumps enabled, but I posted two different cases, one segfaults because I ^C, the other just keeps shortfin running in the background or foreground depending on the daemonize flag. In all cases I can't access shortfin on localhost:88/
./shortfin -c shortfin.conf
ERROR mlockall: Cannot allocate memory
* Loading configuration file 'shortfin.conf'...
* Daemonizing...
I looked into this a bit this morning. The segfault when shortfin's not running in daemon mode, and you ^C is due to the signal handler using uninitialized data. As far as I can tell, the data the signal handler uses is never initialized, so that's likely the root cause in daemon mode, too.
Also, I suspect the failure to load virtual server configuration is the root cause of shortfin not responding on the configured port. As it exists now, there are two points where the configuration is loaded, and I suspect after the first load shortfin does a chdir(), which causes the second config load to fail.
Oh, I forgot to mention that also while debugging I discovered that shortfin is leaking shared memory segments, which is not good because after awhile shmget() fails due to -ENOSPC. I'm still trying to wrap my head around the worker thread model...
Congrats :+1: "That was a really productive morning @joshcartwright" Glad you found the cause of it.
I'm still having fun with all kinds of webservers, like monkeyhttpd,nxweb,lwan,gwan,nginx,shortfin,lighttpd,webmachine and many many more.
One way to test out my chdir() theory would be to give shortfin the absolute path to your configuration file.