Komodo / KomodoEdit

Komodo Edit is a fast and free multi-language code editor. Written in JS, Python, C++ and based on the Mozilla platform.
http://www.komodoide.com/komodo-edit
Other
2.15k stars 300 forks source link

Perl Interpreter Has Stopped Working #3530

Closed cashfields closed 6 years ago

cashfields commented 6 years ago

Short Summary

Perl Interpreter Has Stopped Working Use Komodo IDE , when executing a small perl script , and opening a DOS window , by checking the two boxes "Simulate ...." and "Debug ...." (see screen print) the perl script runs. But the system fails at the end.

Steps to Reproduce

Run the IDE , for prel XX.PL

For example, if an input file named merge1

contains the lines

a1

a2

a3

and another file, merge2, contains the lines

b1

b2

b3

then the resulting output file consists of

a1

b1

a2

b2

a3

b3

open (INFILE1, "merge1.txt") || die ("Cannot open input file merge1.txt\n"); open (INFILE2, "merge2.txt") || die ("Cannot open input file merge2.txt\n"); $line1 = ; $line2 = ; while ($line1 ne "" || $line2 ne "") { if ($line1 ne "") { print STDOUT ($line1); print ($line1); $line1 = ; } if ($line2 ne "") { print ($line2); $line2 = ; } }

Expected results

A list of data printed: a1 b1 a2 a2 b2 a3 a3 b3

Actual results

Prints , but then WINDOWS say , the "Perl Interpreter Has Stopped Working ..." (see screen print)

Platform Information

Komodo IDE Komodo Version? Komodo IDE, version 11.0.2, build 90813, platform win32-x86. Built on Mon Dec 04 08:56:02 2017. Operating System Windows 10?

See screen prints of system data

Additional Information

If I open a CMD window , and it is run as ADMINISTRATOR ; job runs successfully. No problems.

See screen print.

You need to add another "clicklydoodle" box the say's "Run as Administrator" or just execute the program (CMD and the perl script) as Administrator.

KOMODO FIX ADMIN ON EXECUTE.docx

mitchell-as commented 6 years ago

Hi, this does not sound like a Komodo problem, but a problem with how you are invoking your Perl interpreter. Perhaps the files are owned by admin and cannot be read by a normal user, perhaps any Perl script needs to be run as admin, etc. Regardless, this does not sound like a Komodo bug.

cashfields commented 6 years ago

Mitchell       You guys - KOMODO IDE  - are invoking a CMD window and calling the perl script. When you invoke the CMD window , it does not have ADMIM level. There is nothing that I do other then click two IDE boxes to get the CMD window to open. By clicking the two boxes , the perl program does NOT run in the IDE , but external to the IDE.  So internal to the IDE some call is being made to start a CMD window , and then invoke the perl program.       Please reopen and open your thinking. Look carefully at the first page , the two check boxes from IDE - these say invoke a external console (CMD). Not in the IDE. Look carefully at the tilde on page 4 ; it says: "C":\WINDOWS\system32\ cmd.exe".  This is invoked by the Komodo IDE ; it does not request enough privilege to properly execute the CMD & perl interpreter.  That is why it fails.

UC

On Monday, April 9, 2018, 9:43:18 AM CDT, mitchell <notifications@github.com> wrote:  

Closed #3530.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

shawnlaffan commented 6 years ago

I tested the code, and it does not work, at least as I understand it should. Some steps to reproduce are below.

Running under Strawberry Perl 5.26.1 under Komodo 11.0.2 with the "Simulate CGI Environment" and "Debug in separate console" options set:

syntax error at C:\komodocheck\XX.PL line 5, near "= ;"
syntax error at C:\komodocheck\XX.PL line 6, near "= ;"
Execution of C:\komodocheck\XX.PL aborted due to compilation errors.
Press any key to continue . . .

If I add use strict; use warnings; to the top of the file then I get:

Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 8.
syntax error at C:\komodocheck\XX.PL line 8, near "= ;"
Global symbol "$line2" requires explicit package name (did you forget to declare "my $line2"?) at C:\komodocheck\XX.PL line 9.
syntax error at C:\komodocheck\XX.PL line 9, near "= ;"
Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 10.
Global symbol "$line2" requires explicit package name (did you forget to declare "my $line2"?) at C:\komodocheck\XX.PL line 10.
Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 12.
Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 13.
Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 14.
Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 15.
Global symbol "$line2" requires explicit package name (did you forget to declare "my $line2"?) at C:\komodocheck\XX.PL line 17.
Global symbol "$line2" requires explicit package name (did you forget to declare "my $line2"?) at C:\komodocheck\XX.PL line 19.
Global symbol "$line2" requires explicit package name (did you forget to declare "my $line2"?) at C:\komodocheck\XX.PL line 20.
Execution of C:\komodocheck\XX.PL aborted due to compilation errors.
Press any key to continue . . .

