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

lock opcode too weak #908

Closed
p5pRT opened this issue Dec 1, 1999 · 4 comments
Closed

lock opcode too weak #908

p5pRT opened this issue Dec 1, 1999 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 1, 1999

Migrated from rt.perl.org#1843 (status was 'resolved')

Searchable as RT1843$

@p5pRT
Copy link
Author

p5pRT commented Dec 1, 1999

From dan@sidhe.org

The lock opcode is too weak. If the main​::lock gv exists for any reason,
including something like a reference to $lock, then perl uses the main​::lock()
sub instead of the lock opcode.

Perl Info


Site configuration information for perl 5.00503:

Configured by unknown at Mon aug 09 15:49:23.42 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=VMS, osvers=V7.2, archname=VMS_AXP
    uname='VMS nydv20 V7.2 AlphaServer 1200 5/533 4MB'
    hint=none, useposix=false, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='CC/DECC', optimize='undef', gccversion=undef
    cppflags='undef'
    ccflags ='/Include=[]/Standard=Relaxed_ANSI/Prefix=All/Obj=.obj/NoList'
    stdchar='char', d_stdstdio=define, usevfork=true
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=N, prototype=define
  Linker and Libraries:
    ld='Link', ldflags ='/NoTrace/NoMap'
    libpth=/sys$share /sys$library
    libs=
    libc=(DECCRTL), so=exe, useshrplib=undef, libperl=undef
  Dynamic Linking:
    dlsrc=dl_vms.c, dlext=exe, d_dlsymun=undef, ccdlflags=''
    cccdlflags='', lddlflags='/Share'

Locally applied patches:
    


@INC for perl 5.00503:
    perl_root:[lib.VMS_AXP.5_00503]
    perl_root:[lib]
    perl_root:[lib.site_perl.VMS_AXP]
    perl_root:[lib.site_perl]
    .


Environment for perl 5.00503:
    HOME=sys$sysdevice:[dsugalski]
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=sys$sysdevice:[dsugalski.perl5_005_03]
    PERLSHR=PERL_ROOT:[000000]PERLSHR
    PERL_BADLANG (unset)
    PERL_ROOT=DSA0:[PERL.PERL5_005_03.]
    SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Dec 1, 1999

From [Unknown Contact. See original ticket]

At 04​:00 PM 12/1/99 -0500, Dan Sugalski wrote​:

The lock opcode is too weak. If the main​::lock gv exists for any reason,
including something like a reference to $lock, then perl uses the
main​::lock()
sub instead of the lock opcode.

Of course, the question is what to do about this?

Part of me's tempted to have toke.c check the CV slot to see if there's
anything there, and part's tempted to change this so pp_lock's smart enough
to check on the fly and morph at runtime into a sub call to main​::lock if
the CV's real.

Of course, there's the part that's thinking this'll all be moot as of 5.6
anyway so it doesn't much matter, though having a generic mechanism to
handle weak opcodes would be nice. (Assuming we decide they're a good idea
in the first place...)

  Dan

----------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
dan@​sidhe.org have teddy bears and even
  teddy bears get drunk

@p5pRT
Copy link
Author

p5pRT commented Dec 4, 1999

From @gsar

On Wed, 01 Dec 1999 16​:00​:41 EST, Dan Sugalski wrote​:

The lock opcode is too weak. If the main​::lock gv exists for any reason,
including something like a reference to $lock, then perl uses the main​::lock()
sub instead of the lock opcode.

Try this.

Sarathy
gsar@​ActiveState.com

Inline Patch
-----------------------------------8<-----------------------------------
Change 4643 by gsar@auger on 1999/12/04 21:55:27

	make weak keyword check look for defined(&lock), not
	merely defined(*lock)

Affected files ...

... //depot/perl/toke.c#167 edit

Differences ...

==== //depot/perl/toke.c#167 (text) ====
Index: perl/toke.c
--- perl/toke.c.~1~	Sat Dec  4 13:55:32 1999
+++ perl/toke.c	Sat Dec  4 13:55:32 1999
@@ -3502,6 +3502,7 @@
 	    }
 	    else if (gv && !gvp
 		     && -tmp==KEY_lock	/* XXX generalizable kludge */
+		     && GvCVu(gv)
 		     && !hv_fetch(GvHVn(PL_incgv), "Thread.pm", 9, FALSE))
 	    {
 		tmp = 0;		/* any sub overrides "weak" keyword */
End of Patch.

@p5pRT
Copy link
Author

p5pRT commented Dec 6, 1999

From [Unknown Contact. See original ticket]

At 01​:57 PM 12/4/99 -0800, Gurusamy Sarathy wrote​:

On Wed, 01 Dec 1999 16​:00​:41 EST, Dan Sugalski wrote​:

The lock opcode is too weak. If the main​::lock gv exists for any reason,
including something like a reference to $lock, then perl uses the
main​::lock()
sub instead of the lock opcode.

Try this.
make weak keyword check look for defined(&lock), not
merely defined(*lock)

Cool. The one thing I was thinking of instead of this was a runtime
check--have perl always emit the lock opcode and have it do a subroutine
call instead if there's a lock sub defined in the current package. (Which
would also catch the cases where there is a lock sub but it's defined after
it's been used) Adds an extra lookup for each usage, though.

If we plan on introducing other 'weak' opcodes it makes sense, otherwise it
doesn't. I can generate a patch to do it this way if you want.

  Dan

----------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
dan@​sidhe.org have teddy bears and even
  teddy bears get drunk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant