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

Writing to $*OUT at BEGIN time results in an [LTA] error message #4959

Open
p6rt opened this issue Dec 30, 2015 · 9 comments
Open

Writing to $*OUT at BEGIN time results in an [LTA] error message #4959

p6rt opened this issue Dec 30, 2015 · 9 comments

Comments

@p6rt
Copy link

p6rt commented Dec 30, 2015

Migrated from rt.perl.org#127086 (status was 'open')

Searchable as RT127086$

@p6rt
Copy link
Author

p6rt commented Dec 30, 2015

From @hoelzro

For example, in test.pl​:

use TestModule;

in TestModule.pm​:

BEGIN say 'hi';

If we run test.pl, we get the following failure​:

===SORRY!===
Constraint type check failed for parameter '$precomp-id'

The commit that introduces the problem is 54e0577 on Rakudo.

@p6rt
Copy link
Author

p6rt commented Dec 30, 2015

From @niner

Your demonstration code does not show an error like you described. What it does show is that the precompilation process uses STDOUT to communicate back the dependencies of a precompiled module. That means, that you cannot also use STDOUT in your module's main line. There shouldn't be a reason for a module to say anything during BEGIN time. For debugging, use note. STDERR is unused.

If you find a use case where a module really has to print something to STDOUT during loading, please also find a good way for the precompilation process to communicate :)

@p6rt
Copy link
Author

p6rt commented Dec 30, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Dec 30, 2015

@niner - Status changed from 'open' to 'rejected'

@p6rt
Copy link
Author

p6rt commented Dec 31, 2015

From @LLFourn

I have had this happen too. I think it's actually doing anything that
writes to stdout during compile time rather than calling CORE but I could
be wrong.
On Thu, 31 Dec 2015 at 1​:26 AM, Rob Hoelz <perl6-bugs-followup@​perl.org>
wrote​:

# New Ticket Created by Rob Hoelz
# Please include the string​: [perl #​127086]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127086 >

For example, in test.pl​:

use TestModule;

in TestModule.pm​:

BEGIN say 'hi';

If we run test.pl, we get the following failure​:

===SORRY!===
Constraint type check failed for parameter '$precomp-id'

The commit that introduces the problem is 54e0577 on Rakudo.

@p6rt
Copy link
Author

p6rt commented Jan 3, 2016

@hoelzro - Status changed from 'rejected' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 3, 2016

From @hoelzro

On 2015-12-30 21​:44​:42, lloyd.fourn@​gmail.com wrote​:

I have had this happen too. I think it's actually doing anything that
writes to stdout during compile time rather than calling CORE but I could
be wrong.
On Thu, 31 Dec 2015 at 1​:26 AM, Rob Hoelz <perl6-bugs-followup@​perl.org>
wrote​:

# New Ticket Created by Rob Hoelz
# Please include the string​: [perl #​127086]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127086 >

For example, in test.pl​:

use TestModule;

in TestModule.pm​:

BEGIN say 'hi';

If we run test.pl, we get the following failure​:

===SORRY!===
Constraint type check failed for parameter '$precomp-id'

The commit that introduces the problem is 54e0577 on Rakudo.

From IRC (http://irclog.perlgeek.de/perl6/2016-01-03#i_11823821)&#8203;:

21​:49 nine hoelzro​: I would not mind you reopening the ticket either. But if you do, I'd really appreciate a suggestion for a fix, because I have no idea :)

My only suggestion for a fix at this time is to perhaps dup standard output to a file descriptor for writing precomp IDs, open standard output to /dev/null (or the platform equivalent), and perhaps make $*OUT a fake handle that notifies the user that $*OUT
isn't available at BEGIN time. The open() is just a safety measure for things that can access standard output without going through $*OUT (ex. nqp​::say).

Another idea is to avoid writing precomp IDs to standard output, and instead provide an output filename via the command line.

@p6rt
Copy link
Author

p6rt commented Jan 7, 2016

From @hoelzro

Feedback from Stefan​:

22​:22 nine hoelzro​: one word​: Windows
22​:23 hoelzro​: everything would be dead simple if we only supported Unix. Then I'd just open a pipe and pass the file descriptor to the child process.

http://irclog.perlgeek.de/perl6/2016-01-03#i_11823946

On 2016-01-03 14​:20​:34, rob@​hoelz.ro wrote​:

On 2015-12-30 21​:44​:42, lloyd.fourn@​gmail.com wrote​:

I have had this happen too. I think it's actually doing anything that
writes to stdout during compile time rather than calling CORE but I
could
be wrong.
On Thu, 31 Dec 2015 at 1​:26 AM, Rob Hoelz <perl6-bugs-
followup@​perl.org>
wrote​:

# New Ticket Created by Rob Hoelz
# Please include the string​: [perl #​127086]
# in the subject line of all future correspondence about this
issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127086 >

For example, in test.pl​:

use TestModule;

in TestModule.pm​:

BEGIN say 'hi';

If we run test.pl, we get the following failure​:

===SORRY!===
Constraint type check failed for parameter '$precomp-id'

The commit that introduces the problem is 54e0577 on Rakudo.

From IRC (http://irclog.perlgeek.de/perl6/2016-01-03#i_11823821)&#8203;:

21​:49 nine hoelzro​: I would not mind you reopening the
ticket either. But if you do, I'd really appreciate a suggestion for
a fix, because I have no idea :)

My only suggestion for a fix at this time is to perhaps dup standard
output to a file descriptor for writing precomp IDs, open standard
output to /dev/null (or the platform equivalent), and perhaps make
$*OUT a fake handle that notifies the user that $*OUT
isn't available at BEGIN time. The open() is just a safety measure
for things that can access standard output without going through $*OUT
(ex. nqp​::say).

Another idea is to avoid writing precomp IDs to standard output, and
instead provide an output filename via the command line.

@p6rt
Copy link
Author

p6rt commented Feb 27, 2016

From @FROGGS

There is a bandaid now​: rakudo/rakudo@cc0472b43e

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

1 participant