Bug 9271 – Forwarding lambda predicate with type inference causes segfault

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-05T03:43:00Z
Last change time
2013-11-25T14:59:39Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
doob

Comments

Comment #0 by doob — 2013-01-05T03:43:55Z
The following code results in a segmentation fault. It seems that "any" is called indefinitely. If I don't use type inference for the lambda everything works as it should. import algorithm = std.algorithm; bool any (alias predicate, Range) (Range range) { return algorithm.any!(predicate)(range); } void main () { auto arr = ["foo"]; any!(e => e == "asd")(arr); // segfault // any!((string e) => e == "asd")(arr); // works }
Comment #1 by maxim — 2013-01-05T06:44:34Z
This works on linux with git head.
Comment #2 by maxim — 2013-01-05T07:02:49Z
However it segfaults on windows using 2.061.
Comment #3 by doob — 2013-01-05T07:03:46Z
Does not work on Mac OS X 32bit. DMD hash d6f0ef93dbd4d88be7a69f85303f6230a02d58a9 This is the stack trace from GDB: (gdb) r Starting program: /Users/doob/development/d/dlang/dmd/src/main Reading symbols for shared libraries +......................... done Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0xbf7ffff4 0x0000181d in D4main4mainFZv30__T3anyS14main9__lambda2TAAyaZ3anyMFAAyaZb () (gdb) bt #0 0x0000181d in D4main4mainFZv30__T3anyS14main9__lambda2TAAyaZ3anyMFAAyaZb () #1 0x00001828 in D4main4mainFZv30__T3anyS14main9__lambda2TAAyaZ3anyMFAAyaZb () #2 0x00001828 in D4main4mainFZv30__T3anyS14main9__lambda2TAAyaZ3anyMFAAyaZb () #3 0x00001828 in D4main4mainFZv30__T3anyS14main9__lambda2TAAyaZ3anyMFAAyaZb () Repeated like the above.
Comment #4 by k.hara.pg — 2013-11-24T22:05:31Z
Comment #5 by github-bugzilla — 2013-11-25T13:57:19Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/e526b5782d8bdc9c71bd44bd4cf95f73e6cf0b3e fix Issue 9271 - Forwarding lambda predicate with type inference causes segfault https://github.com/D-Programming-Language/dmd/commit/7d23f86e09666863969721abb35eb0d54b31df5c Merge pull request #2877 from 9rnsr/fix9271 Issue 9271 - Forwarding lambda predicate with type inference causes segfault