When I correct those lines I get:

Name "main::INFILE2" used only once: possible typo at C:\shawn\git\perlmonks\komodo\XX.PL line 6.
Name "main::INFILE1" used only once: possible typo at C:\shawn\git\perlmonks\komodo\XX.PL line 4.
Press any key to continue . . .

The code never reads from the file handles. Updating the file to do so triggers the crash dialogue, but the code still does not work as intended (so far as I understand it). It also crashes when called outside komodo. See the first set of code below.

The second set of code below works as I understand it should, although it could still be modernised to use lexical file handles.

#  This code segfaults
use strict;
use warnings;

open (INFILE1, "merge1.txt") ||
die ("Cannot open input file merge1.txt\n");
open (INFILE2, "merge2.txt") ||
die ("Cannot open input file merge2.txt\n");
my $line1 = '';
my $line2 = '';
#  not very valid code here, but triggers the seg fault
while ($line1 = <INFILE1> or $line2 = <INFILE2>)
{
if ($line1 ne "") {
print STDOUT ($line1);
print ($line1);
$line1 = '';
}
if ($line2 ne "")
{
print ($line2);
$line2 = '';
}
}
# This code does not segfault
use strict;
use warnings;

open (INFILE1, "merge1.txt") 
  or die ("Cannot open input file merge1.txt\n");
open (INFILE2, "merge2.txt")
  or die ("Cannot open input file merge2.txt\n");
my $line1 = <INFILE1>;
my $line2 = <INFILE2>;
while (defined $line1) {

    if ($line1 ne "") {
        print ($line1);
    }
    if ($line2 ne "")
    {
        print ($line2);
    }
    $line1 = <INFILE1>;
    $line2 = <INFILE2>;

}
cashfields commented 6 years ago

Guys        I added your code and the problem went away. I see the "my" fixed the problem. I am reading an e-book called: (ebook pdf) teach yourself perl in 21 days.pdf

Just don't understand why there is so much difficulty to learn a new language. Thanks for the help.

same code in perl5:http://ft-sipil.unila.ac.id/dbooks/(ebook%20pdf)%20Teach%20Yourself%20Perl%20in%2021%20Days.pdf

