#995856 "sysread() isn't allowed on :utf8 handles at /usr/share/perl5/Expect.pm line 849."

#995856#5
Date:
2021-10-07 06:03:29 UTC
From:
To:
When using Expect.pm, the script dies with the above message.

The startup code is

   $gdb = new Expect;
   $gdb->raw_pty(1);
   $gdb->log_stdout(1);
   $gdb->spawn("gdb 2>&1", ()) or die "Cannot spawn gdb: $!\n";

followed later on by

   $obj->print_log_file("...");
   $obj->send("...");
   $obj->expect($TIMEOUT, "...");

#995856#10
Date:
2021-10-07 07:56:51 UTC
From:
To:

#995856#15
Date:
2021-10-10 17:19:34 UTC
From:
To:
Hmm, strange. So a new version would not help.

Maybe this has some connection to your problem?
https://github.com/perl/perl5/issues/14839

#995856#20
Date:
2021-10-11 09:59:07 UTC
From:
To:
Reads like the reason why it now errors, yeah.
#995856#25
Date:
2021-10-11 14:54:38 UTC
From:
To:
---

perldoc -f sysread

"Note that if the filehandle has been marked as ":utf8",
            "sysread" will throw an exception. "
--- https://github.com/Perl/perl5/issues/17885 "The sysread(), recv(), syswrite() and send() operators are deprecated on handles that have the ":utf8" layer, either explicitly, or implicitly, eg., with the ":encoding(UTF-16LE)" layer." "The problem is that it assumes the byte stream will be in Perl's internal upgraded encoding (:utf8, which is kind of like UTF-8 but not quite), but ignores any other layers on the handle which could be really important, like an :encoding layer that actually translates that internal encoding to a completely different encoding, or a :crlf you might then expect to be noticed. So in the case of non-UTF-8 encodings it was actually completely broken, and when you only mean to use it for UTF-8 it is risky (like using :utf8 in general for input), so in 5.30 it is an error."
--- It seems as if it isn't going to be resolved either. I would suggest that you should try to rewrite your code. /Jörgen
#995856#30
Date:
2021-10-12 05:38:30 UTC
From:
To:
Yeah, that's my understanding as well.

Well, that's the thing - it doesn't error in my code but in Expect.pm!

Expect opens the pipes and does the reading/writing -
my script is only using the API...


That's why I opened the bug against the library, after all ;/

#995856#35
Date:
2021-10-12 15:04:42 UTC
From:
To:
True, you have a point. :-)

I'll send it upstream.