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

Cannot deal with undefined variables #4

Closed
Icenowy opened this issue Jan 26, 2017 · 2 comments
Closed

Cannot deal with undefined variables #4

Icenowy opened this issue Jan 26, 2017 · 2 comments

Comments

@Icenowy
Copy link

Icenowy commented Jan 26, 2017

icenowy@x220i [ oil@master ] $ bin/osh
osh$ $a
Traceback (most recent call last):
  File "bin/osh", line 374, in <module>
    sys.exit(main(sys.argv))
  File "bin/osh", line 364, in main
    return OshMain(main_argv)
  File "bin/osh", line 274, in OshMain
    InteractiveLoop(opts, ex, c_parser, w_parser, line_reader)
  File "bin/osh", line 100, in InteractiveLoop
    status, cflow = ex.ExecuteTop(node)
  File "/home/icenowy/git-repos/oil/bin/../core/cmd_exec.py", line 635, in ExecuteTop
    status, cflow = self.Execute(node)
  File "/home/icenowy/git-repos/oil/bin/../core/cmd_exec.py", line 663, in Execute
    raise AssertionError('Error evaluating words: %s' % err)
AssertionError: Error evaluating words: ['Undefined variable a', 'Error evaluating word part (SimpleVarSub token:(token id:VSub_Name val:"$a" span_id:0))', 'Error evaluating word (CompoundWord parts:[(SimpleVarSub token:(token id:VSub_Name val:"$a" span_id:0))])']

But on a standard POSIX sh, the value of undefined variables are just nothing.

@andychu
Copy link
Contributor

andychu commented Jan 26, 2017

Yes, this is a bug I just introduced in the process of making the AST more detailed. To convert osh to oil, I need to represent the different between $a and ${a}, which doesn't matter from an execution point of view. So the executor doesn't deal properly with $a (but I think ${a} should work).

After the AST is done evolving (based on three use cases I outlined at the end of this post: http://www.oilshell.org/blog/2017/01/06.html ) I need to make another pass on the executor to fix up stuff like this.

Thanks for trying it!

@andychu
Copy link
Contributor

andychu commented Mar 7, 2017

I fixed this with commit cb22624. That fixed the way we processed $a and ${a} -- i.e. the difference introduced by the Lossless Syntax Tree.

Now it complains about not having one argument, which isn't right either, but we're making progress :)

If you are interested in helping let me know, or subscribe to oil-dev: http://lists.oilshell.org/private.cgi/oil-dev-oilshell.org/2017-March/thread.html

$ bin/osh
osh$ $a
Traceback (most recent call last):
  File "bin/osh", line 378, in <module>
    sys.exit(main(sys.argv))
  File "bin/osh", line 368, in main
    return OshMain(main_argv)
  File "bin/osh", line 278, in OshMain
    InteractiveLoop(opts, ex, c_parser, w_parser, line_reader)
  File "bin/osh", line 100, in InteractiveLoop
    status, cflow = ex.ExecuteTop(node)
  File "/home/andy/git/oil/bin/../core/cmd_exec.py", line 866, in ExecuteTop
    status, cflow = self.Execute(node)
  File "/home/andy/git/oil/bin/../core/cmd_exec.py", line 852, in Execute
    status, cflow = self._Execute(node)
  File "/home/andy/git/oil/bin/../core/cmd_exec.py", line 661, in _Execute
    thunk = self._GetThunkForSimpleCommand(argv, more_env)
  File "/home/andy/git/oil/bin/../core/cmd_exec.py", line 503, in _GetThunkForSimpleCommand
    assert argv, "Need at least one arugment"
AssertionError: Need at least one arugment

@andychu andychu closed this as completed Mar 7, 2017
andychu pushed a commit that referenced this issue Feb 6, 2021
Why didn't this happen on my own machine?

http://travis-ci.oilshell.org/srht-jobs/2021-02-06__19-34-07.wwz/_tmp/toil/logs/cpp-unit-all.txt

--> COLLECT with 0 roots
i = -2147483648
.AddressSanitizer:DEADLYSIGNAL
=================================================================
==3052==ERROR: AddressSanitizer: SEGV on unknown address 0x7f8666c53034 (pc 0x55618e7f6d5b bp 0x7ffc429f1190 sp 0x7ffc429f1180 T0)
==3052==The signal is caused by a READ memory access.
    #0 0x55618e7f6d5a in gc_heap::str_equals(gc_heap::Str*, gc_heap::Str*) /home/build/oil/mycpp/gc_heap.cc:260
    #1 0x55618e7dafd0 in str_replace_test /home/build/oil/mycpp/my_runtime_test.cc:162
    #2 0x55618e7e7bd6 in main /home/build/oil/mycpp/my_runtime_test.cc:779
    #3 0x7f866924109a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #4 0x55618e7d94b9 in _start (/home/build/oil/mycpp/_bin/my_runtime_test.asan+0xd4b9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/build/oil/mycpp/gc_heap.cc:260 in gc_heap::str_equals(gc_heap::Str*, gc_heap::Str*)
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