Opened 8 weeks ago

Closed 7 weeks ago

#70897 closed defect (fixed)

cp: Bad address

Reported by: christophecvr (christophecvr) Owned by: Ryan Carsten Schmidt <git@…>
Priority: Normal Milestone:
Component: base Version: 2.10.99
Keywords: haspatch Cc:
Port:

Description

openssl 3 does not install due to destroot failure during man docs install phase. extract from concerned error :

*** Installing manpages
install doc/man/man1/CA.pl.1 -> /opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/share/man/man1/CA.pl.1ssl
install doc/man/man1/openssl-asn1parse.1 -> /opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/share/man/man1/openssl-asn1parse.1ssl
install doc/man/man1/openssl-ca.1 -> /opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/share/man/man1/openssl-ca.1ssl
install doc/man/man1/openssl-ciphers.1 -> /opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/share/man/man1/openssl-ciphers.1ssl
install doc/man/man1/openssl-cmds.1 -> /opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/share/man/man1/openssl-cmds.1ssl
cp: Bad address
make: *** [install_man_docs] Error 14
make: Leaving directory `/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/openssl-3.3.2'
Command failed:  cd "/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/openssl-3.3.2" && /usr/bin/make -w install MANDIR=/opt/local/share/man MANSUFFIX=ssl DESTDIR=/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot 
Exit code: 2
Error: Failed to destroot openssl3: command execution failed
Error: See /opt/local/var/macports/logs/_opt_mports_macports-ports_devel_openssl3/openssl3/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port openssl3 failed

this on macos 10.15.7 xcode 11.5 CommandLineTools 11.5

macports master.

included full.log as append.

Attachments (1)

mainopenssl3.log.bz2 (80.1 KB) - added by jmroot (Joshua Root) 7 weeks ago.

Download all attachments as: .zip

Change History (18)

comment:1 Changed 7 weeks ago by christophecvr (christophecvr)

I looked to find a way to build openssl3 without the manpages . The only way in openssl3 is to just not install the manpages by using install_sw instead of install.

How can the port be configured so that the destroot phase uses:

make instal_sw ...

instead of

make install ...

I could not find that in manual of mac ports

comment:2 Changed 7 weeks ago by christophecvr (christophecvr)

Found the way by using

destroot.target install_sw

however port is really not ok in general.

to build by me

Version 0, edited 7 weeks ago by christophecvr (christophecvr) (next)

comment:3 Changed 7 weeks ago by christophecvr (christophecvr)

Well further investigation showed it is a problem on my mac self with the cp command. I solved the issue by adapting the Makefile self after build is done. by : changing all cp commands of the install sections of docs from :

cp *****

to :

/opt/local/bin/gcp -afv ******

And yes all destroot and installs fine. very curious.

comment:4 Changed 7 weeks ago by jmroot (Joshua Root)

Port: openssl3 added
Version: 2.9.992.10.99

You're running master, so cp will be the thin wrapper in clonebin. Is it actually crashing, and if so can you attach the crash report? Is it always failing on a specific file, and if so which one? Is that reproducible by running the wrapper yourself?

comment:5 Changed 7 weeks ago by jmroot (Joshua Root)

Also it would be good to double check that this doesn't happen with the current release.

Changed 7 weeks ago by jmroot (Joshua Root)

Attachment: mainopenssl3.log.bz2 added

comment:6 in reply to:  4 Changed 7 weeks ago by christophecvr (christophecvr)

Replying to jmroot:

You're running master, so cp will be the thin wrapper in clonebin. Is it actually crashing, and if so can you attach the crash report? Is it always failing on a specific file, and if so which one? Is that reproducible by running the wrapper yourself?

First no it happens more a bit at wild. But always during destroot phase. Sometimes it even happens earlier before the man docs install execution. example here extract of one case where it happens a bit earlier.

Executing:  cd "/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/openssl-3.3.2" && /usr/bin/make -w install MANDIR=/opt/local/share/man MANSUFFIX=ssl DESTDIR=/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot 
make: Entering directory `/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/openssl-3.3.2'
"/Library/Developer/CommandLineTools/usr/bin/make" depend && "/Library/Developer/CommandLineTools/usr/bin/make" _build_libs
make[1]: Entering directory `/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/openssl-3.3.2'
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/openssl-3.3.2'
make[1]: Entering directory `/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/openssl-3.3.2'
make[1]: Nothing to be done for `_build_libs'.
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/openssl-3.3.2'
created directory `/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/libexec/openssl3'
created directory `/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/libexec/openssl3/lib'
*** Installing runtime libraries
install libcrypto.3.dylib -> /opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/libexec/openssl3/lib/libcrypto.3.dylib
install libssl.3.dylib -> /opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/libexec/openssl3/lib/libssl.3.dylib
*** Installing development files
created directory `/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/libexec/openssl3/include'
created directory `/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/libexec/openssl3/include/openssl'
install ./include/openssl/aes.h -> /opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/libexec/openssl3/include/openssl/aes.h
install ./include/openssl/asn1.h -> /opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/libexec/openssl3/include/openssl/asn1.h

# then a lot off install lines till 
install ./include/openssl/rsaerr.h -> /opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/libexec/openssl3/include/openssl/rsaerr.h
cp: Bad address
make: *** [install_dev] Error 14
make: Leaving directory `/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/openssl-3.3.2'
Command failed:  cd "/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/openssl-3.3.2" && /usr/bin/make -w install MANDIR=/opt/local/share/man MANSUFFIX=ssl DESTDIR=/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot 
Exit code: 2
Error: Failed to destroot openssl3: command execution failed
Error: See /opt/local/var/macports/logs/_opt_mports_macports-ports_devel_openssl3/openssl3/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port openssl3 failed

