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

Mac OS X 10.10.4: Tests Fail (Perl 5.20.2) #34

Open
ghost opened this issue Aug 26, 2015 · 12 comments
Open

Mac OS X 10.10.4: Tests Fail (Perl 5.20.2) #34

ghost opened this issue Aug 26, 2015 · 12 comments

Comments

@ghost
Copy link

ghost commented Aug 26, 2015

cpanm (App::cpanminus) 1.7027 on perl 5.020002 built for darwin-2level

Work directory is /Users/konstantin_c/.cpanm/work/1440578234.61459
You have make /usr/bin/make
You have LWP 6.13
You have /usr/bin/tar: bsdtar 2.8.3 - libarchive 2.8.3
You have /usr/bin/unzip
Searching RPerl on cpanmetadb ...
--> Working on RPerl
Fetching http://www.cpan.org/authors/id/W/WB/WBRASWELL/RPerl-1.000007.tar.gz
-> OK
Unpacking RPerl-1.000007.tar.gz
Entering RPerl-1.000007
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.04)
Configuring RPerl-1.000007
Running Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for RPerl
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have Test::Exception 0.32 ... Yes (0.40)
Checking if you have Test::Number::Delta 1.06 ... Yes (1.06)
Checking if you have ExtUtils::MakeMaker 7.04 ... Yes (7.04)
Checking if you have CPAN::Meta 2.150005 ... Yes (2.150005)
Checking if you have Test::CPAN::Changes 0.400002 ... Yes (0.400002)
Checking if you have Inline::CPP 0.63 ... Yes (0.73)
Checking if you have Perl::Critic 1.121 ... Yes (1.126)
Checking if you have Module::Refresh 0.17 ... Yes (0.17)
Checking if you have Inline::C 0.76 ... Yes (0.76)
Checking if you have Perl::Tidy 20140711 ... Yes (20150815)
Checking if you have Parse::Eyapp 1.182 ... Yes (1.182)
Checking if you have Inline::Filters 0.17 ... Yes (0.17)
Checking if you have Inline 0.76 ... Yes (0.80)
Checking if you have PadWalker 2.1 ... Yes (2.1)
Building and testing RPerl-1.000007
cp lib/RPerl/Test/OperatorVoid01NamedVoidReturn/program_05_good.pl blib/lib/RPerl/Test/OperatorVoid01NamedVoidReturn/program_05_good.pl
...
cp script/rperl blib/script/rperl
"/Users/konstantin_c/.plenv/versions/5.20.2/bin/perl5.20.2" -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/rperl
Manifying 1 pod document
Manifying 1 pod document
PERL_DL_NONLAZY=1 "/Users/konstantin_c/.plenv/versions/5.20.2/bin/perl5.20.2" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00_depend.t .................. ok
t/01_changes.t ................. ok
t/02_inline_c.t ................ ok

#   Failed test 'Inline::CPP, call Airplane methods, return correct value 1'
#   at t/03_inline_cpp.t line 146.
#                   ''
#     doesn't match '/Object\ \(0x\w*\)/'
# Looks like you failed 1 test of 17.
t/03_inline_cpp.t ..............
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/17 subtests
t/04_type_scalar.t ............. ok
t/05_type_array.t .............. ok
t/06_type_hash.t ............... ok
t/07_interpret_execute.t ....... ok
t/08_precompiled_oo_inherit.t .. ok
t/09_precompiled_sort.t ........ ok
t/10_parse.t ................... ok
t/11_generate.t ................ ok
t/13_compile_sort.t ............ ok

Test Summary Report
-------------------
t/03_inline_cpp.t            (Wstat: 256 Tests: 17 Failed: 1)
  Failed test:  4
  Non-zero exit status: 1
Files=13, Tests=3156, 1064 wallclock secs ( 0.69 usr  0.11 sys + 943.25 cusr 89.72 csys = 1033.77 CPU)
Result: FAIL
Failed 1/13 test programs. 1/3156 subtests failed.
make: *** [test_dynamic] Error 255
@wbraswell
Copy link
Owner

Please manually run the following command and paste the output of the failing test:
perl t/03_inline_cpp.t

@ghost
Copy link
Author

ghost commented Sep 7, 2015

