Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core dumped on an undefined variable with a new PC definition #4

Closed
pawelkrol opened this issue Oct 1, 2020 · 3 comments
Closed

Core dumped on an undefined variable with a new PC definition #4

pawelkrol opened this issue Oct 1, 2020 · 3 comments

Comments

@pawelkrol
Copy link

When an undefined variable is encountered in a source code accompanied by an additional PC definition command, it results in a failed assertion and a consequent core dump.

Here is a minimal example to reproduce the issue:

        *= $0800
        ora $1000
        jmp $0900

        *= $0900
        jmp show

Compilation of this syntactically valid code snippet fails with the following error message:

Some vars still undefined. Dump not yet supported, sorry!
dreamass: segment.c:430: segment_enterSegElem: Assertion `false' failed.
Aborted (core dumped)

An expected behaviour would be to report show as an undefined variable just like this:

Some vars still undefined. Dump not yet supported, sorry!
program.src:6: error:variable undefined: show
@thecky
Copy link

thecky commented Apr 13, 2021

Hi, I checked out the commit ba43fe1 - which is the last commit in 2014 (= oldversion), and I can't reproduce your issue.
I used your code snippet from above and got this output:
Some vars still undefined. Dump not yet supported, sorry! testfile.asm:6: error:variable undefined: show

Even with the latest commit (bc34eb3), I get the desired error message.

@pawelkrol
Copy link
Author

OK, so I still get a segmentation fault on ba43fe1 just as described:

$ git reset --hard ba43fe1
HEAD is now at ba43fe1 Code cleanups. Use fixed sizes for all types.
$ make
$ ./dreamass program.src 
Some vars still undefined. Dump not yet supported, sorry!
dreamass: segment.c:430: segment_enterSegElem: Assertion `false' failed.
Aborted (core dumped)

Interestingly it doesn't show up under valgrind:

$ valgrind --leak-check=full dreamass program.src 
Some vars still undefined. Dump not yet supported, sorry!
WARNING: PC still phased at end of segment.
program.src:6: error:variable undefined: show

However after fetching just the very next commit 98c93ba everything works as expected:

$ git merge $(git rev-list master..origin/master | tail -n1)
Updating ba43fe1..98c93ba
Fast-forward
 segment.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
$ make
$ ./dreamass program.src 
Some vars still undefined. Dump not yet supported, sorry!
WARNING: PC still phased at end of segment.
program.src:6: error:variable undefined: show

Judging from the contents of a core dump, it looks like the issue has been indeed fixed by 98c93ba:

$ ulimit -c unlimited
$ ./dreamass program.src
$ coredumpctl list
TIME                            PID   UID   GID SIG COREFILE  EXE
Wed 2021-04-14 18:05:25 CEST  19072  1000  1000   6 present   /data/Tools/dreamass/dreamass
$ coredumpctl info 19072
        Signal: 6 (ABRT)
       Message: Process 19072 (dreamass) of user 1000 dumped core.
                
                Stack trace of thread 19072:
                #0  0x00007f67c842d9d5 raise (libc.so.6 + 0x3d9d5)
                #1  0x00007f67c84168a4 abort (libc.so.6 + 0x268a4)
                #2  0x00007f67c8416789 __assert_fail_base.cold (libc.so.6 + 0x26789)
                #3  0x00007f67c8426026 __assert_fail (libc.so.6 + 0x36026)
                #4  0x0000000000409daf segment_enterSegElem (dreamass + 0x9daf)
                #5  0x0000000000406852 nextvalid (dreamass + 0x6852)
                #6  0x0000000000406b0b pp_get (dreamass + 0x6b0b)
                #7  0x0000000000405fdd pass_showUndefs (dreamass + 0x5fdd)
                #8  0x0000000000402db2 baekwha (dreamass + 0x2db2)
                #9  0x00000000004013d2 main (dreamass + 0x13d2)
                #10 0x00007f67c84181e2 __libc_start_main (libc.so.6 + 0x281e2)
                #11 0x000000000040141e _start (dreamass + 0x141e)

No clue why you couldn't reproduce the problem. I'm glad it's been fixed though.

@thecky
Copy link

thecky commented Apr 14, 2021

Yep, it seems fixed in latest commits - and your're right, the bug is still in ba43fe1.
My mistake was: I used my version under /usr/bin and not the version from git (forgotten the ./) and the version under /usr/bin is from 2014 - but without the bug (it's not a version from Github).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants