[erlang-questions] werl R14A on windows 7 frequently crashes during file access

Brian Williams <>
Mon Jul 19 15:24:24 CEST 2010


On Sat, Jul 17, 2010 at 5:30 PM, Tuncer Ayaz <> wrote:
> On Thu, Jul 15, 2010 at 6:39 PM, Brian Williams wrote:
>> I'm not entirely sure what combination of running software is causing
>> this. I have a program that opens a list of log files (~100kb to
>> ~200kb), reads one a line at a time, matches the line against some
>> regexes, prints a report and finishes). Sometimes it works without a
>> problem. But other times werl will crash one or two lines into reading
>> the first log file, or when it opens up the report file. I have my
>> .erl, .beam and final report file in a Dropbox directory, which may be
>
> Hi Brian,
>
> I don't expect Dropbox to be the problem but have you tested on
> a Windows 7 install without Dropbox ever installed?
>

I have run a bunch of other examples and my own code right off beams
in drop box before. Just none that have done file i/o, but I can move
these files elsewhere and try that, too.


>> Win7 gives me a report like this when it crashes:
>> Problem signature:
>> Problem Event Name:   APPCRASH
>> Application Name:     werl.exe
>> Application Version:  0.0.0.0
>> Application Timestamp:        4c17b8f1
>> Fault Module Name:    beam.smp.dll
>> Fault Module Version: 0.0.0.0
>> Fault Module Timestamp:       4c17b83a
>> Exception Code:       c0000005
>> Exception Offset:     000cc562
>> OS Version:   6.1.7600.2.0.0.256.48
>> Locale ID:    1033
>> Additional Information 1:     0a9e
>> Additional Information 2:     0a9e372d3b4ad19135b953a78882e789
>> Additional Information 3:     0a9e
>> Additional Information 4:     0a9e372d3b4ad19135b953a78882e789
>
> If you have a Windows crash dump for that I would make a backup of
> the dump. Just in case...
>

Where would I look for this dump? Would I be able to make sense of it at all?

>>            {ok, WarningExp} = re:compile("warning", [caseless]),
>>            {ok, ErrorExp} = re:compile("error", [caseless]),
>>
>>            Compiled_Tests = [
>>                {warnings, warning_exps(), WarningExp},
>>                {errors, error_exps(), ErrorExp}],
>>            Report = scan_lines(Compiled_Tests, Dev, io:get_line(Dev, '')),
>
> What's the definition of scan_lines/3 (what does it do with
> the result of io:get_line/2 and with the compiled patterns)?
>

Here's the rest except for the report printing, which is pretty simple.

% starts an empty report for accumulation
scan_lines(Compiled_Tests, Dev, Line) ->
    scan_lines(Compiled_Tests, Dev, Line,
        [{warnings, []}, {errors, []}]).
% reached end of file, return report
scan_lines(_Compiled_Tests, _Dev, eof, Report) -> Report;
scan_lines(Compiled_Tests, Dev, Line, Report) ->
    % match line and update report
    % io:format("Attempting to match line: ~s~n", [Line]),
    UpdatedReport = update_report(Compiled_Tests, Line, Report),
    % get next line and recurse
    scan_lines(Compiled_Tests, Dev, io:get_line(Dev, ''), UpdatedReport).

%% Takes a line, scans for errors and warnings and updates the report
update_report([], _Line, Report) -> Report;
update_report([{Group, Tests, GroupMatch} | Compiled_Tests], Line, Report) ->
    case re:run(Line, GroupMatch) of
            {match, _Captured} ->
                % io:format("Matched ~p, checking for specific ~p
errors~n", [Group, Group]),
                check_test(Line, Group, Tests, Report);
            nomatch -> update_report(Compiled_Tests, Line, Report)
    end.

check_test(Line, Group, [], Report) ->
    io:format("Unmatched ~p for line: ~s", [Group, Line]),
    increment_report(Report, {Group, unknown, "Non-matched line"});
check_test(Line, Group, [{TestName, Exp, Test} | RestTests], Report) ->
    case re:run(Line, Exp) of
        {match, _TestCapture} ->
            % return new report, don't recurse
            % io:format("Matched a test, incrementing: ~p~n", [TestName]),
            increment_report(Report, {Group, TestName, Test});
        nomatch ->
            % try the next test
            check_test(Line, Group, RestTests, Report)
    end.

increment_report(Report, {Group, TestName, Test}) ->
    % get the group of counts in the report that we're working with
    {Group, Counts} = lists:keyfind(Group, 1, Report),
    % io:format("Got counts: ~p for test group: ~p~n", [Counts, Group]),
    case lists:keyfind(TestName, 1, Counts) of
        % if that test is already in the report, increment
        {TestName, CurrentCount, _MatchTest} ->
            % io:format("Replacing count with ~p~n", [{TestName,
CurrentCount +1}]),
            lists:keyreplace(Group, 1, Report, {Group,
                lists:keyreplace(TestName, 1, Counts, {TestName,
CurrentCount + 1, Test})});
        % else, add it in with initial count of 1
        false ->
            % io:format("Couldn't find test ~p in report, adding a new
one~n", [TestName]),
            lists:keyreplace(Group, 1, Report, {Group, [{TestName, 1,
Test} | Counts]})
    end.


-- 
Brian E. Williams

http://www.techhouse.us/wordpress-mu/brianw

"Never attribute to malice that which can be adequately
explained by stupidity." - Hanlon's Razor


More information about the erlang-questions mailing list