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
The "my" variables and "@_" in the underlying frame are corrupted. Cc: abs@auriga.ru #420
Comments
From abs@auriga.ru |
From abs@auriga.ru This is a report about the possible bug in Perl. Revision of the Perl where the bug has been encountered. This is perl, version 5.005_03 built for MSWin32-x86-object (with 1 registered patch, see perl -V for more detail) Built 13:14:00 Jun 24 1999 Perl may be copied only under the terms of either the Artistic License GNU General Public License, which may be found in the Perl 5.0 source this system using `man perl' or `perldoc perl'. If you have access Internet, point your browser at http://www.perl.com/, the Perl Home Disclaimer. Also I'm a novice in Perl so I cannot give the expert conclusion about I was involved as a debugger and found that not everything is OK. Up to my C-programmer experience I can suggest that my variables How to reproduce the problem. To generate the debugging output please use: # perl badguy.pl > badguy.out # perl dbadm.pl > dbadm.out # perl -d badguy.pl
What is wrong. ..... ($DBName_C,$FExpr,$Reg)=@_; ..... # @save = @_; # $DBName_C=$dbname; We found that 1. @_ variable is different BEFORE and AFTER the call to CalculateConditions . 2. The value of local (defined as my ) variable $DBName_C And nobody expected that the arguments vector could be modified implicitly. print(" HERE0 CalculateConditions(@_)::argc=$argc, DBNameC=$DBNameC, $calc=CalculateExpr($DB_name,$CondExpr,1); print(" HERE1 CalculateConditions(@_)::argc=$argc, DBNameC=$DBNameC, ENTER CalculateExpr(Goods GooCode 1):: DBName_C=Goods, FExpr=GooCode, MIDDLE CalculateExpr(Goods GooCode 1):: DBName_C=Goods, FExpr=GooCode, DONE CalculateExpr(Goods GooCode 1):: DBName_C=Goods, FExpr=GooCode, REPLY CalculateExpr::RetValue=2 HERE1 CalculateConditions( Goods )::argc=2, DBNameC=Orders, Nobody had the intention to use references, so we expect that all variables At least it shows effects that couldn't happen if @_ is just an array Debugging and the place that makes bad thing. Function calls stack BEFORE the mess looks like this (top-down): GetFieldsNamesList( 'Goods' , 'd:\project\data'); CalculateConditions('Orders', 'Goods.<RecordNumber>.....'); CalculateExpr( 'Orders' , 'Goods.SUnitPrice'); CheckAndCount(5); AddToDB('Orders'); This is the following code in the my $Regim=0; #Not full in array for calculating my @FieldNames, $DBName,$DBDir; ($DBName,$DBDir) = @_; # here CORRUPTED NOW stack looks as it was described above. After this stack of calls looks like this: GetFieldsNamesList( 'Goods' , 'd:\project\data'); CalculateConditions('Orders', 'Goods.<RecordNumber>.....'); CalculateExpr( 'Goods' , 'Goods.SUnitPrice'); CheckAndCount(5); AddToDB('Orders'); What is wrong: 1. We assign the value to my variable in the topmost This change should be local to this frame. 2. Instead, this assignment affects two other places: a) the variable that has been declared as my b) the arguments array for underlying CalculateExpr In C language this may happen ONLY if the element of the vector is variable being changed and the my variables inside the stack are placed into the same memory space. Once again. More failures. In this case the @_ is NOT corrupted, however the value of $DBName_C Look again at the lines BEFORE and AFTER, at the value of $DBName_C. Take a look at the file 04.pl -- it is a model of the mainstream program. Help needed. 1. Will this behaviour appear in the latest version of Perl? 2. Will it happen on UNIX version? Answer is: YES. 3. May be something in the PROGRAM is wrong? Thanks. - fixing our program.(if this is our bug; don't suggest workarounds - fixing Perl - telling us what's wrong in the World :-) Andrew Bogatyrev. |
Migrated from rt.perl.org#1257 (status was 'resolved')
Searchable as RT1257$
The text was updated successfully, but these errors were encountered: