[MDEV-12778] mariadb-10.1 FTBFS on GNU/Hurd due to use of PATH_MAX Created: 2017-05-10 Updated: 2020-12-08 Resolved: 2017-07-18 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Compiling |
| Affects Version/s: | 10.1.23 |
| Fix Version/s: | 10.1.26, 5.5.57, 10.0.32, 10.2.8 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Svante Signell | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Debian GNU/Hurd i386 and DEbian GNU/Linux amd64 |
||
| Attachments: |
|
| Description |
|
Attached are patches to make mariadb-10.1 to build on GNU/Hurd. Unfortunately The current debian version is at 10.1.23-6. Since there is a freeze going on and since the GNU patches are also affecting other OSes it would be nice if the patches are accepted upstream. If so, they are easily motivation to be accepted in Debian, including the imminent Stretch release. |
| Comments |
| Comment by Sergei Golubchik [ 2017-05-17 ] | ||||||||||||||||||||||||||
|
What was the issue with O_EXEC? Why _GNU_SOURCE in mysys_priv.h? It's already redundantly defined in my_config.h and my_global.h. It seems like groonga preferred select, when both poll and select were available, and you've changed it to prefer poll. Why? What's the PATH_MAX issue that you fix? No PATH_MAX on GNU/Hurd? I can simply define PATH_MAX to be 512 if it isn't defined. Would that work for you? Besides, your realpath() changes in NOSYMLINK_FUNCTION_BODY are broken, realpath() needs only one argument being NULL, not both — how would it know what path to convert? — and even if it'd work, you forgot to free buf at the end | ||||||||||||||||||||||||||
| Comment by Svante Signell [ 2017-05-25 ] | ||||||||||||||||||||||||||
|
I tried to reply by email to jira@mariadb.org but that failed. Pasting my reply here instead. > Sergei Golubchik commented on The issue is that O_PATH is not defined on GNU/Hurd and O_EXEC is not either > Why _GNU_SOURCE in mysys_priv.h? It's already redundantly defined in If _GNU_SOURCE is already defined this part is not needed and can safely be > It seems like groonga preferred select, when both poll and select were Well, the build on GNU/Hurd defined USE_POLL, not USE_SELECT. I did not take the > What's the PATH_MAX issue that you fix? No PATH_MAX on GNU/Hurd? I can PATH_MAX is never and will never be defined on GNU/Hurd it's bad coding to use realpath(3) use 2 arguments:
and the patch use two too:
The usage of the function CREATE_NOSYMLINK_FUNCTION defined in mysys_priv.h The eventual need of freeing the buffer happen at my_delete.c:
There a free(pathname); would be eventually needed. In the original code Thanks for your review. Hope things are clearer by now. I'm looking forward to | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-05-25 ] | ||||||||||||||||||||||||||
|
Thanks. Few more questions:
| ||||||||||||||||||||||||||
| Comment by Svante Signell [ 2017-06-01 ] | ||||||||||||||||||||||||||
Sorry no. the O_* definitions are mainly in /usr/include/i386-gnu/bits/fcntl.h
Unfortunately the best documentation is the source code itself: gnumach, hurd and glibc.
both <poll.h> and <sys/poll.h> are available. <poll.h> contains: #include <sys/poll.h> | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-06-01 ] | ||||||||||||||||||||||||||
|
One more question. The purpose of my_open_parent_dir_nosymlinks() is to take a path and to open one path component after the other using openat(), while making sure that no path component in a symlink. O_PATH, O_SEARCH, O_EXEC — they all serve this goal. Their semantics is different (O_SEARCH/O_EXEC will fail to open a symlink, O_PATH will open the symlink itself, and the next openat() will fail), but the end result is the same — an error, if there is a symlink in the path. Can this be done with GNU/Hurd? if not, I'll fall back to realpath()/strcmp() approach. | ||||||||||||||||||||||||||
| Comment by Svante Signell [ 2017-06-01 ] | ||||||||||||||||||||||||||
|
On Hurd there is: /usr/include/i386-gnu/bits/fcntl.h
At least the open(2)and openat(2) manpages describes this flag. Maybe usable? HTH | ||||||||||||||||||||||||||
| Comment by Svante Signell [ 2017-06-08 ] | ||||||||||||||||||||||||||
|
ping? | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-06-08 ] | ||||||||||||||||||||||||||
|
Nothing happened yet. See the release schedule at https://jira.mariadb.org and expect some activity here closer to the release date. Discussions take time, so I was asking questions well before the release, but I don't have questions anymore and the fix will happen, probably, within a week before a release. | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-06-14 ] | ||||||||||||||||||||||||||
|
gnu_srs, now I remember why O_NOFOLLOW alone is not enough. Opening a directory with O_NOFOLLOW will fail if the directory is not readable. But we don't need readable, we only need executable bit, because ultimately we want to open a file inside the directory. Using O_NOFOLLOW would require all path components up to the actual table file be readable by the mysql user. So, if GNU/Hurd has no way of opening a directory without requiring it to be readable, then I won't be able to use openat on GNU/Hurd. | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-06-14 ] | ||||||||||||||||||||||||||
|
cmake.patch:
| ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-06-14 ] | ||||||||||||||||||||||||||
|
gnu_srs, as I don't have GNU/Hurd, could you please try this patch — hurd-pathmax.diff | ||||||||||||||||||||||||||
| Comment by Svante Signell [ 2017-06-16 ] | ||||||||||||||||||||||||||
|
The PATH_MAX part of hurd-pathmax.diff would work. But why do you keep the PATH_MAX code for non-hurd? All POSIX.1-2008 compliant systems do support realpath(whatever, NULL) (sorry for the switched arguments in realpath(). Regarding #define _GNU_SOURCE it is needed, otherwise Lmid_t is not defined when including /usr/include/link.h. It is defined in /usr/include/dlfcn.h included by link.h. For the fsecond part of the path_max.patch you removed, For the USE_SELECT parts, the debian package build cannot easily disable the mroonga plugin, it is a separate package being built for arcihtectures: Architecture: any-alpha any-amd64 any-arm any-arm64 any-i386 any-ia64 any-mips64el any-mips64r6el any-mipsel any-mipsr6el any-nios2 any-powerpcel any-ppc64el any-sh3 any-sh4 any-tilegx I'll propose an updated patch soon. | ||||||||||||||||||||||||||
| Comment by Svante Signell [ 2017-06-16 ] | ||||||||||||||||||||||||||
|
New patch: path_max_new.patch attached. | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-06-16 ] | ||||||||||||||||||||||||||
|
I'm sorry, I don't understand.
_GNU_SOURCE is unconditionally defined in my_config.h, which is included at the beginning of my_global.h which is included first into mysys_priv.h. Why would you need to define _GNU_SOURCE in mysys_priv.h again?
I don't understand that either. The code is
So, precisely, when O_EXEC is not defined (e.g. on GNU/Hurd) there will be no #define O_PATH O_EXEC.
To avoid unnecessary mallocs. | ||||||||||||||||||||||||||
| Comment by Svante Signell [ 2017-06-16 ] | ||||||||||||||||||||||||||
|
Sorry about O_EXEC: It is defined on GNU/Hurd but defining O_PATH would make my_open_parent_dir_nosymlinks() used in macro NOSYMLINK_FUNCTION_BODY(AT,NOAT) instead of the definition using realpath(). I'll be back on the _GNU_SOURCE later. Have to recompile without _GNU_SOURCE and issue gcc -E ... to see where things go wrong. | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-06-16 ] | ||||||||||||||||||||||||||
|
Okay, I see. So GNU/Hurd does have O_EXEC. Why do you try to avoid my_open_parent_dir_nosymlinks()? Because O_EXEC has a different semantics on GNU/Hurd? What semantics is it? May be, because GNU/Hurd does not have openat? | ||||||||||||||||||||||||||
| Comment by Svante Signell [ 2017-06-16 ] | ||||||||||||||||||||||||||
|
From what I remember that function, my_open_parent_dir_nosymlinks(), does introduce another PATH_MAX issue (sigh). I did not invest the time to avoid another PATH_MAX issue by making it PATH_MAX -free. OK; I was lazy, admitted. (Will you ever learn not to use PATH_MAX? Perhaps using a fixed size if you want to avoid malloc) | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-06-19 ] | ||||||||||||||||||||||||||
|
Okay. I've fixed my_open_parent_dir_nosymlinks() not to use PATH_MAX. You should try to use my_open_parent_dir_nosymlinks() if possible, because it's the only race-condition safe way to open symlinked tables. As far as your poll/select changes are concerned, I don't understand them either
to
but that couldn't have made any difference, because Groonga always defines only one of the four USE_SELECT, USE_POLL, USE_EPOLL, USE_KQUEUE. In your case, judging from your CMakeCache.txt | ||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2017-07-18 ] | ||||||||||||||||||||||||||
|
gnu_srs, I'm closing this issue.The subject says "due to use of PATH_MAX" and PATH_MAX related changes are in 5.5.57. 5.5.57 is released now and we cannot have this issue "half-fixed" in one version and "rest-fixed" in the other. So let's close this one as "PATH_MAX" problem. And if you need poll/select changes, please, open a new issue for them (and mention this one, so that you wouldn't need to describe everything again). |