$ perl t/03_inline_cpp.t
1..17
ok 1 - Inline::CPP, define class Farmer returns correct value
ok 2 - Inline::CPP, call Farmer methods returns correct value
ok 3 - Inline::CPP, define class Airplane returns correct value
not ok 4 - Inline::CPP, call Airplane methods, return correct value 1
#   Failed test 'Inline::CPP, call Airplane methods, return correct value 1'
#   at t/03_inline_cpp.t line 146.
#                   ''
#     doesn't match '/Object\ \(0x\w*\)/'
ok 5 - Inline::CPP, call Airplane methods, return correct value 2
ok 6 - Inline::CPP, define average() and avg() returns correct value
ok 7 - Inline::CPP, call average() and avg() returns correct value 1
ok 8 - Inline::CPP, call average() and avg() returns correct value 2
ok 9 - Inline::CPP, call average() and avg() return values are equivalent
ok 10 - Inline::CPP, define classes Queue and Stack returns correct value
ok 11 - Inline::CPP, call Queue and Stack methods returns correct value 1
ok 12 - Inline::CPP, call Queue and Stack methods returns correct value 2
ok 13 - Inline::CPP, define multiadd() returns correct value
ok 14 - Inline::CPP, call multiadd(1) returns correct value
ok 15 - Inline::CPP, call multiadd(1, 2) returns correct value
ok 16 - Inline::CPP, call multiadd(1, 2, 3) returns correct value
ok 17 - Inline::CPP, call multiadd(1, 2, 3, 4) throws correct exception
# Looks like you failed 1 test of 17.

@wbraswell
Copy link
Owner

Are you familiar with C++?
This error is occurring because our attempt to stringify the "this" object seems to be returning an empty string instead of 'Object (0xFOO)' as expected.
I only have Linux, can you somehow debug this to find out why we are receiving an empty string?
https://github.com/wbraswell/rperl/blob/master/t/03_inline_cpp.t#L146

@protoCall7
Copy link

@wbraswell - I'm experiencing the same issue in OS X that @dshadow is experiencing.

I'm more of a C dev than C++, but if you can tell me what you're looking for, i'm happy to grab back-traces or variable values for you from the debugger.

@wbraswell
Copy link
Owner

This is the failing test:

like( $airplane_retval1, '/Object\ \(0x\w*\)/', 'Inline::CPP, call Airplane methods, return correct value 1' );

This is the call to nonprint() which is supposed to return the correct value:

my $plane_retval1 = $plane->nonprint;

This is the definition of the nonprint() method, which should return "Object(0x...)"

virtual char* nonprint() { ostringstream oretval; oretval << "Object (" << this << ")"; return((char*)oretval.str().c_str()); }

This works just fine in Linux (and apparently also Windows), but not in Macintosh.

So yes, please help me debug this!

@protoCall7
Copy link

So far I have determined that the behavior is the same regardless of Inline::CPP or cutting the C++ out and writing a small main(). I will mess around with the raw C++ in the debugger this evening and see if I can figure out where the value is going.

I'm almost wondering if the pointer to oretval is being garbage collected when it goes out of scope from the function returning because it's being cast from a const char* to a char*

I will continue investigating this evening and let you know what I find.

int main ()
{
    Airplane ap;
    char* foo = ap.nonprint();

    cout << foo;

    return 0;
}

@protoCall7
Copy link

I swapped out the char* and c_str() for plain strings, and everything works fine in C++. The original version of nonprint returned nothing, as seen in the test.

The compiler in use here is clang:

Apple LLVM version 7.0.0 (clang-700.0.72)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

#include <iostream>
#include <sstream>

using namespace std;

/*  Abstract class (interface) */
class Object {
    public:
        virtual string nonprint() { ostringstream oretval; oretval << "Object (" << this << ")"; string ret = oretval.str(); return ret; }
};

class Airplane : public Object {
    public:
        Airplane() {}
        ~Airplane() {}
};

int main(void)
{
    Airplane ap;
    string val = ap.nonprint();
    cout << val;
    return 0;
}

However, when I directly drop this into the test (see commit cd021f9), I get a failure to eval because there is no method called nonprint:

t/03_inline_cpp.t .............. 3/17
#   Failed test 'Inline::CPP, call Airplane methods lives'
#   at t/03_inline_cpp.t line 151.
# died: Error in eval, have $EVAL_ERROR =
#
# BEGIN EVAL ERROR
#
# Can't locate object method "nonprint" via package "Airplane" at (eval 146) line 2.
#
#
# END EVAL ERROR
#
# croaking at /Users/peter/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Test/Exception.pm line 367.

Any thoughts on where to go from here, @wbraswell?

@david-hoekman
Copy link

The error is unchanged with the RPerl 1.2 release, and latest release of Mac OS X tools:

Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix

On the bright side, it is still the only error...

@wbraswell
Copy link
Owner

This may be a bug in Inline::CPP, we shall have to wait and see what the I::CPP team says.
Meanwhile, as a temporary band-aid solution, I have disabled the offending test in the latest release on CPAN, v1.200_002.
Everyone, please give it a try on your Macintosh systems and let me know if we are passing all tests now. Thanks!

@david-hoekman
Copy link

It does indeed pass all tests, and installs on my system just fine. Will experiment a bit with it, see if any issues arise.

@wbraswell
Copy link
Owner

Good to hear so far, please keep me posted!

@wbraswell wbraswell changed the title Test fails on Mac OS X 10.10.4 (Perl 5.20.2) Mac OS X 10.10.4: Tests Fail (Perl 5.20.2) Dec 4, 2015
@wbraswell
Copy link
Owner

may be fixable using new typemap documentation:
daoswald/Inline-CPP@2860272

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

3 participants