www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3119] New: Segfault combining std.c.linux and passing a ref string

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3119

           Summary: Segfault combining std.c.linux and passing a ref
                    string
           Product: D
           Version: 2.030
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: Jesse.K.Phillips+D gmail.com


In the code below the compiler will "Segmentation fault." getopt takes a
string[], but is being given just a string. With the included import to
std.c.linux.linux DMD will end with a segfault rather than the appropriate
error message. Removing the import works as expected.

import std.c.linux.linux;
import std.getopt;

string arg1;

void main(string[] args) {

}

void parseArgs(ref string args) {
    getopt(args, "f|file", &arg1);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3119


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |clugdbug yahoo.com.au


--- Comment #1 from Don <clugdbug yahoo.com.au> 2009-10-08 05:09:51 PDT ---
Can someone please (1) check that this fails; and
(2) reduce the test case?

Need to work out which part of std.c.linux.linux is triggering it. Probably
isn't Linux specific, unless it's crashing in the code generation step.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 08 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3119


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|x86_64                      |All
            Summary|Segfault combining          |Segfault(expression.c)
                   |std.c.linux and passing a   |template function overloads
                   |ref string                  |with function with same
                   |                            |name in other module
         OS/Version|Linux                       |All
           Severity|minor                       |normal


--- Comment #2 from Don <clugdbug yahoo.com.au> 2009-10-09 05:23:42 PDT ---
Reduced test case. Applies on any OS (not Linux specific), but D2 only since it 
involves overload sets.
Import order is important! If order of imports is swapped, generates "Error: 
expected 1 function arguments, not 0".
Segfaulting in CallExp::semantic(). e1->type is garbage. (not NULL, garbage!)

----
import bugB;
import bugC;

void main() {  foo(); }
----
     bugB.d:
----
void foo(int) {} 
---
    bugC.d:
---
void foo(T)(){}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 09 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3119


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #3 from Don <clugdbug yahoo.com.au> 2009-10-09 07:36:36 PDT ---
ANALYSIS:
expression.c, line 6693:

    if (!f)
    {   /* No overload matches, just set f and rely on error
         * message being generated later.
         */
        f = (FuncDeclaration *)eo->vars->a.data[0];
    }

This is wrong because it's not necessarily a FuncDeclaration, it could be a
TemplateDeclaration instead. I think an error message needs to be generated
immediately.

Change this to something like:

    if (!f)
    {   /* No overload matches, just set f and rely on error
         * message being generated later.
         */
        error("no overload matches %s", savedFuncName);
        return this;
    }

after having added to line 6320 something like:

    istemp = 0;
Lagain:
+    char *savedFuncName = toChars();
    //printf("Lagain: %s\n", toChars());
    f = NULL;
    if (e1->op == TOKthis || e1->op == TOKsuper)
    {
    // semantic() run later for these
    }
    else
    {
    UnaExp::semantic(sc);

since the UnaExp::semantic() call turns the name into __overloadset which makes
yucky error messages.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 09 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3119


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2009-10-13
13:52:17 PDT ---
Fixed dmd 2.034

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 13 2009