Ticket #1592 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

t/op/io.t fails in non optimized build

Reported by: NotFound Owned by: dukeleto
Priority: normal Milestone:
Component: testing Version: 2.3.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:


The test open_delegates_to_filehandle_pmc in t/op/io.t fire an assertion in Parrot_io_open: PARROT_ASSERT(new_filehandle->vtable->base_type == typenum);

I'm not sure what are the purposes of the test and the assertion.

A related point: Parrot_io_open uses HLL mapped FileHandle but Parrot_io_new_pmc uses enum_class_FileHandle, looks inconsistent.


r45961.diff Download (3.3 KB) - added by jkeenan 4 years ago.
revision in which failure in t/op/io.t (non-optimized) build first occurred

Change History

Changed 4 years ago by jkeenan

  • component changed from none to testing

The failure:

prove -v t/op/io.t 
t/op/io.t .. 
src/io/api.c:130: failed assertion 'new_filehandle->vtable->base_type == typenum'
Backtrace - Obtained 15 stack frames (max trace depth is 32).
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0 [0xb7d4e9e2]
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0(Parrot_confess+0x9a) [0xb7d4eb4a]
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0(Parrot_io_open+0xbe) [0xb7dc40be]
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0 [0xb7d37733]
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0 [0xb7dac221]
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0 [0xb7daaf6f]
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0 [0xb7d6d83f]
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0(Parrot_pcc_invoke_from_sig_object+0x1bc) [0xb7d6726c]
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0(Parrot_pcc_invoke_sub_from_c_args+0x11e) [0xb7d673de]
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0(Parrot_runcode+0x15e) [0xb7d4d4ce]
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0 [0xb7e8e399]
/home/jimk/work/parrot/blib/lib/libparrot.so.2.3.0(imcc_run+0x39c) [0xb7e8ee8c]
parrot [0x8049a00]
/lib/libc.so.6(__libc_start_main+0xe5) [0xb6fc1455]
parrot [0x8048df1]
Failed 5/5 subtests 

Test Summary Report
t/op/io.t (Wstat: 6 Tests: 0 Failed: 0)
  Non-zero wait status: 6
  Parse errors: Bad plan.  You planned 5 tests but ran 0.

Changed 4 years ago by jkeenan

  • owner set to dukeleto

Bisection indicates that the failure occurred with r45961 (attached).

dukeleto, can you take a look and test without --optimize? Thanks.

Changed 4 years ago by jkeenan

revision in which failure in t/op/io.t (non-optimized) build first occurred

Changed 4 years ago by cotto

  • status changed from new to closed
  • resolution set to fixed

The assert was removed in r46009 causing t/op/io.t to pass once again. This is part of the correct fix according to allison's reply to a related thread ( http://groups.google.com/group/parrot-dev/msg/881e03c120a1909e).

Changed 4 years ago by mikehh

  • status changed from closed to reopened
  • resolution fixed deleted

the test is still failing for me in builds without --optimize (it passes - [i.e. does not indicate failure] on builds with --optimize).

it now fails with:
src/ops/io.ops:161: failed assertion '! PMC_IS_NULL(PREG(1))'

the relevant code is

inline op open(out PMC, in STR) :filesys_open {
    if (STRING_IS_NULL($2)) {
        opcode_t *handler = Parrot_ex_throw_from_op_args(interp, expr NEXT(),
            EXCEPTION_UNEXPECTED_NULL, "Invalid open");
        goto ADDRESS(handler);
    else {
        $1 = Parrot_io_open(interp, PMCNULL, $2, NULL);

with 161 being the PARROT_ASSERT

I extracted the test and the remaining tests pass but the test fails when run on its own.

.const int TESTS = 1

.sub 'main' :main
    .include 'test_more.pir'



.sub open_delegates_to_filehandle_pmc
    load_bytecode 'P6object.pbc'

    .local pmc p6meta, interp, classes, classid
    p6meta = get_root_global ["parrot"], "P6metaclass"

    interp = getinterp
    classes = interp[0]
    classid = classes['Testing']
    $I0 = classes['FileHandle']
    set classes['FileHandle'], classid

    $P1 = open '/foo'

    # replace the original, so we don't break other tests
    set classes['FileHandle'], $I0


.namespace ["Testing"]

.sub open :method
    .param pmc args :slurpy
    ok(1,'open opcode delegates to the FileHandle PMC')

I don't think the ok function should be in the open method but after checking The

    $P1 = open '/foo'

if $P1 is NULL as the assertion seems to indicate, then we are not getting a valid result, and the test should not ok it.

Is P6_Object.pbc right for parrot tests?

Changed 4 years ago by NotFound

Here's an example of the problems with the current implementation:


.HLL 'fubar'

# Check HLL mapping of filehandle

.sub main
    .local pmc interp, fh, fbh, fake
    interp = getinterp
    fh = get_class ['FileHandle']

# Use a parrot class, whose base_type isn't
# what get_ctx_HLL_type returns.
    fbh = newclass ['FubarHandle']
    $P0 = new fh
    interp.'hll_map'(fh, fbh)
    $P1 = open 'something'
    close $P1

# Use a PMC, which is. Dragons and lions here:
    fake = get_class ['ResizablePMCArray']
    #fake = get_class ['Integer']
    interp.'hll_map'(fh, fake)
    $P2 = open 'hllmapfh.pir'
    close $P2

.namespace [ 'FubarHandle' ]

.sub init :vtable
    say 'FubarHandle.init'

.sub open :method
    .param string whatever
    .param string dontcare
    say 'FubarHandle.open'

.sub close :method
    say 'FubarHandle.close'

# End

When using a parrot class, the check new_filehandle->vtable->base_type == typenum doen't pass. When using a PMC, that checks assumes is a FileHandle PMC. The result may vary, can do nothing, can fail subtlety, can coredump...

So I really don't know what the intention of the code is or what the test is testing.

Changed 4 years ago by cotto

  • status changed from reopened to closed
  • resolution set to fixed

mikehh has verified that the original issue has been fixed so I'll put this ticket to bed. Discussion of other issues should go into a new ticket.

Note: See TracTickets for help on using tickets.