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

Remap symname [RT #94221] #20

Merged
merged 2 commits into from
Mar 28, 2014
Merged

Remap symname [RT #94221] #20

merged 2 commits into from
Mar 28, 2014

Conversation

rurban
Copy link
Contributor

@rurban rurban commented Mar 26, 2014

Allow remapping of external symbols in the shared lib at run-time for perlcc.
See https://rt.cpan.org/Public/Bug/Display.html?id=94221

Reini Urban added 2 commits March 26, 2014 12:32
Store the symbol name along the IV ptr as SVp_POK PVX.
This is needed for perlcc when thawing frozen images, where an
encoding object was initialized at compile-time, pointing to
an extern symbol of the shared library, and need to be remapped
to the new ptr at run-time.
See e.g. https://rt.cpan.org/Public/Bug/Display.html?id=94069
where Net::DNS uses an encoding via use constant, causing a segfault,
and https://code.google.com/p/perl-compiler/issues/detail?id=305 for
the perlcc support code.
Which is something along:

  #include <dlfcn.h>
  void *handle = dlopen(sofile, RTLD_NOW|RTLD_NOLOAD);
  void *ascii_encoding = dlsym(handle, "ascii_encoding");
  SvIV_set(&sv_list[1], PTR2IV(ascii_encoding));

Detection:
  https://github.com/rurban/perl-compiler/blob/ce6ce452dd8fcc9bb90605dcf47489250fd540a1/lib/B/C.pm#L2545
Remapping:
  https://github.com/rurban/perl-compiler/blob/ce6ce452dd8fcc9bb90605dcf47489250fd540a1/lib/B/C.pm#L4851
Tested ok on all major perl versions:
$ perlall -mq maketest
$ grep Result: log.test-linuxmint1-5.*
log.test-linuxmint1-5.10.1d:Result: PASS
log.test-linuxmint1-5.10.1-nt:Result: PASS
log.test-linuxmint1-5.12.5:Result: PASS
log.test-linuxmint1-5.12.5-nt:Result: PASS
log.test-linuxmint1-5.14.4:Result: PASS
log.test-linuxmint1-5.14.4-nt:Result: PASS
log.test-linuxmint1-5.16.3:Result: PASS
log.test-linuxmint1-5.16.3-nt:Result: PASS
log.test-linuxmint1-5.18.2:Result: PASS
log.test-linuxmint1-5.18.2-nt:Result: PASS
log.test-linuxmint1-5.8.4d-nt:Result: PASS
log.test-linuxmint1-5.8.5-nt:Result: PASS
log.test-linuxmint1-5.8.8d-nt:Result: PASS
log.test-linuxmint1-5.8.9:Result: PASS
log.test-linuxmint1-5.8.9-nt:Result: PASS

In particular it is safe not to use a heap copy of the PVX
since it's a SVp_POK with LEN=0, which is never freed, thus freed
along the shared library.
dankogai added a commit that referenced this pull request Mar 28, 2014
@dankogai dankogai merged commit 6565370 into dankogai:master Mar 28, 2014
jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Jul 16, 2014
2.62 2014/05/31 12:12:39
! Encode.pm
  s/2013/2014/ on COPYRIGHT section
! Byte/Makefile.PL
  CN/Makefile.PL
  EBCDIC/Makefile.PL
  Encode/Makefile_PL.e2x
  Encode.xs
  JP/Makefile.PL
  KR/Makefile.PL
  Symbol/Makefile.PL
  TW/Makefile.PL
  bin/enc2xs
  Merged from perl.git: "Fix Encode 2.60 with g++"
  http://perl5.git.perl.org/perl.git/commit/89c2544cd3

2.61 2014/05/31 09:48:48
! bin/piconv
  Applied: piconv nit
  + Better error handling when the encoding name is nonexistent
  Message-Id: <[email protected]>
! Encode.xs
  Applied: RT #95466:
   fallback definition of SvIsCOW() is wrong
   (and hence breaks on 5.8.2 and earlier)
  https://rt.cpan.org/Ticket/Display.html?id=95466

2.60 2014/04/29 16:25:06
! Byte/Makefile.PL
  CN/Makefile.PL
  EBCDIC/Makefile.PL
  Encode/Makefile_PL.e2x
  Encode/encode.h
  JP/Makefile.PL
  KR/Makefile.PL
  Symbol/Makefile.PL
  TW/Makefile.PL
  bin/enc2xs
  encengine.c
  Applied: more Fix Windows build (of Encode) with VC++ 6.0
  http://perl5.git.perl.org/perl.git/commit/9e9002efd1609c7d154f98af43a026320df7582c
! Unicode/Unicode.xs
  Addressed: sign extension issue found by Coverity #21
  dankogai/p5-encode#21
! Encode/encode.h Encode.xs Unicode/Unicode.xs
  removed #define U8 U8
  https://rt.perl.org/Ticket/Display.html?id=121554
  http://perl5.git.perl.org/perl.git/commit/2f2b4ff2c154a8e461857f2e82cb815c238d0d94

2.59 2014/04/06 17:23:55
! Byte/Makefile.PL
  CN/Makefile.PL
  EBCDIC/Makefile.PL
  Encode.pm
  Encode.xs
  Encode/Makefile_PL.e2x
  JP/Makefile.PL
  KR/Makefile.PL
  Symbol/Makefile.PL
  TW/Makefile.PL
  bin/enc2xs
  Restored the signature of Encode_XSEncoding() to address RT#94478
  * While dankogai/p5-encode#20
    pulls the symnames via argument thus breaks the compatibility
    with Encode::XX modules with *.ucm, the restored version
    pulls the symanmes via enc->name[0] so the added 2nd argument
    is no longer needed.
  https://rt.cpan.org/Public/Bug/Display.html?id=94478

2.58 2014/03/28 02:37:42
! bin/piconv
  Addressed: piconv bug of decoding UTF-16 (with fix)
  dankogai/p5-encode#19
! Byte/Makefile.PL
  CN/Makefile.PL
  EBCDIC/Makefile.PL
  Encode.pm
  Encode.xs
  Encode/Makefile_PL.e2x
  JP/Makefile.PL
  KR/Makefile.PL
  Symbol/Makefile.PL
  TW/Makefile.PL
  bin/enc2xs
  Pulled: Remap symname [RT #94221]
  dankogai/p5-encode#20
  https://rt.cpan.org/Public/Bug/Display.html?id=94221
! Encode.pm
  Pulled: [doc] clarify that CHECK coderefs return octets #18
  dankogai/p5-encode#18
jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Oct 11, 2014
2.62 2014/05/31 12:12:39
! Encode.pm
  s/2013/2014/ on COPYRIGHT section
! Byte/Makefile.PL
  CN/Makefile.PL
  EBCDIC/Makefile.PL
  Encode/Makefile_PL.e2x
  Encode.xs
  JP/Makefile.PL
  KR/Makefile.PL
  Symbol/Makefile.PL
  TW/Makefile.PL
  bin/enc2xs
  Merged from perl.git: "Fix Encode 2.60 with g++"
  http://perl5.git.perl.org/perl.git/commit/89c2544cd3

2.61 2014/05/31 09:48:48
! bin/piconv
  Applied: piconv nit
  + Better error handling when the encoding name is nonexistent
  Message-Id: <[email protected]>
! Encode.xs
  Applied: RT #95466:
   fallback definition of SvIsCOW() is wrong
   (and hence breaks on 5.8.2 and earlier)
  https://rt.cpan.org/Ticket/Display.html?id=95466

2.60 2014/04/29 16:25:06
! Byte/Makefile.PL
  CN/Makefile.PL
  EBCDIC/Makefile.PL
  Encode/Makefile_PL.e2x
  Encode/encode.h
  JP/Makefile.PL
  KR/Makefile.PL
  Symbol/Makefile.PL
  TW/Makefile.PL
  bin/enc2xs
  encengine.c
  Applied: more Fix Windows build (of Encode) with VC++ 6.0
  http://perl5.git.perl.org/perl.git/commit/9e9002efd1609c7d154f98af43a026320df7582c
! Unicode/Unicode.xs
  Addressed: sign extension issue found by Coverity #21
  dankogai/p5-encode#21
! Encode/encode.h Encode.xs Unicode/Unicode.xs
  removed #define U8 U8
  https://rt.perl.org/Ticket/Display.html?id=121554
  http://perl5.git.perl.org/perl.git/commit/2f2b4ff2c154a8e461857f2e82cb815c238d0d94

2.59 2014/04/06 17:23:55
! Byte/Makefile.PL
  CN/Makefile.PL
  EBCDIC/Makefile.PL
  Encode.pm
  Encode.xs
  Encode/Makefile_PL.e2x
  JP/Makefile.PL
  KR/Makefile.PL
  Symbol/Makefile.PL
  TW/Makefile.PL
  bin/enc2xs
  Restored the signature of Encode_XSEncoding() to address RT#94478
  * While dankogai/p5-encode#20
    pulls the symnames via argument thus breaks the compatibility
    with Encode::XX modules with *.ucm, the restored version
    pulls the symanmes via enc->name[0] so the added 2nd argument
    is no longer needed.
  https://rt.cpan.org/Public/Bug/Display.html?id=94478

2.58 2014/03/28 02:37:42
! bin/piconv
  Addressed: piconv bug of decoding UTF-16 (with fix)
  dankogai/p5-encode#19
! Byte/Makefile.PL
  CN/Makefile.PL
  EBCDIC/Makefile.PL
  Encode.pm
  Encode.xs
  Encode/Makefile_PL.e2x
  JP/Makefile.PL
  KR/Makefile.PL
  Symbol/Makefile.PL
  TW/Makefile.PL
  bin/enc2xs
  Pulled: Remap symname [RT #94221]
  dankogai/p5-encode#20
  https://rt.cpan.org/Public/Bug/Display.html?id=94221
! Encode.pm
  Pulled: [doc] clarify that CHECK coderefs return octets #18
  dankogai/p5-encode#18
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

Successfully merging this pull request may close these issues.

2 participants