Skip to content

Comments

fix Issue 16291 - EncodingScheme.create fails#4840

Merged
schveiguy merged 2 commits intodlang:stablefrom
MartinNowak:fix16291
Oct 5, 2016
Merged

fix Issue 16291 - EncodingScheme.create fails#4840
schveiguy merged 2 commits intodlang:stablefrom
MartinNowak:fix16291

Conversation

@MartinNowak
Copy link
Member

@MartinNowak MartinNowak commented Oct 4, 2016

  • add EncodingScheme.register overload that references the registered class
  • just adding the FQN name of a class does not reference that class, so
    it must not end up in the binary and subsequently EncodingScheme.create failed
  • This used to work by chance b/c all the EncodingScheme implementations
    were in a module w/ static ctor. Any user of std.encoding did drag in
    that ModuleInfo, which in turn referenced all classes of std.encoding.
    Since moving the static ctor to std.internal.phobosinit to break a
    cycle, the classes were no longer referenced by a ModuleInfo w/ shared
    ctor, so they wouldn't end up in the binary unless explicitly
    referenced elsewhere.
  • deprecate the old EncodingScheme.register(string fqn) b/c relying on
    Object.factory is slow, error prone (linkage), and really unnecessary
  • import encodinginit in std.encoding so that the
    outsourced static ctor actually gets run

Please merge #4839 first so this can be rebased and only the diff for Issue 16291 gets shown.
Alternatively just ignore the first commit belonging to #4839.

- partially Revert "Merge pull request dlang#4493 from schveiguy/fixcycles2"
- recreate processinit (and import it from std.process)
  to call std.process shared ctor w/o creating a cycle
- keep it separate from phobosinit to not drag std.encoding
  into any binary using std.process
@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
16291 phobosinit never gets called (EncodingScheme.create fails)
16580 [REG 2.072.0-b1] spawnShell segfaults on macOS

@MartinNowak MartinNowak mentioned this pull request Oct 4, 2016
@MartinNowak
Copy link
Member Author

MartinNowak commented Oct 4, 2016

Unfortunately we can't really test for that bug from within phobos, need to add some additional tests like we have for druntime, but that's somewhat out of scope. Tested the old and the new register functions manually.

- add EncodingScheme.register overload that references the registered class
- just adding the FQN name of a class does not reference that class, so
  it must not end up in the binary and subsequently EncodingScheme.create failed
- This used to work by chance b/c all the EncodingScheme implementations
  were in a module w/ static ctor. Any user of std.encoding did drag in
  that ModuleInfo, which in turn referenced all classes of std.encoding.
  Since moving the static ctor to std.internal.phobosinit to break a
  cycle, the classes were no longer referenced by a ModuleInfo w/ shared
  ctor, so they wouldn't end up in the binary unless explicitly
  referenced elsewhere.
- deprecate the old EncodingScheme.register(string fqn) b/c relying on
  Object.factory is slow, error prone (linkage), and really unnecessary
- import encodinginit in std.encoding so that the
  std_encoding_shared_static_this callback actually gets run
@schveiguy
Copy link
Member

Nice, LGTM.

I think we merge this and close the other PR.

@schveiguy
Copy link
Member

Auto-merge toggled on

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.

3 participants