Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues on NetBSD #1

Closed
0-wiz-0 opened this issue Sep 28, 2017 · 16 comments
Closed

Issues on NetBSD #1

0-wiz-0 opened this issue Sep 28, 2017 · 16 comments

Comments

@0-wiz-0
Copy link

0-wiz-0 commented Sep 28, 2017

I tried building Sys-Utmp-1.7 on NetBSD-8.99.2/amd64, but I see two problems. With unchanged sources, the build fails with:

gcc -c    -O2 -g -D_FORTIFY_SOURCE=2 -fstack-check -pthread -I/usr/include -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -O2 -g -D_FORTIFY_SOURCE=2 -fstack-check -I/usr/include  -g   -I/usr/include    -DVERSION=\"1.7\"  -DXS_VERSION=\"1.7\" -DPIC -fPIC "-I/usr/pkg/lib/perl5/5.26.0/x86_64-netbsd-thread-multi/CORE"   Utmp.c
Utmp.xs: In function 'constant':
Utmp.xs:125:13: error: 'ACCOUNTING' undeclared (first use in this function)
      return ACCOUNTING;
             ^
Utmp.xs:125:13: note: each undeclared identifier is reported only once for each function it appears in
Utmp.xs:129:13: error: 'BOOT_TIME' undeclared (first use in this function)
      return BOOT_TIME;
             ^
Utmp.xs:133:13: error: 'DEAD_PROCESS' undeclared (first use in this function)
      return DEAD_PROCESS;
             ^
Utmp.xs:137:13: error: 'EMPTY' undeclared (first use in this function)
      return EMPTY;
             ^
Utmp.xs:141:13: error: 'INIT_PROCESS' undeclared (first use in this function)
      return INIT_PROCESS;
             ^
Utmp.xs:145:13: error: 'LOGIN_PROCESS' undeclared (first use in this function)
      return LOGIN_PROCESS;
             ^
Utmp.xs:149:13: error: 'NEW_TIME' undeclared (first use in this function)
      return NEW_TIME;
             ^
Utmp.xs:153:13: error: 'OLD_TIME' undeclared (first use in this function)
      return OLD_TIME;
             ^
Utmp.xs:157:13: error: 'RUN_LVL' undeclared (first use in this function)
      return RUN_LVL;
             ^
Utmp.xs:161:13: error: 'USER_PROCESS' undeclared (first use in this function)
      return USER_PROCESS;
             ^
Utmp.xs: In function 'XS_Sys__Utmp_getutent':
Utmp.xs:226:22: error: 'struct utmp' has no member named 'ut_id'
        _ut_id = utent->ut_id;
                      ^
Utmp.xs:231:24: error: 'struct utmp' has no member named 'ut_type'
        _ut_type = utent->ut_type;
                        ^
Utmp.xs:236:23: error: 'struct utmp' has no member named 'ut_pid'
        _ut_pid = utent->ut_pid;
                       ^
In file included from /scratch/nih/p5-Sys-Utmp/work/.buildlink/lib/perl5/5.26.0/x86_64-netbsd-thread-multi/CORE/perl.h:5648:0,
                 from Utmp.xs:2:
Utmp.xs:250:34: error: 'struct utmp' has no member named 'ut_user'
        sv_ut_user = newSVpv(utent->ut_user,0);
                                  ^
/scratch/nih/p5-Sys-Utmp/work/.buildlink/lib/perl5/5.26.0/x86_64-netbsd-thread-multi/CORE/embed.h:415:42: note: in definition of macro 'newSVpv'
 #define newSVpv(a,b)  Perl_newSVpv(aTHX_ a,b)
                                          ^

Switching to the NOUTFUNCS case with the following patch:

