fix Issue 16291 - EncodingScheme.create fails#4840
Merged
schveiguy merged 2 commits intodlang:stablefrom Oct 5, 2016
Merged
Conversation
- 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
Contributor
Merged
Member
Author
|
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
Member
|
Nice, LGTM. I think we merge this and close the other PR. |
Member
|
Auto-merge toggled on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
it must not end up in the binary and subsequently EncodingScheme.create failed
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.
Object.factory is slow, error prone (linkage), and really unnecessary
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.