September 06, 2013 [Issue 10970] Segfault in a simple test compiled without -g. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zhouxuan | http://d.puremagic.com/issues/show_bug.cgi?id=10970 --- Comment #10 from hsteoh@quickfur.ath.cx 2013-09-06 16:56:43 PDT --- (In reply to comment #6) [...] > In just this little snippet, there are *all* kinds of wrong: > 1. insertion: when inserting a new item, CC ("this(this)") is never called for > some strange reason. Furthermore, destruction happens *twice* (again, for some > strange reason). > 2. removal: Where's the destructor? [...] Ugh. I looked at the code, and it's just one big ugly mess. For starters, _aaGetX, which implements "aa[key] = value", takes only a *size* parameter to the value to be stored. If the Slot for that key doesn't already exist, it creates one for it, and then proceeds to memset the value part of the Slot to binary zero. So already, we have a problem: now there's a Slot for which the value isn't properly initialized (e.g., if the value type has a non-trivial ctor that sets things up). Next, when you call remove(), it ultimately goes to _aaDelX, which calls GC.free on the Slot, which, according to the docs, explicitly does NOT finalize the block. So, the key and value originally in that slot, if they have dtors, won't have their dtors called. To top things off, I added writeln's before and after inserting the element into the AA, and discovered that the ctor call and BOTH of the dtor calls happen *during insertion into the AA*. So it looks like after _aaGetX created an invalid instance of S (bypassing the ctor), the compiler is attempting to perform an assignment to it from a temporary copy of S it created from the RHS of the statement. Since the compiler believes (wrongly) that the AA Slot already contains a value of type S, it calls S's dtor in order to delete the old value, then copies the new value into it. Afterwards, it destructs the temporary copy of S (so this accounts for the 1 ctor call and 2 dtor calls). But here, the mess is topped off with yet another bug: the postblit isn't being called after this assignment!! Ugh! This code is an embarrassment!! Makes me want to fork dmd, rip out every last bit of the existing AA implementation, and redo it from scratch. It'll probably be easier than trying to sort out this rabbit warren of AA bugs. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 07, 2013 [Issue 10970] Segfault in a simple test compiled without -g. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zhouxuan | http://d.puremagic.com/issues/show_bug.cgi?id=10970 --- Comment #12 from hsteoh@quickfur.ath.cx 2013-09-06 17:10:14 PDT --- Only 50? I have 78 on my list, and that's not including bugs that don't say AA or hash in the subject line, like this one. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 07, 2013 [Issue 10970] Segfault in a simple test compiled without -g. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zhouxuan | http://d.puremagic.com/issues/show_bug.cgi?id=10970 --- Comment #13 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-09-06 17:10:41 PDT --- (In reply to comment #10) > Ugh! This code is an embarrassment!! Makes me want to fork dmd, rip out every last bit of the existing AA implementation, and redo it from scratch. It'll probably be easier than trying to sort out this rabbit warren of AA bugs. If you do that, we will build a statue in your honor in Menlo Park. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 07, 2013 [Issue 10970] Segfault in a simple test compiled without -g. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zhouxuan | http://d.puremagic.com/issues/show_bug.cgi?id=10970 --- Comment #14 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-09-06 17:11:24 PDT --- (In reply to comment #12) > Only 50? I have 78 on my list, and that's not including bugs that don't say AA or hash in the subject line, like this one. My bugzilla query string must be inadequate, what's yours? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 07, 2013 [Issue 10970] Segfault in a simple test compiled without -g. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zhouxuan | http://d.puremagic.com/issues/show_bug.cgi?id=10970 --- Comment #15 from hsteoh@quickfur.ath.cx 2013-09-06 17:13:32 PDT --- http://d.puremagic.com/issues/buglist.cgi?query_format=advanced&short_desc=aa%20associative%20hash&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&short_desc_type=anywordssubstr&version=D1%20%26%20D2&version=D2&known_name=aa&query_based_on=aa -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 22, 2013 [Issue 10970] Segfault in a simple test compiled without -g. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zhouxuan | http://d.puremagic.com/issues/show_bug.cgi?id=10970 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull, wrong-code Platform|x86_64 |All OS/Version|Windows |All --- Comment #16 from Kenji Hara <k.hara.pg@gmail.com> 2013-09-21 22:55:10 PDT --- The root cause is a dup of bug 6178. https://github.com/D-Programming-Language/dmd/pull/2539 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 22, 2013 [Issue 10970] Segfault in a simple test compiled without -g. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zhouxuan | http://d.puremagic.com/issues/show_bug.cgi?id=10970 --- Comment #17 from github-bugzilla@puremagic.com 2013-09-22 13:04:32 PDT --- Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/36a44cbcea9fbb18b221f77e00f2dca77f21bc88 fix Issue 10970 - Segfault in a simple test compiled without -g. Fixes `CondExp::toElem` to avoid "Internal error: backend\cgcs.c 351" -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 23, 2013 [Issue 10970] Segfault in a simple test compiled without -g. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zhouxuan | http://d.puremagic.com/issues/show_bug.cgi?id=10970 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation