1. problem with euc on Win10 64bit

I'm using

Euphoria to C Translator v4.1.0 development 
   64-bit Windows, Using System Memory 
   Revision Date: 2015-02-02 14:18:53, Id: 6300:57179171dbed 
and I've just compiled the following .ex file to .exe

include std/math.e  
include std/convert.e 
 
function Bin(integer n, sequence s = "") 
  if n > 0 then 
   return Bin(floor(n/2),(mod(n,2) + #30) & s) 
  end if 
  if length(s) = 0 then 
   return to_integer("0") 
  end if 
  return to_integer(s) 
end function 
 
printf(1, "%d\n", Bin(0)) 
printf(1, "%d\n", Bin(5)) 
printf(1, "%d\n", Bin(50)) 
printf(1, "%d\n", Bin(9000)) 

When I run that with eui.exe I get

>eui bin.ex 
0 
101 
110010 
10001100101000 
but when I run the exe, I get
>bin.exe 
0 
0 
0 
0 
As Julius Sumner Miller used to say, "Why is it so?"

bugmagnet

new topic     » topic index » view message » categorize

2. Re: problem with euc on Win10 64bit

bugmagnet said...
include std/math.e   
include std/convert.e  
  
function Bin(integer n, sequence s = "")  
  if n > 0 then  
   return Bin(floor(n/2),(mod(n,2) + #30) & s)  
  end if  
  if length(s) = 0 then  
   return to_integer("0")  
  end if  
  return to_integer(s)  
end function  
  
printf(1, "%d\n", Bin(0))  
printf(1, "%d\n", Bin(5))  
printf(1, "%d\n", Bin(50))  
printf(1, "%d\n", Bin(9000))  

[ronald@localhost myeuphoria]$ eui --version 
Euphoria Interpreter v4.1.0 development 
   64-bit Linux, Using System Memory 
   Revision Date: 2015-08-27 10:36:54, Id: 6340:e912a32d9ad5 
[ronald@localhost myeuphoria]$ eui bintest.ex  
0 
101 
110010 
10001100101000 
[ronald@localhost myeuphoria]$ euc bintest.ex  
Build directory: build-796719/ 
Translating code, pass: 1 2 3 4 5 6 7 8 9 10 11  generating 
Compiling with GCC 
Compiling   3% init-.c 
Compiling  11% bintest.c 
Compiling  16% main-.c 
Compiling  22% math.c 
Compiling  27% types.c 
Compiling  32% convert.c 
Compiling  38% search.c 
Compiling  43% filesys.c 
Compiling  49% datetime.c 
Compiling  54% dll.c 
Compiling  59% machine.c 
Compiling  65% memory.c 
Compiling  70% get.c 
Compiling  76% scinot.c 
Compiling  81% fenv.c 
Compiling  86% utils.c 
Compiling  92% sequence.c 
Compiling  97% sort.c 
Linking 100% ../bintest 
[ronald@localhost myeuphoria]$ ./bintest  
0 
0 
0 
0 
[ronald@localhost myeuphoria]$  

new topic     » goto parent     » topic index » view message » categorize

3. Re: problem with euc on Win10 64bit AND Mint 32bit

It gets worse. I am modifying the subject. I am also changing a little bit your test. I can still reproduce the problem with these changes. Look at what happens on 32-bit Linux:

t_bugmagnet_15.e:

include std/math.e   
include std/convert.e  
 
function Bin(integer n, sequence s = "")  
  if n > 0 then  
   return Bin(floor(n/2),(mod(n,2) + #30) & s)  
  end if  
  if length(s) = 0 then  
   return to_integer("0")  
  end if  
  return to_integer(s)  
end function  
 
include std/unittest.e 
 
test_equal("Bin(0) = '0'", "0", sprintf("%d", Bin(0))) 
test_equal("Bin(5) = '5'", "101", sprintf("%d", Bin(5))) 
test_equal("Bin(50) = '110010'", "110010", sprintf("%d", Bin(50))) 
test_equal("Bin(9000) = '10001100101000'", "10001100101000", sprintf("%d", Bin(9000))) 
 
test_report() 

eutest -euc ../source/build/euc -eui ../source/build/eui -lib ../source/build/eu.a t_bugmagnet_15.e 
output:
interpreting t_bugmagnet_15.e: 
 
translating t_bugmagnet_15.e:  failed: Bin(5) = '5', expected: "101" but got: "0" 
  failed: Bin(50) = '110010', expected: "110010" but got: "0" 
  failed: Bin(9000) = '10001100101000', expected: "10001100101000" but got: "0" 
  4 tests run, 1 passed, 3 failed, 25% success 
FAILURE: t_bugmagnet_15 program died with status 256 
 
Test results summary: 
    FAIL: translated t_bugmagnet_15-translated 
Files (run: 2) (failed: 1) (50% success) 
 
 

new topic     » goto parent     » topic index » view message » categorize

4. Re: problem with euc on Win10 64bit AND Mint 32bit

Same machine as before (Mint/32bit) but with Euphoria 4.0 (development tip):

eutest -euc ../source/build/euc -eui ../source/build/eui -lib ../source/build/eu.a t_bugmagnet_15.e  
 
interpreting t_bugmagnet_15.e: 
 
translating t_bugmagnet_15.e: 
 
Test results summary: 
Files (run: 2) (failed: 0) (100% success) 

new topic     » goto parent     » topic index » view message » categorize

5. Re: problem with euc on Win10 64bit AND Mint 32bit

Raspberry Pi too.

pi@raspberrypi ~/dev/myeuphoria $ eui --version 
Euphoria Interpreter v4.1.0 development 
   32-bit Linux, Using System Memory 
   Revision Date: 2015-09-29 19:26:24, Id: 6380:1110bd29c7d4 
pi@raspberrypi ~/dev/myeuphoria $ eui bintest.ex  
0 
101 
110010 
10001100101000 
pi@raspberrypi ~/dev/myeuphoria $ euc bintest.ex  
Build directory: build-441383/ 
Translating code, pass: 1 2 3 4 5 6 7 8 9 10 11  generating 
Compiling with GCC 
Compiling   3% init-.c 
Compiling  11% bintest.c 
Compiling  16% main-.c 
Compiling  22% math.c 
Compiling  27% types.c 
Compiling  32% convert.c 
Compiling  38% search.c 
Compiling  43% filesys.c 
Compiling  49% datetime.c 
Compiling  54% dll.c 
Compiling  59% machine.c 
Compiling  65% memory.c 
Compiling  70% get.c 
Compiling  76% scinot.c 
Compiling  81% fenv.c 
Compiling  86% utils.c 
Compiling  92% sequence.c 
Compiling  97% sort.c 
Linking 100% ../bintest 
pi@raspberrypi ~/dev/myeuphoria $ ./bintest  
0 
0 
0 
0 

new topic     » goto parent     » topic index » view message » categorize

6. Re: problem with euc on Win10 64bit AND Mint 32bit

In the case of n=5, we have a temporary getting the value of NOVALUE returned from a function:

(gdb) continue 
Continuing. 
 
Breakpoint 1, _1Bin (_n_11027=_n_11027@entry=5, _s_11028=-2130608542) at t_bugmagnet_15a.c:6 
6	{ 
(gdb) n 
49	        Concat((object_ptr)&_6222, _6221, _s_11028); 
(gdb)  
6	{ 
(gdb)  
10	    object _6222 = NOVALUE; 
(gdb)  
17	    if (!IS_ATOM_INT(_n_11027)) { 
(gdb)  
24	    if (_n_11027 <= 0) 
(gdb)  
29	    _6220 = _2mod(_n_11027, 2); 
(gdb) p _6220 
$14 = -1073741825 
(gdb) n 
28	    _6219 = _n_11027 >> 1; 
(gdb)  
29	    _6220 = _2mod(_n_11027, 2); 
(gdb) p _6220 
$15 = -1073741825 

Yet if you step into this function gdb reports it returns an integer value

(gdb) s 
28	    _6219 = _n_11027 >> 1; 
(gdb)  
29	    _6220 = _2mod(_n_11027, 2); 
(gdb)  
_2mod (_x_477=5, _y_478=_y_478@entry=2) at math.c:241 
241	{ 
(gdb) n 
264	    _sign_1__tmp_at19_486 = (_y_478 > 0); 
(gdb)  
265	    _sign_2__tmp_at19_487 = (_y_478 < 0); 
(gdb)  
264	    _sign_1__tmp_at19_486 = (_y_478 > 0); 
(gdb)  
260	    _sign_2__tmp_at2_483 = (_x_477 < 0); 
(gdb)  
259	    _sign_1__tmp_at2_482 = (_x_477 > 0); 
(gdb)  
260	    _sign_2__tmp_at2_483 = (_x_477 < 0); 
(gdb)  
261	    _sign_inlined_sign_at_2_481 = _sign_1__tmp_at2_482 - _sign_2__tmp_at2_483; 
(gdb)  
264	    _sign_1__tmp_at19_486 = (_y_478 > 0); 
(gdb)  
265	    _sign_2__tmp_at19_487 = (_y_478 < 0); 
(gdb)  
266	    _sign_inlined_sign_at_19_485 = _sign_1__tmp_at19_486 - _sign_2__tmp_at19_487; 
(gdb)  
267	    if (_sign_inlined_sign_at_2_481 == _sign_inlined_sign_at_19_485) 
(gdb)  
284	    return _154; 
(gdb) p _sign_inlined_sign_at_2_481  
$16 = 1 
(gdb) p _154 
$17 = 1 
(gdb) n 
326	} 
(gdb) finish 
Run till exit from #0  _2mod (_x_477=5, _y_478=_y_478@entry=2) at math.c:326 
_1Bin (_n_11027=<optimized out>, _n_11027@entry=5, _s_11028=-2130608542) at t_bugmagnet_15a.c:31 
31	    if (IS_ATOM_INT(_6220)) { 
Value returned is $18 = 1 
(gdb) n 
29	    _6220 = _2mod(_n_11027, 2); 
(gdb) p _6220 
$19 = -1073741825 

gdb tells me _2mod() returns 1, yet when I inspect the value of the returned variable the value is the same as the special NOVALUE number used to indicate the value has not been assigned.

new topic     » goto parent     » topic index » view message » categorize

7. Re: problem with euc on Win10 64bit AND Mint 32bit

Mysteries of what is going on with gdb aside, by solely inspecting you can see a problem at the end of the translated Bin routine where there is code after the return statement.but no label. There is no way to reach the second return. My guess is there is a forgotten NOP that needs to be emited in the translated version related to tail recursion. This kind of thing illustrates that although euphoria code is converted to a kind of intermediate language before translation and interpretation this intermediate language is not the same for both the interpreter and the translator. I say it ought to be though. There is a program for displaying this intermediate language called eudis, and it could simplify things a lot if NOP was supported by the interpreter and the translator always generated them.

    /** t_bugmagnet_15a.e:10	  if length(s) = 0 then */ 
    _6224 = 0; 
 
    /** t_bugmagnet_15a.e:11	   return to_integer("0") */ 
    RefDS(_6226); 
    _6227 = _6to_integer(_6226, 0); 
    DeRefDS(_s_11028); 
    return _6227; 
 
    /** t_bugmagnet_15a.e:13	  return to_integer(s) */ 
    RefDS(_s_11028); 
    _6228 = _6to_integer(_s_11028, 0); 
    DeRefDS(_s_11028); 
    DeRef(_6227); 
    _6227 = NOVALUE; 
    return _6228; 

new topic     » goto parent     » topic index » view message » categorize

8. Re: problem with euc on Win10 64bit AND Mint 32bit

I have created a ticket for this bug: ticket #935.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu