Created attachment 159230 [details] Patch file (including plist) Attached is a patch to update Mono 4.0.1 to 4.0.3.19 in Ports.
Great, you might also want to have a look at https://github.com/mono/mono/pull/1863 (filed as https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200783) which makes us free from /proc. This got merged into git master, maybe we can ask Mono to backport this to 4.0.3 as well. There is also https://github.com/mono/mono/pull/1860 to fix mono on systems without $TZ set. There is also some work in progress in https://github.com/mono/mono/pull/1882 to improve checks against iconv, maybe we could even make it to use base system iconv.
Build-tests on cur 93a 10x 10i are fine.
Reviewing ATM (I had a previous version in the pipeline). The patch contains some weird files… Please double-check this when you submit a PR. Also, why was the CPE information removed from the uses? Lastly, I encounter a strange behavior when building the port form my "usual" directory: /usr/home/romain/Projects/FreeBSD/ports/lang/mono. The problems ties down to getcwd(3) returing NULL with errno set to 0 when actually the passed buffer is too small. Am I the only one suffering from this issue?
Created attachment 159689 [details] Workaround for getcwd(3) returning NULL with errno set to 0. A minimal test program does not produce this incorrect behavior… I guess something magic is happening.
You certainly don't want || here because errno maybe set to something before the whole thing starts. Your getcwd() fails because of some other reason ("make clean" done in the other window?) The problem with this code is that it does not say anything meaningful in non-ERANGE case. Can you check what it says in your case? --- a/eglib/src/gfile-posix.c +++ b/eglib/src/gfile-posix.c @@ -175,6 +175,8 @@ g_get_current_dir (void) s <<= 1; } } while (fail); + if (r == NULL) + perror("getcwd"); /* On amd64 sometimes the bottom 32-bits of r == the bottom 32-bits of buffer * but the top 32-bits of r have overflown to 0xffffffff (seriously wtf getcwd
Aleady tried: getcwd() returns NULL and errno = 0. Ignoring the errno value and looping while getcwd() returns NULL increases the buffer size until the CWD fits and then everything is fine. My guess is that the system getcwd(3) function is masked and replaced by some other code that has this incorrect behavior, but I could not check any further.
Btw, build-tests for 4.0.3.20 were fine as well 8-}
No, they are using original getcwd(3) but I don't see the case where getcwd(3) returns NULL AND errno = 0 - very strange! Anything special about your directory?
I am using 4.0.3.20. I build mono as a regular user from a subdir of this user's $HOME directory where the ports has been checked-out. Without patching eglib, the build fails when building mscorlib.dll: ~~~ [...] mkdir -p -- ../../class/lib/build/ MCS [build] mscorlib.dll Cannot determine the text encoding for the assembly location: X±/class/lib/basic/basic.exe Please add the correct encoding to MONO_EXTERNAL_ENCODINGS and try again. ../../build/library.make:270: recipe for target '../../class/lib/build/mscorlib.dll' failed gmake[9]: *** [../../class/lib/build/mscorlib.dll] Error 255 ../../build/rules.make:143: recipe for target 'do-all' failed gmake[8]: *** [do-all] Error 2 ../build/rules.make:164: recipe for target 'all-recursive' failed gmake[7]: *** [all-recursive] Error 1 build/rules.make:164: recipe for target 'all-recursive' failed gmake[6]: *** [all-recursive] Error 1 Makefile:45: recipe for target 'profile-do--build--all' failed gmake[5]: *** [profile-do--build--all] Error 2 Makefile:41: recipe for target 'profiles-do--all' failed gmake[4]: *** [profiles-do--all] Error 2 Makefile:555: recipe for target 'all-local' failed gmake[3]: *** [all-local] Error 2 gmake[3]: Leaving directory '/usr/home/romain/Projects/FreeBSD/ports/lang/mono/work/mono-4.0.3/runtime' Makefile:522: recipe for target 'all-recursive' failed gmake[2]: *** [all-recursive] Error 1 gmake[2]: Leaving directory '/usr/home/romain/Projects/FreeBSD/ports/lang/mono/work/mono-4.0.3' Makefile:449: recipe for target 'all' failed gmake[1]: *** [all] Error 2 gmake[1]: Leaving directory '/usr/home/romain/Projects/FreeBSD/ports/lang/mono/work/mono-4.0.3' ~~~ Notice the garbage at the beginning of the assembly location.
Created attachment 159690 [details] Tidy-up workaround patch Only loop if the buffer is too short (normal case) or if getcwd(3) returned NULL and errno is still 0 (our unexpected condition); keep the initial behavior otherwise (likely to cause problems anyway).
(In reply to Romain Tartière from comment #10) Yeah, that's better - but I am very frustrated how we got there. Which FreeBSD version are you using? I've been toying with mono on 10.1-STABLE without any such problems...
(In reply to Marcin Cieślak from comment #11) 10-STABLE here too: % uname -v FreeBSD 10.2-PRERELEASE #21 r286362: Thu Aug 6 17:27:51 CEST 2015 root@marvin.blogreen.org:/usr/obj/usr/src/sys/MARVIN Do you experience this problem on your system copying /usr/ports/lang/mono to some directory with a longer name?
Just tried git mono in /home/saper/something/pretty/long/maybe/getcwd/breaks/this/way/who/knows/mono and everything worked fine (with mono git master), but eglib is pretty much the same. It's quite older than yours, r283908.
Did you try single stepping via this code and libc to see what actually happens?
Forgot to link r394390 to this PR.(In reply to Marcin Cieślak from comment #14) My time constraints do not allow me to do this soon. I have committed my update to 4.0.3.20 as r394390.