www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9134] New: failed assert leads to Segmentation fault when iterating file lines

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

           Summary: failed assert leads to Segmentation fault when
                    iterating file lines
           Product: D
           Version: unspecified
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: atankeev gmail.com


--- Comment #0 from Alexander Tankeev <atankeev gmail.com> 2012-12-10 01:59:35
PST ---
---{ cut: testcase.d }---
import std.stdio;
void main()
{
    auto file = File("testcase.d","r");
    foreach (ulong i, string line; lines(file))
        assert(true == false);
        // Segmentation fault (core dumped)
    file.close();
}
---------{ EOF }---------

# rdmd testcase.d
Segmentation fault (core dumped)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 10 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9134


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru


--- Comment #1 from Maxim Fomin <maxim maxim-fomin.ru> 2012-12-10 07:21:12 PST
---
Note: if it is compiled with -g, an AssertError is thrown.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9134


Maxime Chevalier-Boisvert <maximechevalierb gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maximechevalierb gmail.com


--- Comment #2 from Maxime Chevalier-Boisvert <maximechevalierb gmail.com>
2013-03-01 08:25:40 PST ---
I ran into this bug as well. Adding the -g compiler option does not fix the
problem for me.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9134



--- Comment #3 from Maxime Chevalier-Boisvert <maximechevalierb gmail.com>
2013-03-01 08:40:55 PST ---
I have a hunch that this might be because the function with the assert is
called from a function with the extern (C) calling convention. Possibly, DMD
tries to unwind the stack and fails when it gets to the function with the C
calling convention...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9134



--- Comment #4 from Maxim Fomin <maxim maxim-fomin.ru> 2013-03-01 09:18:23 PST
---
I cannot it reproduce with g(In reply to comment #2)
 I ran into this bug as well. Adding the -g compiler option does not fix the
 problem for me.

Which environment do you use? I cannot reproduce it now with 2.062 on windows and linux git head. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9134



--- Comment #5 from Maxime Chevalier-Boisvert <maximechevalierb gmail.com>
2013-03-01 11:35:53 PST ---
(In reply to comment #4)
 I cannot it reproduce with g(In reply to comment #2)
 I ran into this bug as well. Adding the -g compiler option does not fix the
 problem for me.

Which environment do you use? I cannot reproduce it now with 2.062 on windows and linux git head.

DMD64 D Compiler v2.062 on Ubuntu 64 bit. assert (false); causes a segmentation fault. I believe the problem might be that this assert is in a function that is indirectly called by a function with the extern (C) calling convention. The problem is further complicated because I call this function from x86 assembler code I wrote myself. I'm guessing the stack unwinding mechanism has a heart attack when it gets to that point in the stack. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9134



--- Comment #6 from Maxim Fomin <maxim maxim-fomin.ru> 2013-03-01 11:45:18 PST
---
(In reply to comment #5)
 (In reply to comment #4)
 I cannot it reproduce with g(In reply to comment #2)
 I ran into this bug as well. Adding the -g compiler option does not fix the
 problem for me.

Which environment do you use? I cannot reproduce it now with 2.062 on windows and linux git head.

DMD64 D Compiler v2.062 on Ubuntu 64 bit. assert (false); causes a segmentation fault. I believe the problem might be that this assert is in a function that is indirectly called by a function with the extern (C) calling convention. The problem is further complicated because I call this function from x86 assembler code I wrote myself. I'm guessing the stack unwinding mechanism has a heart attack when it gets to that point in the stack.

OK. I can successfully run following code (with assertion failure, of course): import std.stdio; void main() { auto file = File("testcase.d","r"); foreach (ulong i, string line; lines(file)) assert(false); // Segmentation fault (core dumped) file.close(); } without any switches using githead. The fact that you are facing bug my be because it is already fixed in head. Can you test master branch? If there are no objections, I will close issue as WORKSFORME. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9134



--- Comment #7 from Alexander Tankeev <atankeev gmail.com> 2013-03-01 11:53:16
PST ---
In 2.062 it can be reproduced if you compile this code with -release flag.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9134



--- Comment #8 from Maxim Fomin <maxim maxim-fomin.ru> 2013-03-01 11:59:50 PST
---
(In reply to comment #7)
 In 2.062 it can be reproduced if you compile this code with -release flag.

It can be reproduced in any version with -release flag since assertion on constant CT zero expression results in halt instruction. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9134



--- Comment #9 from Alexander Tankeev <atankeev gmail.com> 2013-03-01 12:13:45
PST ---
It crashes only with Ubuntu Linux 12.10, dmd64. Under win32 it works fine.
Interesting that even such code crashes with dmd64 2.062/linux and -release
flag:
void main() { assert(false); }

 It can be reproduced in any version with -release flag since assertion on

No. In win32 I have just an exception and in linux I have segmentation fault. Should I explain why is it unacceptable behavior? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9134



--- Comment #10 from Alexander Tankeev <atankeev gmail.com> 2013-03-01 12:27:58
PST ---
You're right
http://forum.dlang.org/thread/bug-5517-3 http.d.puremagic.com/issues/

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9134


Alexander Tankeev <atankeev gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #11 from Alexander Tankeev <atankeev gmail.com> 2013-03-01 12:31:47
PST ---
*** This issue has been marked as a duplicate of issue 5517 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2013