Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #29994] [BUG] "loadlib $P0, varname" not working correctly

0 views
Skip to first unread message

Jens Rieks

unread,
Jun 1, 2004, 11:22:14 AM6/1/04
to bugs-bi...@rt.perl.org
# New Ticket Created by Jens Rieks
# Please include the string: [perl #29994]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=29994 >


% cat error.imc
.sub _main @MAIN
.local string na123me

na123me = "/foo"
loadlib $P0, na123me

end
.end

% ./parrot -o error.pbc error.imc
Couldn't load 'runtime/parrot/a123m': runtime/parrot/a123m: cannot open shared
object file: No such file or directory

This is caused by imcc/parser_util.c:INS, where a test is done to check if the
current instruction is "loadlib"; if it is, the second argument is treat as a
string; this fails if it actually is a variable name.

Leopold Toetsch

unread,
Jun 2, 2004, 3:51:27 AM6/2/04
to perl6-i...@perl.org
Jens Rieks <parrotbug...@parrotcode.org> wrote:

> % cat error.imc
> .sub _main @MAIN
> .local string na123me

> na123me = "/foo"
> loadlib $P0, na123me

> end
> .end

> % ./parrot -o error.pbc error.imc
> Couldn't load 'runtime/parrot/a123m':

The parser currently loads extensions at compile time to be able to load
in new PMC types. This of course fails with variables.

I can see some ways to fix that:
- allow only string constants for loadlib
- don't load extensions at compile time, so that dynamic PMCs have to be
created with

$I0 = find_type "Foo"
$P0 = new $I0

- just don't try to load the lib, if it's name isn't a string constant

leo

Dan Sugalski

unread,
Jun 2, 2004, 10:19:27 AM6/2/04
to l...@toetsch.at, perl6-i...@perl.org
At 9:51 AM +0200 6/2/04, Leopold Toetsch wrote:
>- don't load extensions at compile time, so that dynamic PMCs have to be
> created with
>
> $I0 = find_type "Foo"
> $P0 = new $I0

Option two here would be the right one.
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Leopold Toetsch

unread,
Jun 3, 2004, 3:50:42 AM6/3/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:
> At 9:51 AM +0200 6/2/04, Leopold Toetsch wrote:
>>- don't load extensions at compile time, so that dynamic PMCs have to be
>> created with
>>
>> $I0 = find_type "Foo"
>> $P0 = new $I0

> Option two here would be the right one.

For dynamic PMC classes and NCI yes. *But* what about dynamic opcode
libs? The PASM/PIR compilers have to load in the lib to be able to emit
the opcode number. Should we use a different opcode for the latter?

leo

Dan Sugalski

unread,
Jun 4, 2004, 9:58:38 AM6/4/04
to l...@toetsch.at, perl6-i...@perl.org
At 9:50 AM +0200 6/3/04, Leopold Toetsch wrote:
>Dan Sugalski <d...@sidhe.org> wrote:
>> At 9:51 AM +0200 6/2/04, Leopold Toetsch wrote:
>>>- don't load extensions at compile time, so that dynamic PMCs have to be
>>> created with
>>>
>>> $I0 = find_type "Foo"
>>> $P0 = new $I0
>
>> Option two here would be the right one.
>
>For dynamic PMC classes and NCI yes. *But* what about dynamic opcode
>libs? The PASM/PIR compilers have to load in the lib to be able to emit
>the opcode number.

Well... not necessarily. The original scheme was for the opcode
loading code to specify what numbers the loaded opcodes would get for
the compilation unit in question.

>Should we use a different opcode for the latter?

I think we need a different scheme for loadable opcode libs, yeah. We
need more metainformation, either at load or at compile time,
possibly both. I think, though, that the compile time information can
be specified completely in the PIR code. Whether we want to or not is
a separate issue, of course, but I think we're going to want to do so.

Might look something like:

.library foo.ops {
.op acosh
.op asech
.op atanh
}

or just go with a .library/.end pair. I don't much care, it's not
that big a deal. It's enough to give the pir compiler what it needs
to map op names to op numbers, and then we need to have a metadata
section in the bytecode file to tell the loader what it needs to do
to build the opcode tables when the bytecode's loaded in and the sub
pmcs are instantiated.

Leopold Toetsch

unread,
Jun 5, 2004, 5:04:40 AM6/5/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:

> Well... not necessarily. The original scheme was for the opcode
> loading code to specify what numbers the loaded opcodes would get for
> the compilation unit in question.

Opcode numbers only aren't sufficient. The compiler checks argument
count and types too. It needs additionally the PARROT_ARGDIR_* flags for
life analysis and PARROT_JUMP_* for generating basic blocks.

The whole information is in the C<struct op_info_t>, which is loaded in
at compile time. Having a totally different scheme for loadable ops
isn't really a good thing.

*If* we allow a different order for loaded ops at compile vs run time,
we need additional information in the metadata, to be able to relocate
the range of dynamic ops. It's a matter of taste, if we allow that or if
we just state: <loadlib> opcodes for dynamic oplibs have to be seen by
the compiler in runtime order.

I'd for now go with option three which was: don't load dynamic libs
which aren't constant strings.

BTW: is it really needed to specify a dynamic extension by variable
name?

leo

Leopold Toetsch

unread,
Jun 15, 2004, 11:10:34 AM6/15/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:
> At 9:50 AM +0200 6/3/04, Leopold Toetsch wrote:
>>Dan Sugalski <d...@sidhe.org> wrote:
>>
>>> Option two here would be the right one.
>>
>>For dynamic PMC classes and NCI yes. *But* what about dynamic opcode
>>libs? The PASM/PIR compilers have to load in the lib to be able to emit
>>the opcode number.

I've for now disabled C<loadlib> at compile time for variables. We still
need something for dynamic opcode libs.

I think that a separate opcode would be simplest:

load_ops Px, "myops" # constant filename only, compile time
loadlib Px, lib # runtime

leo

Klaas-Jan Stol via RT

unread,
Feb 21, 2007, 8:39:52 AM2/21/07
to perl6-i...@perl.org
On Tue Jun 15 08:13:06 2004, leo wrote:
> Dan Sugalski <d...@sidhe.org> wrote:
> > At 9:50 AM +0200 6/3/04, Leopold Toetsch wrote:
> >>Dan Sugalski <d...@sidhe.org> wrote:
> >>
> >>> Option two here would be the right one.
> >>
> >>For dynamic PMC classes and NCI yes. *But* what about dynamic opcode
> >>libs? The PASM/PIR compilers have to load in the lib to be able to emit
> >>the opcode number.
>
> I've for now disabled C<loadlib> at compile time for variables. We still
> need something for dynamic opcode libs.
>
> I think that a separate opcode would be simplest:
>
> load_ops Px, "myops" # constant filename only, compile time
> loadlib Px, lib # runtime
>
> leo
>


I checked this bug on windows, and apparently, the loadlib op works. See
for an example the attachment. It loads the library libnci_test, which
is included in the Parrot distr.

Both
$P0 = loadlib myLib
as
$P0 = loadlib 'libnci_test'
work.

However, something else seems to be wrong: when loading a non-existent
library (as in the example), no error message/exception is shown/raised.
I think this should be the case, although I don't really know the specs
for that. (it would make sense to do so, though)

loadlibtest.pir
0 new messages