Fix issue 16291 -- phobosinit fails to register encodings on individual tests#4744
Fix issue 16291 -- phobosinit fails to register encodings on individual tests#4744schveiguy wants to merge 2 commits intodlang:masterfrom
Conversation
|
|
@schveiguy, thanks for your PR! By analyzing the annotation information on this pull request, we identified @JackStouffer, @kyllingstad and @andralex to be potential reviewers. @JackStouffer: The PR was automatically assigned to you, please reassign it if you were identified mistakenly. |
std/encoding.d
Outdated
| // cycles. | ||
| extern(C) void std_encoding_shared_static_this() | ||
| { | ||
| foreach(scheme; [ |
There was a problem hiding this comment.
I think it does. Is it important for it not to? I'll fix it back to a slew of calls. Would be nice to have a way to make an array at compile-time mid-expression for things like this.
|
Awesome. I've uncovered some sort of dmd heisenbug that works just fine on my system. @WalterBright how do I debug that signal 11 from here? |
std.encoding and std.process.
Current coverage is 88.78% (diff: 100%)@@ master #4744 diff @@
==========================================
Files 121 121
Lines 74159 74152 -7
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 65845 65838 -7
Misses 8314 8314
Partials 0 0
|
|
I misread the call, I thought it was the build, but it's actually the checkwhitespace.d program. I can reproduce the crash locally. |
|
Auto-merge toggled on |
|
Whatever it is, I trust you'll get to the bottom of it. |
|
HAHA I think somehow the linker/compiler is trimming out all the data in this file. If I insert this line, then it works: auto ascii = new EncodingSchemeASCII;That has to be a bug... I'm going to just put in the line above, to get this done. This whole file needs a rewrite anyway. |
|
@schveiguy, thanks for your PR! By analyzing the annotation information on this pull request, we identified @JackStouffer, @complexmath and @kyllingstad to be potential reviewers. @JackStouffer: The PR was automatically assigned to you, please reassign it if you were identified mistakenly. |
|
Auto-merge toggled off |
|
Something is really really wrong on OSX for this fix... |
|
OK, I guess the failure is from the exe size growing too much. WTF... |
|
I'm like 90% convinced that nobody uses |
|
Dear christ, this is such a dirty hack. I would really rather not have code like this in Phobos; if I wasn't following the development of this, maintaining this would royally suck. Maybe I'm overreacting, but if we can't get normal |
|
@JackStouffer this is an old old module. At this point, changing it to be better designed is kind of a lost cause. The hack for cycles is fine for now. That's not the issue with this PR. Until we can somehow mark a static ctor as being manually-verified as standalone, it's impossible to deal with the issue without doing something like this -- the runtime has to run static ctors in the right order, and the only way to do this is sort them at startup. The compiler doesn't give enough info to do a complete perfect dependency sort, so we are stuck with module-level sorting. When there are module cycles, you have to refactor like this. The issue with this PR is that on OSX (at least), the module info isn't properly being stored and/or read. I'm setting up a bug report right now. |
|
Bug report: https://issues.dlang.org/show_bug.cgi?id=16423 |
|
This won't fully solve the problem (and all the trouble for some stupid false cycle detection). With the current situation std.net.curl becomes unusable (b/c it instantiates whatever Transfer-Encoding it sees). Please add a new |
Wrong, anyone importing |
| { | ||
| version (OSX) | ||
| { | ||
| import std.internal.phobosinit; // needed to make sure the function gets called |
There was a problem hiding this comment.
Please don't reference the encoding scheme init from std.process, merging all constructors in phobosinit is a really bad idea.
There was a problem hiding this comment.
Yes, I think that's why default hello world goes up in space so much. Ugly as it is, we need an individual internal module for each module that has cycles.
There was a problem hiding this comment.
I think this relates to https://issues.dlang.org/show_bug.cgi?id=16580 as well.
Why is that? I think moduleInfo should be present if classinfo is used (at the very least). Otherwise, runtime reflection initialization doesn't work (Object.factory). I agree that std.encoding should use compile-time reflection for initialization. |
We're running in circles dlang/dmd#6076 (comment), |
|
Fixed in #4840 |
std.encoding and std.process depend on an extern(C) binding to call their standalone static ctors. Doing it this way avoids cycles in the modules for unit tests.
However, my previous scheme of having std.internal.phobosinit import std.encoding allows the linker to simply discard that entire module since nothing depends on or calls it. It must be imported the other way, and must not import anything (to avoid cycles). I also had removed the import from std.process thinking it was unnecessary (incorrectly).