Re: Strange machine-level exception

new topic     » goto parent     » topic index » view thread      » older message » newer message

Bernie Ryan wrote:
> 
> Juergen Luethje wrote:
> > 
> > Hi all,
> > 
> > I've changed my private create_set() function a little, in order to take
> > advantage of find_from(). Then I encountered a strange machine-level
> > exception.
> > 
> > I've tested it on Windows XP Pro and Euphoria 3.1. The following code runs
> > fine when interpreted by EX.exe, EXW.exe and EXWC.exe. When I uncomment
> > the denoted line near the end, the program still runs fine with EX.exe but
> > crashes reliably with EXW.exe and EXWC.exe. Renaming "safe.e" to "machine.e"
> > and including it in the program didn't provide any hints.
> > }}}
<eucode>
> > function create_set (sequence s)
> >    -- create a set (= remove duplicate entries)
> >    integer p
> > 
> >    if length(s) < 2 then
> >       return s
> >    end if
> > 
> >    p = length(s)
> >    for i = length(s)-1 to 1 by -1 do
> >       if find_from(s[i], s, i+1) = 0 then  -- Machine-level exception here
> >       ...
> >          p -= 1
> >          s[p] = s[i]
> >       end if
> >    end for
> >    return s[p..$]
> > end function
> > 
> > 
> > sequence freq, result, unique
> > integer n, player
> > 
> > n = 1000
> > 
> > result = {}
> > for i = 1 to n do
> >    freq = repeat(0, 3)
> >    for card = 1 to 4 do
> >       player = rand(3)
> > --       freq[player] += 1                 -- ... after uncommenting this
> > line!
> >    end for
> >    result = append(result, freq)
> > end for
> > 
> > unique = create_set(result)
> > ? unique
> > if getc(0) then end if
> > </eucode>
{{{

> > Can someone please confirm the problem?
> > 
> > Regards,
> >    Juergen
> 
> Juergen:
>     Could the problem be caused by variations in the RAND() function ?
>     The rand() may be compiled different for each compiler or different
>     on each OS. The reason I say this is because the rand() occurs before
>     the line that is commented out.
> Bernie
> 
> My files in archive:
> WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 
> 
> Can be downloaded here:
> <a
> href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a>

I just made a few tests from office (WinXP Pro). Same problems.
The exception occurs at random iterations in create_set(), but always during the
call to find_from(). 1000 calls to rand() are made before create_set() is run,
and no exception occurs during that stage.
So, if it is not a find_from() Windows implementation bug, it means that the
implementation of rand() interferes with the one of find_from() under Windows.
Still a possibility, but less likely.
The exception occcurs after 1 to 6 calls to find_from(), irrespective of the
last result being 0, 1000, i+1 or anything else.

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu