vishapoberon / compiler

vishap oberon compiler
http://oberon.vishap.am
GNU General Public License v3.0
186 stars 25 forks source link

Segfault when use NEW #61

Closed ghost closed 6 years ago

ghost commented 6 years ago
MODULE Hello;
  VAR
    code : POINTER TO ARRAY OF RECORD
      label : POINTER TO RECORD END;
    END;
BEGIN
  NEW(code, 666);
END Hello.
$  gdb --args voc Hello.mod
Program received signal SIGSEGV, Segmentation fault.
0x000000000042244a in OPC_Ident (obj=0x0) at OPC.c:184
184     mode = obj->mode;
(gdb) bt
#0  0x000000000042244a in OPC_Ident (obj=0x0) at OPC.c:184
#1  0x000000000042adc1 in OPV_NewArr (d=0x7ffff7ff1dd0, x=0x7ffff7ff1d50) at OPV.c:1186
#2  0x000000000042b6c2 in OPV_stat (n=0x7ffff7ff1d90, outerProc=0x0) at OPV.c:1342
#3  0x000000000042b13b in OPV_stat (n=0x7ffff7ff1c90, outerProc=0x0) at OPV.c:1258
#4  0x000000000042c115 in OPV_Module (prog=0x7ffff7ff1c90) at OPV.c:1557
#5  0x0000000000400b33 in Compiler_Module (done=0x7fffffffde9f "\001") at Compiler.c:46
#6  0x00000000004011e1 in Compiler_Translate () at Compiler.c:152
#7  0x000000000040144e in main (argc=2, argv=0x7fffffffe808) at Compiler.c:211

But if remove field "label" or make field static or remove call NEW then everythin work.

norayr commented 6 years ago

thank you!

norayr commented 6 years ago

used Templ's solution. https://github.com/jtempl/ofront/commit/9e3e13af63499aa61e8934c80e69eb18ffb35acf

norayr commented 6 years ago

https://github.com/vishaps/voc/commit/2ec7f3277a967ef16fd31752a2503153f5a9dd96