--- Makefile.PL.orig    2013-10-27 08:58:56.000000000 +0000
+++ Makefile.PL
@@ -8,7 +8,7 @@ my (
 # This may require some refinement
 if ( $^O =~ /netbsd/i )
 {
-    $defined = "";
+   $define = '-DNOUTFUNCS';
 }
 elsif ( $^O =~ /bsd/i )
 {

makes the build progress further, but die in

gcc -c    -O2 -g -D_FORTIFY_SOURCE=2 -fstack-check -pthread -I/usr/include -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -O2 -g -D_FORTIFY_SOURCE=2 -fstack-check -I/usr/include  -g   -I/usr/include    -DVERSION=\"1.7\"  -DXS_VERSION=\"1.7\" -DPIC -fPIC "-I/usr/pkg/lib/perl5/5.26.0/x86_64-netbsd-thread-multi/CORE"  -DNOUTFUNCS Utmp.c
Utmp.xs:60:6: error: conflicting types for 'utmpname'
 void utmpname(char *filename)
      ^
In file included from Utmp.xs:5:0:
/usr/include/utmp.h:67:5: note: previous declaration of 'utmpname' was here
 int utmpname(const char *);
     ^
*** [Utmp.o] Error code 1

I used the following patch to fix that:

--- Utmp.xs.orig        2013-10-27 08:34:17.000000000 +0000
+++ Utmp.xs
@@ -57,11 +57,6 @@ static int ut_fd = -1;
 
 static char _ut_name[] = _PATH_UTMP;
 
-void utmpname(char *filename)
-{
-   strcpy(_ut_name, filename);
-}
-
 void setutent(void)
 {
     if (ut_fd < 0)

Even with those two, a couple of self tests are not happy:

t/06taint.t .......... Can't call method "ut_user" on an undefined value at t/06taint.t line 26.
# Looks like your test exited with 255 before it could output anything.
t/06taint.t .......... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 2/2 subtests 
t/07utent_methods.t .. Can't call method "ut_user" on an undefined value at t/07utent_methods.t line 10.
# Looks like your test exited with 255 before it could output anything.
t/07utent_methods.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 7/7 subtests 
t/08utent_types.t .... Can't call method "accounting" on an undefined value at t/08utent_types.t line 9.
# Looks like your test exited with 255 before it could output anything.
t/08utent_types.t .... Dubious, test returned 255 (wstat 65280, 0xff00)

Please advise.

One other thing: The Changes file in the CPAN distribution does not list the changes for 1.7.

@jonathanstowe
Copy link
Owner

Hi,
Thanks for this. It may take a while for me to get round to fixing this as I don't have a NetBSD machine to test with so I'll have to build a VM.

@jonathanstowe
Copy link
Owner

Right, when I first made this some fifteen years ago it was all a bit of a mixed bag regarding POSIX support so there were various workarounds. I'm not sure I ever actually tested with NetBSD. It appears that the NetBSD implementation actually defines some of the functions whereas FreeBSD doesn't define any. I think it's a combinatiom of the NOUTFUNCS and some more specialized preprocessor fun.

I've got a NetBSD VM now but won't get to this until Saturday.

@jonathanstowe
Copy link
Owner

I've just uploaded 1.8 to Pause - it compiles and passes its tests with NetBSD, FreeBSD and Linux

@0-wiz-0
Copy link
Author

0-wiz-0 commented Sep 29, 2017

Thank you for fixing this so quickly! I can confirm that it builds now.

However, I still see test errors on NetBSD-8.99.2/amd64:

"/usr/pkg/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Utmp.bs blib/arch/auto/Sys/Utmp/Utmp.bs 644
PERL_DL_NONLAZY=1 "/usr/pkg/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01pod.t ............ ok
t/02podcoverage.t .... ok
t/03utmp.t ........... ok
t/04constants.t ...... ok
t/05fields.t ......... ok
t/06taint.t .......... Can't call method "ut_user" on an undefined value at t/06taint.t line 26.
# Looks like your test exited with 255 before it could output anything.
t/06taint.t .......... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 2/2 subtests
t/07utent_methods.t .. Can't call method "ut_user" on an undefined value at t/07utent_methods.t line 10.
# Looks like your test exited with 255 before it could output anything.
t/07utent_methods.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 7/7 subtests
t/08utent_types.t .... Can't call method "accounting" on an undefined value at t/08utent_types.t line 9.
# Looks like your test exited with 255 before it could output anything.
t/08utent_types.t .... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 10/10 subtests

Test Summary Report
-------------------
t/06taint.t        (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 2 tests but ran 0.
t/07utent_methods.t (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 7 tests but ran 0.
t/08utent_types.t  (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 10 tests but ran 0.
Files=8, Tests=28,  1 wallclock secs ( 0.01 usr  0.03 sys +  0.42 cusr  0.08 csys =  0.54 CPU)
Result: FAIL
Failed 3/8 test programs. 0/28 subtests failed.
*** Error code 255

@jonathanstowe jonathanstowe reopened this Sep 30, 2017
@jonathanstowe
Copy link
Owner

Ah, this is the current rather than the stable - they must have changed something fairly fundamental for it to fail like that. I'm guessing that they've jumped wholesale to the POSIX utmpx stuff and stopped populating the heritage utmp file.

So I'm confident that it works well with the stable NetBSD and I'll have to make a VM with current to see what is going on there.

@jonathanstowe
Copy link
Owner

Well, I just installed NetBSD bombast 8.0_BETA NetBSD 8.0_BETA (GENERIC.201709170600Z) amd64 which I guess is close to what you have and it works fine. I'm not entirely sure how to get exactly the version that you have though.

Is there a /var/run/utmp and if so does it have anything in it?

@0-wiz-0
Copy link
Author

0-wiz-0 commented Oct 2, 2017

Yes, there is a recent /var/run/utmp:

-rw-rw-r--  1 root  utmp  920 Oct  2 08:04 /var/run/utmp

As I understand it, the native interface is now utmpx but the utmp files are still kept up-to-date.

@jonathanstowe
Copy link
Owner

Right so there is a difference in the version I have installed and the one you have. As it definitely works in the 8.00 Beta I have.

For reference the Perl 6 version of Sys::Utmp does use the utmpx functions but I haven't got round to back porting the code.

Can you provide me with the URI of an ISO that I can use to install the 8.99_2 in a VM?

@0-wiz-0
Copy link
Author

0-wiz-0 commented Oct 2, 2017

Strange.

Anyway, daily builds are here:
https://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/201709161700Z/amd64/installation/cdrom/

but the date in the URI changes often.

@jonathanstowe
Copy link
Owner

Hmm that is the exact one I installed (from the boot.iso) why does the kernel version differ on mine?

@0-wiz-0
Copy link
Author

0-wiz-0 commented Oct 2, 2017

That is confusing. Are you sure you took HEAD and not netbsd-8?

@jonathanstowe
Copy link
Owner

I'll try another one when I get in.

@jonathanstowe
Copy link
Owner

@jonathanstowe
Copy link
Owner

Well.....

-bash-4.4$ uname -a
NetBSD varoomshka 8.99.2 NetBSD 8.99.2 (GENERIC) #0: Sat Sep 16 09:28:38 UTC 2017  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
-bash-4.4$ make test
"/usr/pkg/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Utmp.bs blib/arch/auto/Sys/Utmp/Utmp.bs 644
PERL_DL_NONLAZY=1 "/usr/pkg/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01pod.t ............ skipped: Test::Pod 1.00 required for testing POD
t/02podcoverage.t .... skipped: Test::Pod::Coverage required for testing POD Coverage
t/03utmp.t ........... ok   
t/04constants.t ...... ok     
t/05fields.t ......... ok   
t/06taint.t .......... ok   
t/07utent_methods.t .. ok   
t/08utent_types.t .... ok     
All tests successful.
Files=8, Tests=43,  0 wallclock secs ( 0.04 usr  0.03 sys +  0.36 cusr  0.11 csys =  0.54 CPU)
Result: PASS

I'm not sure where to go from here.

@0-wiz-0
Copy link
Author

0-wiz-0 commented Oct 6, 2017

I'm really terribly sorry to have sent you on such a wild goose hunt. I just found that I had no /var/run/utmp file inside my sandbox, only outside. When I copy it inside, the tests work for me as well.
Thank you very much for your help!

@0-wiz-0 0-wiz-0 closed this as completed Oct 6, 2017
@jonathanstowe
Copy link
Owner

No need to apologise, it motivated me to test a whole bunch of other stuff on NetBSD and I've also started on back-porting the utmpx stuff from the Perl 6 version so all good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants