-
-
Notifications
You must be signed in to change notification settings - Fork 611
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
Point users to Bugzilla on ICEs #8138
Conversation
Thanks for your pull request, @wilzbach! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#8138" |
Yeah, I think it would be helpful to output some more information. Compiler version would be good. I'm not sure what you mean by |
I think you should also consider that this code may be shared by LDC and GDC which use different bug trackers. It'd be nice to make is easy for them to adapt it to their workflows. |
I was thinking about something along this:
or:
The luckily don't use the same backend and the frontend check is directly in dmd's own
|
I think I'd prefer that format over the json. |
Is a stack trace going too far? |
Also, I suggest "This is a compiler bug, please report it via https://issues.dlang.org/enter_bug.cgi with, preferably, a reduced, reproducible example." or something like that to encourage the user to do a little more than just cut and paste the compiler output into the bug tracker. |
37f5ccc
to
7e74521
Compare
Okay here's how it will look with the new changes:
Assertion failures already have a stack trace right now (well, if assert's are enabled like in the release build) and they are very useful, so I don't think there's a reason not to show them. |
src/dmd/mars.d
Outdated
stream.fprintf("---\n"); | ||
stream.fprintf("ERROR: This is a compiler bug.\n" ~ | ||
"Please report it via https://issues.dlang.org/enter_bug.cgi\n" ~ | ||
"with, preferably, a reduced, reproducible example and the information below.\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe: "Include a a reduced, reproducible ..." ?
src/dmd/mars.d
Outdated
Params: | ||
stream = output stream to print the information on | ||
*/ | ||
extern(C) void internalFailureLogo(FILE* stream) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backend was printing to stdout
and I didn't want to change this behavior in this PR.
No, stack trace is fine - and infact ideally all bug reports should have the file/line info of the ICE as it makes it easy to find possibly related issues. |
src/dmd/mars.d
Outdated
stream.fprintf("ERROR: This is a compiler bug.\n" ~ | ||
"Please report it via https://issues.dlang.org/enter_bug.cgi\n" ~ | ||
"with, preferably, a reduced, reproducible example and the information below.\n"); | ||
stream.fprintf("DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction.\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time to make dustmite a dlang project? 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah 👍
FYI: it gets checked out as a "full source" to the tools repo already (https://github.com/dlang/tools/tree/master/DustMite), which is a bit useless as no one is developing on this copy.
CC @andralex
src/dmd/backend/util2.c
Outdated
@@ -38,6 +38,8 @@ void *ph_calloc(size_t nbytes); | |||
void ph_free(void *p); | |||
void *ph_realloc(void *p , size_t nbytes); | |||
|
|||
extern "C" void internalFailureLogo(FILE* stream); // from dmd/mars.d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Logo" or "Log"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DMD already had a function called "logo" that printed its version. Hence "Logo" as this is an extended version of it, but I really don't care about the name ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I understand why it was called logo, but this isn't that. Also, I suggest making methods begin with a verb, so my preference would be something like "printInternalFailure".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great idea, looking forward to it!
src/dmd/mars.d
Outdated
{ | ||
OutBuffer buf; | ||
foreach (const str; *global.versionids) | ||
{ | ||
buf.writeByte(' '); | ||
buf.writestring(str.toChars()); | ||
} | ||
message("predefs %s", buf.peekString()); | ||
stream.fprintf("predefs %.*s", buf.peekString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use %*s
for 0 terminated strings.
src/dmd/mars.d
Outdated
*/ | ||
extern(C) void internalFailureLogo(FILE* stream) | ||
{ | ||
stream.fprintf("---\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these strings have separate fprintf's, some are joined with ~. The latter is better. Also, for mere strings, use fputs.
} | ||
} | ||
|
||
if (flag.strchr(' ')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that be if (needsquoting)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but I just moved the code - check the red part on the left.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently it's not that easy (breaks a test), so I will modify this in a different PR.
src/dmd/mars.d
Outdated
foreach (flag; dflags.asDArray) | ||
{ | ||
bool needsQuoting; | ||
for (auto flagp = flag; flagp; flagp++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wat? Since when does incrementing a pointer until it is null work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For null terminated strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I just moved the code - check the red part on the left.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null terminated string
That's incrementing the pointer until what it points to is null. Not until the pointer itself is null!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
I understand, and normally I would let things slide for that reason. But this code is so clearly wrong I don't think we should defer fixing it.
src/dmd/mars.d
Outdated
getenv_setargv(readFromEnv(&environment, "DFLAGS"), &dflags); | ||
environment.reset(1); | ||
OutBuffer buf; | ||
foreach (flag; dflags.asDArray) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This asDArray
seems mighty peculiar, and is in fact not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively dereferencing can be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I just moved the code - check the red part on the left.
7761923
to
7a85853
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, and normally I would let things slide for that reason. But this code is so clearly wrong I don't think we should defer fixing it.
Fair enough. Changed the code.
src/dmd/mars.d
Outdated
bool needsQuoting; | ||
foreach (c; flag[0 .. strlen(flag)]) | ||
{ | ||
if (!(isalnum(c) || c == '_' || c == '-' || c == '/' || c == '.')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example:
DFLAGS -I/home/seb/dlang/dmd/generated/linux/release/64/../../../../../druntime/import -I/home/seb/dlang/dmd/generated/linux/release/64/../../../../../phobos -L-L/home/seb/dlang/dmd/generated/linux/release/64/../../../../../phobos/generated/linux/release/64 -L--export-dynamic -fPIC
(AFAICT no quoting needed)
foreach (flag; dflags[]) | ||
{ | ||
bool needsQuoting; | ||
foreach (c; flag[0 .. strlen(flag)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly readFrom
calls getenv
which returns a boring, old C-string.
@wilzbach Is this ready to go? Do you plan on adding anything else? |
AFAICT this is ready (at least I don't plan on adding sth. else). |
Revival of #6103.
While there's still a bit of hold-up on DIP1006 being implemente see e.g. #7980, we can already prepare the codebase today.
Also LDC already allows to selectively enable assert's in
-release
today.ICEs to test this:
Frontend
(from: https://issues.dlang.org/show_bug.cgi?id=18721)
Backend
(from: https://issues.dlang.org/show_bug.cgi?id=15206)
Other ideas:
How about dumping all
global
data too? (or just a long variant of--version
)?