DMD Patches for three severe wrong-code bugs#1
Conversation
1914 Array initialisation from const array yields memory trample 3198 wrong initializer for structs arrays There was an old incorrect D2-only fix for 1914 (the old fix didn't fix all-zero array initializers). This is replaced with a general solution. 3198 is also fixed, by removing an incorrect special case for arrays.
|
Regarding "is this the best way". If you have push access to the official dmd repo (which it looks like you do), then this isn't the best way. Although it does allow us to see only your commits to dmd pretty easily, it requires more work by someone in the official repo (which might be you!) to pull in your repo and merge it in. You're better off cloning the official repo and creating a branch. Then commit your individual changes to that branch. You can then push your local branch to a remote branch here on the official dmd repo. Walter can review the changes and merge them in (or ask you to merge them in). You get the same effect (committing without messing with master), but less work on pulling in your forked repo. |
|
Push access != push permission. Walter pretty much owns all commits, so pull requests are probably exactly right. |
(patch by Johannes Pfau)
|
I'm a bit surprised that after I made this pull request, my subsequent commits got added to it. |
Patch by ibuclaw
D2 version. The basic bug causes a segfault. The special treatment with the 'getVarExp' is needed to avoid a stack overflow; this also happens in D1 (the segfault is D2-specific).
Note that we're using HTML4. When we change to HTML5, this test needs to change to the commented-out version.
Patch by ibuclaw and aziz.koeksal
When a recursive alias declaration is encountered, mark it as type error (not just as an alias to itself of type error).
…n't compile Introduced on 5th Dec, in the fix for bug 5110. From the comments for 5110: "the patch limits STC propagation via Scope's storage class (sc->stc) only to @safe/@trusted/@System. Other STCs such as const and synchronized are 'pulled' by need of each member out of parent AggregateDeclaration." This regression happened because when deducing a function template, these STCs haven't been pulled from the parent yet. Applying the STCs doesn't happen until FuncDeclaration::semantic. This isn't early enough for function template matching. So we need to complete the storage class of 'this' during matching. It applies to const, immutable, synchronized, and shared classes.
Added here because it was broken by the patch for the test included immediately above it. Doesn't need to run (it fails to compile on 2.051).
Patch by rsinfu
I've put this next to the tests for the two closely related bugs.
Patch type-checked-arrays to compile for win32/dmc.
Fix building for 32mscoff with MARS.
fixed visual studio build to generate VERSION instead of verstr.h
I guess the recent removal of module constructors in druntime has brought these to light, for a little LDC ASan smoke test, which newly complains with D v2.105, e.g.: > Direct leak of 78624 byte(s) in 126 object(s) allocated from: > #0 0x55606978c40d in malloc /local/mnt/workspace/tmp/final/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3 > dlang#1 0x5560698050b1 in _D2rt5minfo11ModuleGroup9sortCtorsMFNbAyaZv
I guess the recent removal of module constructors in druntime has brought these to light, for a little LDC ASan smoke test, which newly complains with D v2.105, e.g.: > Direct leak of 78624 byte(s) in 126 object(s) allocated from: > #0 0x55606978c40d in malloc /local/mnt/workspace/tmp/final/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3 > #1 0x5560698050b1 in _D2rt5minfo11ModuleGroup9sortCtorsMFNbAyaZv
Limit the number of platforms that this is done on. A inspection of some libc implementations of fork has identified the main culprits, don't need to apply this to any others. MacOS testsuite also regressed as a result on calling this code, it's not clear why, but the backtrace is: ``` * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) * frame #0: 0x00007ff81abe6ee3 libsystem_platform.dylib`_os_unfair_lock_recursive_abort + 23 frame #1: 0x00007ff81abe12da libsystem_platform.dylib`_os_unfair_lock_lock_slow + 247 frame #2: 0x00007ff81abccd44 libsystem_pthread.dylib`_pthread_atfork_prepare_handlers + 48 frame #3: 0x00007ff825dc2705 libSystem.B.dylib`libSystem_atfork_prepare + 25 frame #4: 0x00007ff81aac17e1 libsystem_c.dylib`fork + 24 frame #5: 0x0000000101f730ee test_runner`core.internal.backtrace.dwarf.resolveAddressesWithAtos(Location[]) + 210 ```
I have created my own DMD repository in git@github:donc/dmd.git (so that I don't interfere with the official one). I don't know if this is the best way of doing this.
Three of the oldest and most severe wrong-code bugs:
1899 AA of fixed-length arrays fails to initialize
1914 Array initialisation from const array yields memory trample
3198 wrong initializer for structs arrays
I haven't merged the patches into the D1 branch, but I have added the tests to the test suite.
Let's see how well this works!