gugod / App-perlbrew

Manage perl installations in your $HOME
https://perlbrew.pl
Other
720 stars 216 forks source link

Script doesn't free port on exit using a relocatable Perl build #736

Open michaelherger opened 2 years ago

michaelherger commented 2 years ago

I'm trying to build a relocatable Perl to run Logitech Media Server. I've successfully created a 5.34.0 build on a M1 Mac Mini (macOS 12.2). I can copy the custom Perl builds to a bundle and run LMS from there. But I fail to do the same on x86_64.

I've built Perl and dependencies on two different computers (macOS 12.2, 12.3), 5.34 and 5.32. Both execute the script perfectly fine, as long as I don't move the Perl. Once I access it from a copy outside the ~/perl5/perlbrew/perls folder, I can run LMS exactly once (no problem there at all!). But once I stop it, I'm no longer able to restart it. Whenever I try to open the necessary UDP port, I'd get an "Address already in use" error. macOS netstat or lsof don't see anything using the port. Yet it's not available any more. I couldn't use it with netcat or the like either. The port is busy. So there seems to be a problem shutting down the port on exit. But only if I use the Perl from a folder outside its build target folder.

I was using variants of the following install line:

MACOSX_DEPLOYMENT_TARGET=10.12 perlbrew install -D usethreads -D userelocatableinc -Dman1dir=none -Dman3dir=none -j4 perl-5.34.0

Tried changing the target to 10.15 and 11.0, and Perl 5.34.0 and 5.32.1, but that didn't help.

I'm trying to come up with the simplest script possible to reproduce the issue. But LMS is a beast... The instruction where it fails can be found here.

I would be very grateful if anybody could give me any hint as to where to look for a solution.

michaelherger commented 2 years ago

Interesting: it seems this only happens if the Mac's firewall is enabled. I disabled it on one of those machines, rebooted, and I was able to start/stop LMS.

Ok, so it's the Mac's firewall which would, under certain circumstances, not free a port. How can that be dependent on the place where perl is stored?!?