segfaults

Steven Schveighoffer schveiguy at yahoo.com
Mon May 3 14:49:52 PDT 2010


On Mon, 03 May 2010 17:25:30 -0400, Bernard Helyer <b.helyer at gmail.com>  
wrote:

> On 04/05/10 08:57, Lars T. Kyllingstad wrote:
>> On Mon, 03 May 2010 15:54:28 -0500, Ellery Newcomer wrote:
>>
>>> Hello.
>>>
>>> I'm trying to invoke a command inside d, and it returns a success code
>>> when the command in question segfaults.
>>>
>>> any ideas?
>>>
>>> // the caller
>>> import std.process;
>>>
>>> int main(){
>>>       auto r = system("./test");
>>>       return(r);
>>> }
>>>
>>>
>>> //test.d
>>> import std.stdio;
>>>
>>> void main()
>>> {
>>>       Object o;
>>>       writeln(o.toString());
>>> }
>>
>> It's a null dereference.  What you're doing is essentially
>>
>>    Object o = null;
>>    writeln(o.toString());
>>
>> -Lars
>
>
> I believe his problem is that the return code of the caller indicates  
> success.

Could it be perhaps that it can't possibly get at that status?  Remember,  
system runs /bin/sh -c, so all you can get as status is the return code of  
/bin/sh (which didn't segfault).

-Steve


More information about the Digitalmars-d-learn mailing list