futurecore / revelation

A JIT-enabled functional simulator for the Adapteva Epiphany III architecture
http://www.revelation-sim.org/
BSD 3-Clause "New" or "Revised" License
6 stars 1 forks source link

String format `%.*e` causes the translated simulator to crash #35

Closed snim2 closed 8 years ago

snim2 commented 8 years ago

This code:

#include <float.h>
#include <stdio.h>
#include <stdint.h>

int main() {
    float d = 0xffffffffffffffff;
    printf("d     = %f\n", d);
    printf("d - 1 = %f\n", d - 1);
    return 0;
}

works:

Loading program revelation/test/c/print_large_float.elf on to core 0x808
d     = 18446744073709551616.000000
d - 1 = 18446744073709551616.000000
Done! Total ticks simulated = 25658
Core 0x808 (32, 8): STATUS=0x1105, Instructions executed=25658

This code:

#include <float.h>
#include <stdio.h>
#include <stdint.h>

int main() {
    float d = 0xffffffffffffffff;
    printf("d     = %.*e\n", DECIMAL_DIG, d);
    printf("d - 1 = %.*e\n", DECIMAL_DIG, d - 1);
    return 0;
}

works in the un-translated simulator, but in the translated simulator produces the following error:

RPython traceback:
  File "revelation_sim.c", line 404, in entry_point
  File "rpython_jit_metainterp.c", line 990, in ll_portal_runner__Signed_Signed_Signed_Signed_Si
  File "revelation_sim.c", line 7431, in portal
  File "revelation_execute_farith.c", line 18724, in farith_10
  ...
Fatal RPython error: ValueError

The file revelation_execute_farith.c is attached. revelation_execute_farith.txt