{"action":"created","issue":{"url":"https://api.github.com/repos/trealla-lang/trealla/issues/77","repository_url":"https://api.github.com/repos/trealla-lang/trealla","labels_url":"https://api.github.com/repos/trealla-lang/trealla/issues/77/labels{/name}","comments_url":"https://api.github.com/repos/trealla-lang/trealla/issues/77/comments","events_url":"https://api.github.com/repos/trealla-lang/trealla/issues/77/events","html_url":"https://github.com/trealla-lang/trealla/issues/77","id":196930748,"number":77,"title":"Unknown operator cause segmentation fault","user":{"login":"dram","id":517130,"avatar_url":"https://avatars.githubusercontent.com/u/517130?v=3","gravatar_id":"","url":"https://api.github.com/users/dram","html_url":"https://github.com/dram","followers_url":"https://api.github.com/users/dram/followers","following_url":"https://api.github.com/users/dram/following{/other_user}","gists_url":"https://api.github.com/users/dram/gists{/gist_id}","starred_url":"https://api.github.com/users/dram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dram/subscriptions","organizations_url":"https://api.github.com/users/dram/orgs","repos_url":"https://api.github.com/users/dram/repos","events_url":"https://api.github.com/users/dram/events{/privacy}","received_events_url":"https://api.github.com/users/dram/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-21T13:18:25Z","updated_at":"2016-12-22T04:02:22Z","closed_at":null,"body":"Following code will cause segmentation fault:\r\n\r\n```\r\n:- initialization(main).\r\n\r\nmain :- 1 => 2, halt.\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nTrealla v0.1alpha, 64-bits (int=128-bits), Dec 21 2016\r\nERROR: unknown operator: '=>'\r\nERROR: consult 'foo.pro', line=2, 'main :- 1 => 2, halt.'\r\nSegmentation fault (core dumped)\r\n```\r\n\r\nBacktrace:\r\n\r\n```\r\nCore was generated by `tpl foo.pro'.\r\nProgram terminated with signal SIGSEGV, Segmentation fault.\r\n#0  0x0000000000404f81 in term_heapcheck (n=0x0) at src/trealla.c:181\r\n181             if (!(n->flags & FLAG_HEAP))\r\n(gdb) bt\r\n#0  0x0000000000404f81 in term_heapcheck (n=0x0) at src/trealla.c:181\r\n#1  0x000000000040bf75 in lexer_consult_fp (self=0x7ffffd72cd00, fp=0x66aa700)\r\n    at src/trealla.c:2406\r\n#2  0x000000000040c0de in lexer_consult_file (self=0x7ffffd72cd00, \r\n    filename=0x7ffffd72f3a9 \"foo.pro\") at src/trealla.c:2437\r\n#3  0x000000000040ea94 in trealla_consult_file (self=0x659e010, \r\n    name=0x7ffffd72f3a9 \"foo.pro\") at src/trealla.c:3221\r\n#4  0x00000000004044aa in main (ac=2, av=0x7ffffd72da58) at tpl.c:328\r\n(gdb) \r\n```\r\n\r\nBTW, the error line number is also incorrect."},"comment":{"url":"https://api.github.com/repos/trealla-lang/trealla/issues/comments/268713372","html_url":"https://github.com/trealla-lang/trealla/issues/77#issuecomment-268713372","issue_url":"https://api.github.com/repos/trealla-lang/trealla/issues/77","id":268713372,"user":{"login":"dram","id":517130,"avatar_url":"https://avatars.githubusercontent.com/u/517130?v=3","gravatar_id":"","url":"https://api.github.com/users/dram","html_url":"https://github.com/dram","followers_url":"https://api.github.com/users/dram/followers","following_url":"https://api.github.com/users/dram/following{/other_user}","gists_url":"https://api.github.com/users/dram/gists{/gist_id}","starred_url":"https://api.github.com/users/dram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dram/subscriptions","organizations_url":"https://api.github.com/users/dram/orgs","repos_url":"https://api.github.com/users/dram/repos","events_url":"https://api.github.com/users/dram/events{/privacy}","received_events_url":"https://api.github.com/users/dram/received_events","type":"User","site_admin":false},"created_at":"2016-12-22T04:02:22Z","updated_at":"2016-12-22T04:02:22Z","body":"Following code still cause a memory error:\r\n\r\n```\r\n:- initialization(main).\r\n\r\nfoo(N) :-\r\n    nl,\r\n    N => N.\r\n\r\nmain :- halt.\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nTrealla v0.1alpha, 64-bits (int=128-bits), Dec 22 2016\r\nERROR: unknown operator: '=>'\r\n*** Error in `tpl': double free or corruption (!prev): 0x0000000006835940 ***\r\nAborted (core dumped)\r\n```\r\n\r\nBacktrace:\r\n\r\n```\r\nCore was generated by `tpl foo.pro'.\r\nProgram terminated with signal SIGABRT, Aborted.\r\n#0  0x00007f0cef0f0067 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56\r\n56      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.\r\n(gdb) bt\r\n#0  0x00007f0cef0f0067 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56\r\n#1  0x00007f0cef0f1448 in __GI_abort () at abort.c:89\r\n#2  0x00007f0cef12e1b4 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7f0cef223210 \"*** Error in `%s': %s: 0x%s ***\\n\") at ../sysdeps/posix/libc_fatal.c:175\r\n#3  0x00007f0cef13398e in malloc_printerr (action=1, str=0x7f0cef223318 \"double free or corruption (!prev)\", ptr=<optimized out>) at malloc.c:4996\r\n#4  0x00007f0cef134696 in _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3840\r\n#5  0x000000000040bda6 in lexer_parse (self=0x7fffca2e7530, term=0x0, src=0x0, line=0x7fffca2e70b8) at src/trealla.c:2355\r\n#6  0x000000000040be92 in lexer_consult_fp (self=0x7fffca2e7530, fp=0x6835700) at src/trealla.c:2387\r\n#7  0x000000000040c12a in lexer_consult_file (self=0x7fffca2e7530, filename=0x7fffca2e93b4 \"foo.pro\") at src/trealla.c:2446\r\n#8  0x000000000040eae0 in trealla_consult_file (self=0x6729010, name=0x7fffca2e93b4 \"foo.pro\") at src/trealla.c:3230\r\n#9  0x00000000004044aa in main (ac=2, av=0x7fffca2e8288) at tpl.c:328\r\n```\r\n\r\nI'll reopen this issue."}}
{"actor":{"display_login":"dram"}}