develooper Front page | perl.perl5.porters | Postings from November 2003

Re: $^E bug and perl 5.8.0

Thread Previous | Thread Next
From:
Chris Nandor
Date:
November 19, 2003 08:19
Subject:
Re: $^E bug and perl 5.8.0
Message ID:
p06010208bbe146e84d8b@[10.0.1.177]
At 11:13 -0500 2003.11.19, Dan Sugalski wrote:
>On Wed, 19 Nov 2003, Rafael Garcia-Suarez wrote:
>
>> Dan Sugalski wrote:
>> > Basically you're using a variable that can be affected by external things
>> > in a way that pretty much guarantees that external things will be
>> > happening. That it changes isn't much of a surprise. ($!/$^E may get
>> > modified by some signal handlers too, depending on what you do, so there's
>> > not even any guarantee that "$^E = 42; $^E++;" will end up with $^E set to
>> > 43.
>>
>> Using the Mac OS X equivalent of truss/strace might help to find out
>> why errno changes there.
>
>My bet would be that the print triggers an errno update, which strikes me
>as perfectly reasonable.

Yes, I just realized you might think that, and I should have been more
descriptive: it happens regardless of print.

  $ ktrace perl -le '$! = -1728; $x = $^E+0; $y = $^E+0; print $x; print $y'
  -1728
  22


It has nothing to do with addition, either:  :-)

  $ ktrace perl -le '$! = -1728; $x = $^E; $y = $^E; print $x; print $y'
  Unknown error: -1728
  Invalid argument


And since it doesn't change with $!, it is not merely because the error is
unknown:

  $ ktrace perl -le '$! = -1728; $x = $!; $y = $!; print $x; print $y'
  Unknown error: -1728
  Unknown error: -1728


Also, the ktrace output of that is identical to the output of the original
(modulo addresses and PIDs):

  $ ktrace perl -le '$! = -1728; print $^E+0 for 0,1'
  -1728
  22

No syscalls between the two assignments.  No reason for errno to update.
And even if it did, why would it only update when $^E is printed, and not
$!?

ktrace/kdump output below if anyone cares.  But there's got to be something
different about $^E from $! that is causing this bug.

  1343 ktrace   RET   ktrace 0
  1343 ktrace   CALL  execve(0xbffff3b0,0xbffff9e8,0xbffff9f8)
  1343 ktrace   NAMI  "/Users/pudge/bin/perl"
  1343 ktrace   RET   execve -1 errno 2 No such file or directory
  1343 ktrace   CALL  execve(0xbffff3b0,0xbffff9e8,0xbffff9f8)
  1343 ktrace   NAMI  "/usr/local/slash/bin/perl"
  1343 ktrace   RET   execve -1 errno 2 No such file or directory
  1343 ktrace   CALL  execve(0xbffff3b0,0xbffff9e8,0xbffff9f8)
  1343 ktrace   NAMI  "/usr/local/apache/bin/perl"
  1343 ktrace   RET   execve -1 errno 2 No such file or directory
  1343 ktrace   CALL  execve(0xbffff3b0,0xbffff9e8,0xbffff9f8)
  1343 ktrace   NAMI  "/usr/local/bin/perl"
  1343 ktrace   NAMI  "/usr/lib/dyld"
  1343 perl     RET   execve 0
  1343 perl     CALL  getuid
  1343 perl     RET   getuid 502/0x1f6
  1343 perl     CALL  getuid
  1343 perl     RET   getuid 502/0x1f6
  1343 perl     CALL  getuid
  1343 perl     RET   getuid 502/0x1f6
  1343 perl     CALL  getgid
  1343 perl     RET   getgid 20/0x14
  1343 perl     CALL  getgid
  1343 perl     RET   getgid 20/0x14
  1343 perl     CALL  open(0x13d8,0,0)
  1343 perl     NAMI  "/usr/local/lib/perl5/5.8.0/darwin/CORE/libperl.dylib"
  1343 perl     RET   open 3
  1343 perl     CALL  fstat(0x3,0xbffff770)
  1343 perl     RET   fstat 0
  1343 perl     CALL  close(0x3)
  1343 perl     RET   close 0
  1343 perl     CALL  open(0x1428,0,0)
  1343 perl     NAMI  "/usr/lib/libSystem.B.dylib"
  1343 perl     RET   open 3
  1343 perl     CALL  fstat(0x3,0xbffff770)
  1343 perl     RET   fstat 0
  1343 perl     CALL
load_shared_file(0x1428,0x22b000,0x1798fc,0xbffff580,0x4,0xbffff510,0xbffff584)
  1343 perl     NAMI  "/usr/lib/libSystem.B.dylib"
  1343 perl     RET   load_shared_file 0
  1343 perl     CALL  close(0x3)
  1343 perl     RET   close 0
  1343 perl     CALL  open(0x900006e8,0,0)
  1343 perl     NAMI  "/usr/lib/system/libmathCommon.A.dylib"
  1343 perl     RET   open 3
  1343 perl     CALL  fstat(0x3,0xbffff700)
  1343 perl     RET   fstat 0
  1343 perl     CALL
load_shared_file(0x900006e8,0x7000,0x6ac4,0xbffff510,0x3,0xbffff4a0,0xbffff514)
  1343 perl     NAMI  "/usr/lib/system/libmathCommon.A.dylib"
  1343 perl     RET   load_shared_file 0
  1343 perl     CALL  close(0x3)
  1343 perl     RET   close 0
  1343 perl     CALL  __sysctl(0xbffff918,0x2,0xbffff920,0xbffff924,0,0)
  1343 perl     RET   __sysctl 0
  1343 perl     CALL  sigaction(0x8,0xbffff850,0xbffff8c0)
  1343 perl     RET   sigaction 0
  1343 perl     CALL  getuid
  1343 perl     RET   getuid 502/0x1f6
  1343 perl     CALL  getuid
  1343 perl     RET   getuid 502/0x1f6
  1343 perl     CALL  getgid
  1343 perl     RET   getgid 20/0x14
  1343 perl     CALL  getgid
  1343 perl     RET   getgid 20/0x14
  1343 perl     CALL  open(0x3011c0,0,0x1b6)
  1343 perl     NAMI  "/dev/null"
  1343 perl     RET   open 3
  1343 perl     CALL  fcntl(0x3,0x2,0x1)
  1343 perl     RET   fcntl 0
  1343 perl     CALL  sigaction(0x14,0,0xbffff3e0)
  1343 perl     RET   sigaction 0
  1343 perl     CALL  getpid
  1343 perl     RET   getpid 1343/0x55a
  1343 perl     CALL  close(0x3)
  1343 perl     RET   close 0
  1343 perl     CALL  fstat(0x1,0xbffff100)
  1343 perl     RET   fstat 0
  1343 perl     CALL  ioctl(0x1,FIODTYPE,0xbffff150)
  1343 perl     RET   ioctl 0
  1343 perl     CALL  write(0x1,0x7000,0x6)
  1343 perl     GIO   fd 1 wrote 6 bytes
       "-1728
       "
  1343 perl     RET   write 6
  1343 perl     CALL  write(0x1,0x7000,0x3)
  1343 perl     GIO   fd 1 wrote 3 bytes
       "22
       "
  1343 perl     RET   write 3
  1343 perl     CALL  exit(0)

-- 
Chris Nandor                      pudge@pobox.com    http://pudge.net/
Open Source Development Network    pudge@osdn.com     http://osdn.com/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About