Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 619370 - =sys-apps/openrc-0.26.2: rc-depend seg faults on uclibc-ng
Summary: =sys-apps/openrc-0.26.2: rc-depend seg faults on uclibc-ng
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal critical (vote)
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: uclibc-porting
  Show dependency tree
 
Reported: 2017-05-22 15:04 UTC by Anthony Basile
Modified: 2017-08-10 10:06 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Basile gentoo-dev 2017-05-22 15:04:34 UTC
This is a regression introduced by =sys-apps/openrc-0.26.2.  It is critical in that it leaves a system unbootable.  I'm masking >sys-apps/openrc-0.24.2 on all uclibc profiles
Comment 1 Anthony Basile gentoo-dev 2017-05-23 22:09:12 UTC
Actually, all versions of openrc after 0.23.2 are broken so I'm restricting the mask to >sys-apps/openrc-0.23.2
Comment 2 Anthony Basile gentoo-dev 2017-05-24 13:54:41 UTC
This problem was introduced with commit 074d90f5 which just dropped -D_BSD_SOURCE from CPPFLAGS in mk/os-Linux.mk.  This was to address bug #604666 about some compiler warnings.  I'm looking more deeply into what this macro is exposing (or hiding) when defined.
Comment 3 Anthony Basile gentoo-dev 2017-05-24 14:51:32 UTC
Two possible fixes:

1) we revert those changes in openrc.  This makes for compatibility with current uclibc-ng and <=sys-libs/glibc-2.19.  See man 7 feature_test_macros:

To allow code that requires _BSD_SOURCE in glibc 2.19 and earlier and _DEFAULT_SOURCE in glibc 2.20 and later to compile without warnings, define both _BSD_SOURCE and _DEFAULT_SOURCE

Note: we have glibc-2.17 and later in the tree.

2) I add _DEFAULT_SOURCE to uclibc-ng which it currently lacks.

I'm going to do the later anyhow, but I think that removing -D_BSD_SOURCES was premature even for glibc.
Comment 4 William Hubbs gentoo-dev 2017-05-25 19:11:13 UTC
(In reply to Anthony Basile from comment #3)
> Two possible fixes:
> 
> 1) we revert those changes in openrc.  This makes for compatibility with
> current uclibc-ng and <=sys-libs/glibc-2.19.  See man 7 feature_test_macros:
> 
> To allow code that requires _BSD_SOURCE in glibc 2.19 and earlier and
> _DEFAULT_SOURCE in glibc 2.20 and later to compile without warnings, define
> both _BSD_SOURCE and _DEFAULT_SOURCE
> 
> Note: we have glibc-2.17 and later in the tree.

I'm no expert on glibc, but 2.20+ has been stable for almost two years at this point. Also, I haven't received any requests from outside of Gentoo that I go back to the older versions.

Another thing to consider is that glibc-2.20+ has a hard requirement for >= Linux 2.6.32, and I don't think we have a kernel that old in the tree.

> 2) I add _DEFAULT_SOURCE to uclibc-ng which it currently lacks.
> 
> I'm going to do the later anyhow, but I think that removing -D_BSD_SOURCES
> was premature even for glibc.

As I said above, it has been almost two years and this is the first time I've heard of this issue, so although I can be convinced this was premature, I'm not convinced at this point.
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2017-05-28 18:44:41 UTC
Do you have a backtrace for peanut gallery?

It looks odd that openrc SIGSEGVs instead of printing what went wrong.
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2017-05-28 21:43:49 UTC
With https://github.com/OpenRC/openrc/pull/136 enabled openrc
is full of build erros on uclibc-ng, like:

libeinfo.c: In function 'colour_terminal':
libeinfo.c:466:4: error: implicit declaration of function 'strlcpy' [-Werror=implicit-function-declaration]
    strlcpy(tmp, tgoto(bold, 0, 0), sizeof(tmp));
    ^
libeinfo.c:466:4: warning: nested extern declaration of 'strlcpy' [-Wnested-externs]
libeinfo.c:467:4: error: implicit declaration of function 'strlcat' [-Werror=implicit-function-declaration]
    strlcat(tmp, tgoto(_af, 0, c & 0x07), sizeof(tmp));
    ^
