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

malloc(): memory corruption Aborted (core dumped) #2398

Closed
ToddAndMargo opened this issue Oct 20, 2018 · 2 comments
Closed

malloc(): memory corruption Aborted (core dumped) #2398

ToddAndMargo opened this issue Oct 20, 2018 · 2 comments

Comments

@ToddAndMargo
Copy link

$ perl6 -v
This is Rakudo version 2018.06 built on MoarVM version 2018.06 implementing Perl 6.c.

$ rpm -qa rakudo*
rakudo-pkg-2018.06-01.x86_64

sub RunNoShellAll( Str $RunString, Int $StdOut, Int $StdErr, Int $Code --> List )
malloc(): memory corruption Aborted (core dumped)

sub RunNoShellAll( Str $RunString, Int $StdOut, Int $StdErr, Int $Code, --> List )
free(): invalid next size (fast) Aborted (core dumped)

Removing --> List completely restored functionality

@ToddAndMargo
Copy link
Author

ToddAndMargo commented Oct 20, 2018

The rest of the sub:

sub RunNoShellAll( Str $RunString, Int $StdOut, Int $StdErr, Int $Code ) {
   # returns  
   #    StdOut as Str $ReturnStr
   #    StdErr as Str $ReturnErr
   #    Return Code ($?) as Int $RtnCode

   # $RunString   Comnad line to run without a shell
   # $StdOur      read and return the STDOUT       1=yes, 0=no
   # $StdErr      read and return the STDERR       1=yes, 0=no    
   # $Code        read and return the return code  1=yes, 0=no 
  
   # Note: If reading the STDERR, it is PRESUMED you also will be reading the STDIN.
   #       If only reading the return code, it is presumed that you want the STDERR
   #          and STDIN to be silent.
  
   # place each value into a cell in an array.  Keep quoted 
   # values together
   # print "Run String = <$RunString>\n";
   
    
   my Buf $BufStdErr; 
   my Str $ReturnStr = ""; 
   my Str $ReturnErr = "";
   my Int $RtnCode = 0;
   my $proc;
   
   my @RunArray  = $RunString ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /;
   
   # shells remove the quote, so you have to here as well
   for @RunArray.kv -> $index, $value { @RunArray[$index] ~~ s:g/\"//; };
   # for @RunArray.kv -> $index, $value { say "\$RunArray[$index] = <$value>"; }; print "\n";
   
   if    $StdErr  { $proc      = run( @RunArray, :err, :out, :enc<utf8-c8> ); }  
   elsif $StdOut  { $proc      = run( @RunArray,       :out, :enc<utf8-c8> ); }  # STDERR goes to the terminal
   else           { $proc      = run( @RunArray, :err, :out, :enc<utf8-c8> ); }  # STDIN and STDERR are silent
   
   if  $Code    { $RtnCode   = $proc.status; } 
   if  $StdErr  { $ReturnErr = $proc.err.slurp; }
   if  $StdOut  { $ReturnStr = $proc.out.slurp; } 
   
   return( $ReturnStr, $ReturnErr, $RtnCode );
}

@zoffixznet
Copy link
Contributor

Moved to rakudo/rakudo#2403

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

2 participants