# New Ticket Created by  Patrick R. Michaud 
# Please include the string:  [perl #37546]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37546 >


---
osname= linux
osvers= 2.4.21-27.0.2.elsmp
arch=   i386-linux-thread-multi
cc=     gcc 4.0.0 20050516 (Red Hat 4.0.0-6)
---
Flags:
    category=core
    severity=high
    ack=no
---
This may be related to #37537 ("coroutine segfaults") but it's
different enough that I'm submitting a separate ticket for it
and some new test diagnostics to evoke the bug. 

Parrot seems to have trouble with subs compiled and loaded using 
the C<compreg> op.  My test involves three files:

  sf8-sub.pir contains a simple subroutine called "outer" in
  the "XYZ" namespace.

      .sub outer
          .param pmc mob
          .local pmc corou
          .return (mob)
      .end

  Both sf8-include.pir and sf8-compreg.pir have a main subroutine
  that simply looks up "outer" in the "XYZ" namespace, and then
  enters an infinite loop calling the outer subroutine.  The difference
  is that sf8-include.pir uses an C< .include "sf8-sub.pir" >
  directive to compile the code, while the sf8-compreg.pir version
  loads sf8-sub.pir into a string register, then uses the C<compreg>
  op to compile and load the code.

  The sf8-include.pir program (using ".include") appears to work 
  just fine.  The sf8-compreg.pir program (using "compreg" op)
  aborts after ~1100 iterations:

      [EMAIL PROTECTED] trunk]$ ./parrot sf8-compreg.pir | wc -l    
      No code segment to switch to
      
      1112
      [EMAIL PROTECTED] trunk]$ 

  Turning on tracing causes it to fail after just 14 iterations,
  and no longer produces the "No code segment to switch to" message
  (although it still aborts):

      [EMAIL PROTECTED] trunk]$ ./parrot -t sf8-compreg.pir 2>xxx | wc -l
      14
      [EMAIL PROTECTED] trunk]$ 

  The last thing in the trace output is a "DOD / GC" pair.

Pm

---
Summary of my parrot 0.3.0 (r9586) configuration:
  configdate='Thu Oct 27 00:50:23 2005'
  Platform:
    osname=linux, archname=i386-linux-thread-multi
    jitcapable=1, jitarchname=i386-linux,
    jitosname=LINUX, jitcpuarch=i386
    execcapable=1
    perl=/usr/bin/perl
  Compiler:
    cc='gcc', ccflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING  -pipe 
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 
-I/usr/include/gdbm',
  Linker and Libraries:
    ld='gcc', ldflags=' -L/usr/local/lib',
    cc_ldflags='',
    libs='-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lrt -lgmp'
  Dynamic Linking:
    share_ext='.so', ld_share_flags='-shared -L/usr/local/lib -fPIC',
    load_ext='.so', ld_load_flags='-shared -L/usr/local/lib -fPIC'
  Types:
    iv=long, intvalsize=4, intsize=4, opcode_t=long, opcode_t_size=4,
    ptrsize=4, ptr_alignment=1 byteorder=1234, 
    nv=double, numvalsize=8, doublesize=8

---
Environment:
    HOME    LANG    LANGUAGE    LD_LIBRARY_PATH    LOGDIR    PATH    SHELL
.sub main :main
    $P0 = open "sf8-sub.pir", "<"
    $S0 = read $P0, 65535

    $P1 = compreg "PIR"
    $P1($S0)

    $P0 = find_global "XYZ", "outer"
  loop:
    $P1 = $P0("abc")
    print $P1
    print "\n"
    goto loop
.end

.sub main :main
    $P0 = find_global "XYZ", "outer"
  loop:
    $P1 = $P0("abc")
    print $P1
    print "\n"
    goto loop
.end

.include "sf8-sub.pir"

.namespace [ "XYZ" ]

.sub outer
    .param pmc mob
    .local pmc corou
    .return (mob)
.end

Reply via email to