libeinfo.c:467:4: warning: nested extern declaration of 'strlcat' [-Wnested-externs]
libeinfo.c: In function 'elogv':
libeinfo.c:525:3: error: implicit declaration of function 'vsyslog' [-Werror=implicit-function-declaration]
   vsyslog(level, fmt, apc);
   ^
libeinfo.c:525:3: warning: nested extern declaration of 'vsyslog' [-Wnested-externs]

These are clearly BSD functions, not POSIX. This change is enough to get
openrc-9999 building and running for me:

diff --git a/mk/os-Linux.mk b/mk/os-Linux.mk
index 3a3c5167..15666fca 100644
--- a/mk/os-Linux.mk
+++ b/mk/os-Linux.mk
@@ -11,7 +11,7 @@
 SFX=           .Linux.in
 PKG_PREFIX?=   /usr
 
-CPPFLAGS+=     -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700
+CPPFLAGS+=     -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700
 LIBDL=         -Wl,-Bdynamic -ldl
 
 ifeq (${MKSELINUX},yes)
diff --git a/src/rc/openrc-init.c b/src/rc/openrc-init.c
index 398259cc..c6611ab5 100644
--- a/src/rc/openrc-init.c
+++ b/src/rc/openrc-init.c
@@ -201,8 +201,10 @@ int main(int argc, char **argv)
                printf("PID1: Received \"%s\" from FIFO...\n", buf);
                if (strcmp(buf, "halt") == 0)
                        handle_shutdown("shutdown", RB_HALT_SYSTEM);
+#ifdef RB_KEXEC
                else if (strcmp(buf, "kexec") == 0)
                        handle_shutdown("reboot", RB_KEXEC);
+#endif
                else if (strcmp(buf, "poweroff") == 0)
                        handle_shutdown("shutdown", RB_POWER_OFF);
                else if (strcmp(buf, "reboot") == 0)
Comment 7 Anthony Basile gentoo-dev 2017-05-29 12:42:52 UTC
(In reply to Sergei Trofimovich from comment #5)
> Do you have a backtrace for peanut gallery?
> 
> It looks odd that openrc SIGSEGVs instead of printing what went wrong.

reverting the removal of -D_BSD_SOURCES is not the correct fix.  i'll be sending a patch to uclibc-ng@ the problem there.  this macro has been deprecated in favor of _DEFAULT_SOURCES.  man feature_test_macros(7)
Comment 8 William Hubbs gentoo-dev 2017-05-31 16:23:20 UTC
Hey all,

can someone on this bug tell me why OpenRC has -D_XOPEN_SOURCE=700 also
defined?

I removed it on glibc, and things seemed to compile fine, but I don't
know for sure why we need this macro for OpenRC and it would be very
helpful to know this. I did not commit the removal, it was just to test
here.

Thanks,

William
Comment 9 Anthony Basile gentoo-dev 2017-06-05 00:28:41 UTC
(In reply to William Hubbs from comment #8)
> Hey all,
> 
> can someone on this bug tell me why OpenRC has -D_XOPEN_SOURCE=700 also
> defined?
> 
> I removed it on glibc, and things seemed to compile fine, but I don't
> know for sure why we need this macro for OpenRC and it would be very
> helpful to know this. I did not commit the removal, it was just to test
> here.
> 
> Thanks,
> 
> William

Answering this question would require detailed knowledge of what functionalities are incorporated in openrc that assume X/Open 7 standards.  I don't know openrc well enough to answer that.
Comment 10 Anthony Basile gentoo-dev 2017-06-05 00:31:38 UTC
Upstream just pushed my patch that fixes this problem:

http://repo.or.cz/uclibc-ng.git/commit/526747a2bf6193f784a578b0b97cffaccb44e3df

I'll back port it to 1.0.24 and unmask openrc on the uclibc profiles when I stabilize 1.0.24 and upgrade all the stages.  I'll then drop <1.0.23 and we should be good.  It'll take me about 1 month.
Comment 11 Anthony Basile gentoo-dev 2017-08-10 10:06:25 UTC
Okay we should be done.  While the arm and mips stages still need rebuilding with uclibc-ng-1.0.25 and latest openrc, this should happen on the next round of builds.