Command used to trigger this error

sudo port -s -v destroot openssl3

comment:7 in reply to:  4 Changed 7 weeks ago by christophecvr (christophecvr)

Replying to jmroot:

You're running master, so cp will be the thin wrapper in clonebin. Is it actually crashing, and if so can you attach the crash report? Is it always failing on a specific file, and if so which one? Is that reproducible by running the wrapper yourself?

The cp command indeed seems to crash or stall but there is no crash report. (checked all crash reports locations). Looks rather a runtime issue here cp then chmod then something with perl back to cp for next file and so on.

Makefile code : used when crash or stall occurs in this last case

	@$(ECHO) "*** Installing development files"
	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)/include/openssl"
	@ : 
	@set -e; for i in $(SRCDIR)/include/openssl/*.h \
			  $(BLDDIR)/include/openssl/*.h; do \
		fn=`basename $$i`; \
		$(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
		cp $$i "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
		chmod 644 "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
	done

How to do : Is that reproducible by running the wrapper yourself?

comment:8 Changed 7 weeks ago by christophecvr (christophecvr)

Replying to jmroot:

Also as info what also works is by just changing the cp command by all those using the routine like mentioned above in the Makefile from :

cp $$i "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \

to :

/bin/cp $$i "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \

Also works. Install runs fine then.

Last edited 7 weeks ago by christophecvr (christophecvr) (previous) (diff)

comment:9 Changed 7 weeks ago by christophecvr (christophecvr)

Replying to jmroot:

Ok found what you mean whit the thin wrapper in codebin :

/opt/local/libexec/macports/clonebin/cp

I check to make a scripts which copy's large amount of small files whit a while or for loop and try to reproduce this error then in terminal.

comment:10 Changed 7 weeks ago by ryandesign (Ryan Carsten Schmidt)

Looking at the code for the cp wrapper, it doesn't look like new_argv is NULL-terminated, but the manpage says it must be.

Also, why execve? The advantage of execve seems to be that you can specify the environment array, but since you're just passing in the existing environ, wouldn't it be simpler to use execv that does that automatically?

comment:11 Changed 7 weeks ago by ryandesign (Ryan Carsten Schmidt)

Component: portsbase
Port: openssl3 removed
Summary: openssl3: fails to destroot due to cp errors when installing man docs.cp: Bad address

comment:12 Changed 7 weeks ago by ryandesign (Ryan Carsten Schmidt)

Also we are getting this warning:

cp.c:21:25: warning: passing 'const char **' to parameter of type 'char *const *' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
        execve(cp_path, new_argv, environ);
                        ^~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:445:49: note: passing argument to parameter '__argv' here
int      execve(const char * __file, char * const * __argv, char * const * __envp) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
                                                    ^
1 warning generated.

comment:13 Changed 7 weeks ago by ryandesign (Ryan Carsten Schmidt)

Keywords: haspatch added

Here's my attempt at fixing this; someone else should check if this makes sense: https://github.com/macports/macports-base/pull/350

comment:14 in reply to:  13 Changed 7 weeks ago by christophecvr (christophecvr)

Replying to ryandesign:

Here's my attempt at fixing this; someone else should check if this makes sense: https://github.com/macports/macports-base/pull/350

I tried to reproduce the error with a small script in terminal :

#!/bin/sh
destpath="$HOME/ACLONEBINCP"
if [ ! -d $destpath ]; then
    mkdir "$destpath"
fi
OLDIFS="$IFS"
filepath="/opt/local/var/macports/build/_opt_mports_macports-ports_devel_openssl3/openssl3/work/destroot/opt/local/libexec/openssl3/share/doc/openssl/html/man7"
IFS="
"
fileslist=(`find $filepath -type f -name "*.html"`)
IFS=$OLDIFS

for I in "${fileslist[@]}"
do
    /opt/local/libexec/macports/clonebin/cp -fv "$I" "$destpath"
done

But then the cp command runs fine.

I will try you're commit with a rebuild by me.

comment:15 in reply to:  13 Changed 7 weeks ago by christophecvr (christophecvr)

Replying to ryandesign:

Here's my attempt at fixing this; someone else should check if this makes sense: https://github.com/macports/macports-base/pull/350

Just used this commits by me and rebuild macports-base installed it.

Now it runs fine openssl3 did build from scratch and destrooted fine without any change.

comment:16 Changed 7 weeks ago by Ryan Carsten Schmidt <git@…>

In 4275d4c99c1b1008d9bd6529bc552830f95c41c2/macports-base (master):

cp: Use execv instead of execve

See: #70897

comment:17 Changed 7 weeks ago by Ryan Carsten Schmidt <git@…>

Owner: set to Ryan Carsten Schmidt <git@…>
Resolution: fixed
Status: newclosed

In a7c00b40cc8760e7e44f504a6c3adea5887d4738/macports-base (master):

cp: NULL-terminate new_argv

Closes: #70897

Note: See TracTickets for help on using tickets.