=====================from the manual :        (ebook pdf) teach yourself perl in 21 days.pdf around page 247: Merging Two Files into OneIn Perl, you can open as many files as you like, provided you define a different file variable for each one.(Actually, there is an upper limit on the number of files you can open, but it's fairly large and also systemdependent.)For an example of a program that has multiple files open at one time, take a look at Listing 6.5.This program merges two files by creating an output file consisting of one line from the first file, one linefrom the second file, another line from the first file, and so on. For example, if an input file named merge1contains the linesa1a2a3and another file, merge2, contains the linesb1b2b3then the resulting output file consists ofa1b1a2b2a3b3Listing 6.5. A program that merges two files.1: #!/usr/local/bin/perl2:3: open (INFILE1, "merge1") ||4: die ("Cannot open input file merge1\n");5: open (INFILE2, "merge2") ||6: die ("Cannot open input file merge2\n");7: $line1 = ;8: $line2 = ;9: while ($line1 ne "" || $line2 ne "") {10: if ($line1 ne "") {11: print ($line1);12: $line1 = ;13: }14: if ($line2 ne "") {15: print ($line2);16: $line2 = ;17: }18: }$ program6_5a1b1a2b2a3b3$Lines 3 and 4 show another way to write a statement that either opens a file or calls die if theopen fails. Recall that the || operator first evaluates its left operand; if the left operand evaluates to true (anonzero value), the right operand is not evaluated because the result of the expression is true.Because of this, the right operand, the call to die, is evaluated only when the left operand is false-whichhappens only when the call to open fails and the file merge1 cannot be opened.Lines 5 and 6 repeat the preceding process for the file merge2. Again, either the file is opened successfullyor the program aborts by calling die.The program then loops repeatedly, reading a line of input from each file each time. The loop terminatesonly when both files have been exhausted. If one file is empty but the other is not, the program just copiesthe line from the non-empty file to the standard output file.Note that the output from this program is printed on the screen. If you decide that you want to send thisoutput to a file, you can do one of two things:l You can modify the program to write its output to a different file. To do this, open the file in writemode and associate it with a file variable. Then, change the print statements to refer to this filevariable.l You can redirect the standard output file on the command line.For a discussion of the second method, see the following section.

Thanks again - will use "my" from here on out !!

UC

On Monday, April 9, 2018, 4:30:16 PM CDT, shawnlaffan <notifications@github.com> wrote:  

I tested the code, and it does not work, at least as I understand it should. Some steps to reproduce are below.

Running under Strawberry Perl 5.26.1 under Komodo 11.0.2 with the "Simulate CGI Environment" and "Debug in separate console" options set: syntax error at C:\komodocheck\XX.PL line 5, near "= ;" syntax error at C:\komodocheck\XX.PL line 6, near "= ;" Execution of C:\komodocheck\XX.PL aborted due to compilation errors. Press any key to continue . . .

If I add use strict; use warnings; to the top of the file then I get: Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 8. syntax error at C:\komodocheck\XX.PL line 8, near "= ;" Global symbol "$line2" requires explicit package name (did you forget to declare "my $line2"?) at C:\komodocheck\XX.PL line 9. syntax error at C:\komodocheck\XX.PL line 9, near "= ;" Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 10. Global symbol "$line2" requires explicit package name (did you forget to declare "my $line2"?) at C:\komodocheck\XX.PL line 10. Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 12. Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 13. Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 14. Global symbol "$line1" requires explicit package name (did you forget to declare "my $line1"?) at C:\komodocheck\XX.PL line 15. Global symbol "$line2" requires explicit package name (did you forget to declare "my $line2"?) at C:\komodocheck\XX.PL line 17. Global symbol "$line2" requires explicit package name (did you forget to declare "my $line2"?) at C:\komodocheck\XX.PL line 19. Global symbol "$line2" requires explicit package name (did you forget to declare "my $line2"?) at C:\komodocheck\XX.PL line 20. Execution of C:\komodocheck\XX.PL aborted due to compilation errors. Press any key to continue . . .

When I correct those lines I get: Name "main::INFILE2" used only once: possible typo at C:\shawn\git\perlmonks\komodo\XX.PL line 6. Name "main::INFILE1" used only once: possible typo at C:\shawn\git\perlmonks\komodo\XX.PL line 4. Press any key to continue . . .

The code never reads from the file handles. Updating the file to do so triggers the crash dialogue, but the code still does not work as intended (so far as I understand it). It also crashes when called outside komodo. See the first set of code below.

The second set of code below works as I understand it should, although it could still be modernised to use lexical file handles.

This code segfaults

use strict; use warnings;

open (INFILE1, "merge1.txt") || die ("Cannot open input file merge1.txt\n"); open (INFILE2, "merge2.txt") || die ("Cannot open input file merge2.txt\n"); my $line1 = ''; my $line2 = '';

not very valid code here, but triggers the seg fault

while ($line1 = or $line2 = ) { if ($line1 ne "") { print STDOUT ($line1); print ($line1); $line1 = ''; } if ($line2 ne "") { print ($line2); $line2 = ''; } }# This code does not segfault use strict; use warnings;

open (INFILE1, "merge1.txt") or die ("Cannot open input file merge1.txt\n"); open (INFILE2, "merge2.txt") or die ("Cannot open input file merge2.txt\n"); my $line1 = ; my $line2 = ; while (defined $line1) {

if ($line1 ne "") {
    print ($line1);
}
if ($line2 ne "")
{
    print ($line2);
}
$line1 = <INFILE1>;
$line2 = <INFILE2>;

} — You are receiving this because you authored the thread.

Reply to this email directly, view it on GitHub, or mute the thread.

shawnlaffan commented 6 years ago

The book you are using is copyright 1996. You'd be better off using a more recent resource such as https://perlmaven.com/perl-tutorial or (at a more advanced level) https://pragprog.com/book/swperl/modern-perl-fourth-edition

You could also try perlmonks (e.g. http://www.perlmonks.org/?node_id=1172488) or stack overflow for perl specific problems.

Naatan commented 6 years ago

Thanks for helping out @shawnlaffan ! :)

cashfields commented 6 years ago

Shawn      Thanks.

UC

On Monday, April 9, 2018, 6:30:01 PM CDT, shawnlaffan <notifications@github.com> wrote:  

The book you are using is copyright 1996. You'd be better off using a more recent resource such as https://perlmaven.com/perl-tutorial or (at a more advanced level) https://pragprog.com/book/swperl/modern-perl-fourth-edition

You could also try perlmonks (e.g. http://www.perlmonks.org/?node_id=1172488) or stack overflow for perl specific problems.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

shawnlaffan commented 6 years ago

No worries.

Shawn.