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

Crash calling a super class method from new() #12471

Closed
Raimondi opened this issue May 30, 2023 · 0 comments
Closed

Crash calling a super class method from new() #12471

Raimondi opened this issue May 30, 2023 · 0 comments
Labels

Comments

@Raimondi
Copy link

Raimondi commented May 30, 2023

Steps to reproduce

Source the following script:

vim9script

class Base
    def Method(arg = 0)
        echom 'Method'
    enddef
endclass

class Child extends Base
    def new()
        super.Method()
    enddef
endclass

Child.new()

That makes vim crash.

Notice that the method of the base class needs to have at least one argument to make vim crash.

I was trying to make a helper function for the child classes to use with new(), when I hit the wall. Replacing super.Method() with Base.Method() doesn't crash, but it says E1325: Method not found on class "Base": Method().

I attached the stack trace at the end.

Expected behaviour

Not crashing.

Version of Vim

9.0.1592

Environment

OS: MacOS 13.1
Terminal: iTerm 3.4.19
$TERM: xterm-256color
Shell: Fish 3.6.1

Logs and stack traces

Process 98216 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001002f8ed9 vim`get_type_ptr(type_gap=0x00000001012a3698) at vim9type.c:43:54
   40  	    if (type == NULL)
   41  		return NULL;
   42
-> 43  	    ((type_T **)type_gap->ga_data)[type_gap->ga_len] = type;
   44  	    ++type_gap->ga_len;
   45  	    return type;
   46  	}
Target 0: (vim) stopped.
(lldb) thread backtrace
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000001002f8ed9 vim`get_type_ptr(type_gap=0x00000001012a3698) at vim9type.c:43:54
    frame #1: 0x00000001002f983c vim`alloc_func_type(ret_type=0x00000001003ae890, argcount=1, type_gap=0x00000001012a3698) at vim9type.c:311:20
    frame #2: 0x00000001002d276e vim`set_function_type(ufunc=0x00000001012a3630) at vim9compile.c:3903:24
    frame #3: 0x00000001002d00ec vim`compile_def_function(ufunc=0x00000001012a3630, check_return_type=0, compile_type=CT_NONE, outer_cctx=0x0000000000000000) at vim9compile.c:3214:6
    frame #4: 0x00000001002f4945 vim`generate_CALL(cctx=0x00007ff7bfef99e0, ufunc=0x00000001012a3630, cl=0x0000000000000000, mi=0, pushed_argcount=0) at vim9instr.c:1842:6
    frame #5: 0x00000001002f095a vim`compile_class_object_index(cctx=0x00007ff7bfef99e0, arg=0x00007ff7bfef96c0, type=0x0000600000239ec0) at vim9expr.c:362:9
    frame #6: 0x00000001002f011c vim`compile_subscript(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0, start_leader="super.Method()", end_leader=0x00007ff7bfef8f90, ppconst=0x00007ff7bfef9338) at vim9expr.c:2302:7
    frame #7: 0x00000001002ed2da vim`compile_expr9(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0, ppconst=0x00007ff7bfef9338) at vim9expr.c:2606:9
    frame #8: 0x00000001002ecb2b vim`compile_expr8(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0, ppconst=0x00007ff7bfef9338) at vim9expr.c:2651:9
    frame #9: 0x00000001002ec6f2 vim`compile_expr7(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0, ppconst=0x00007ff7bfef9338) at vim9expr.c:2685:9
    frame #10: 0x00000001002ec222 vim`compile_expr6(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0, ppconst=0x00007ff7bfef9338) at vim9expr.c:2764:9
    frame #11: 0x00000001002ebd70 vim`compile_expr5(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0, ppconst=0x00007ff7bfef9338) at vim9expr.c:2872:9
    frame #12: 0x00000001002eba07 vim`compile_expr4(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0, ppconst=0x00007ff7bfef9338) at vim9expr.c:3009:9
    frame #13: 0x00000001002eb2f2 vim`compile_expr3(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0, ppconst=0x00007ff7bfef9338) at vim9expr.c:3283:9
    frame #14: 0x00000001002eb1a2 vim`compile_expr2(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0, ppconst=0x00007ff7bfef9338) at vim9expr.c:3308:9
    frame #15: 0x00000001002eab1c vim`compile_expr1(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0, ppconst=0x00007ff7bfef9338) at vim9expr.c:3349:9
    frame #16: 0x00000001002eb21e vim`compile_expr0_ext(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0, is_const=0x0000000000000000) at vim9expr.c:3508:9
    frame #17: 0x00000001002ea1e1 vim`compile_expr0(arg=0x00007ff7bfef96c0, cctx=0x00007ff7bfef99e0) at vim9expr.c:3526:12
    frame #18: 0x00000001002c93b9 vim`compile_eval(arg="super.Method()", cctx=0x00007ff7bfef99e0) at vim9cmds.c:1874:9
    frame #19: 0x00000001002d0f8e vim`compile_def_function(ufunc=0x00000001012a3490, check_return_type=0, compile_type=CT_NONE, outer_cctx=0x0000000000000000) at vim9compile.c:3622:14
    frame #20: 0x00000001002dea34 vim`call_def_function(ufunc=0x00000001012a3490, argc_arg=0, argv=0x00007ff7bfefa780, flags=0, partial=0x0000000000000000, object=0x0000000000000000, funccal=0x0000000102844c00, rettv=0x00007ff7bfefb238) at vim9execute.c:5910:6
    frame #21: 0x00000001002b45e6 vim`call_user_func(fp=0x00000001012a3490, argcount=0, argvars=0x00007ff7bfefa780, rettv=0x00007ff7bfefb238, funcexe=0x00007ff7bfefa6a8, selfdict=0x0000000000000000) at userfunc.c:2785:6
    frame #22: 0x00000001002b4312 vim`call_user_func_check(fp=0x00000001012a3490, argcount=0, argvars=0x00007ff7bfefa780, rettv=0x00007ff7bfefb238, funcexe=0x00007ff7bfefa6a8, selfdict=0x0000000000000000) at userfunc.c:3218:10
    frame #23: 0x00000001002c4ea3 vim`class_object_index(arg=0x00007ff7bfefb110, rettv=0x00007ff7bfefb238, evalarg=0x00007ff7bfefb1b0, verbose=1) at vim9class.c:1309:15
    frame #24: 0x0000000100073ca4 vim`handle_subscript(arg=0x00007ff7bfefb110, name_start="Child.new()", rettv=0x00007ff7bfefb238, evalarg=0x00007ff7bfefb1b0, verbose=1) at eval.c:6930:10
    frame #25: 0x00000001000764dd vim`eval9(arg=0x00007ff7bfefb110, rettv=0x00007ff7bfefb238, evalarg=0x00007ff7bfefb1b0, want_string=0) at eval.c:4309:8
    frame #26: 0x00000001000787c1 vim`eval8(arg=0x00007ff7bfefb110, rettv=0x00007ff7bfefb238, evalarg=0x00007ff7bfefb1b0, want_string=0) at eval.c:3841:11
    frame #27: 0x00000001000781c5 vim`eval7(arg=0x00007ff7bfefb110, rettv=0x00007ff7bfefb238, evalarg=0x00007ff7bfefb1b0, want_string=0) at eval.c:3645:9
    frame #28: 0x00000001000777da vim`eval6(arg=0x00007ff7bfefb110, rettv=0x00007ff7bfefb238, evalarg=0x00007ff7bfefb1b0) at eval.c:3424:9
    frame #29: 0x0000000100077465 vim`eval5(arg=0x00007ff7bfefb110, rettv=0x00007ff7bfefb238, evalarg=0x00007ff7bfefb1b0) at eval.c:3313:9
    frame #30: 0x00000001000770aa vim`eval4(arg=0x00007ff7bfefb110, rettv=0x00007ff7bfefb238, evalarg=0x00007ff7bfefb1b0) at eval.c:3164:9
    frame #31: 0x0000000100076be8 vim`eval3(arg=0x00007ff7bfefb110, rettv=0x00007ff7bfefb238, evalarg=0x00007ff7bfefb1b0) at eval.c:3025:9
    frame #32: 0x000000010006eda8 vim`eval2(arg=0x00007ff7bfefb110, rettv=0x00007ff7bfefb238, evalarg=0x00007ff7bfefb1b0) at eval.c:2899:9
    frame #33: 0x000000010006920f vim`eval1(arg=0x00007ff7bfefb110, rettv=0x00007ff7bfefb238, evalarg=0x00007ff7bfefb1b0) at eval.c:2745:9
    frame #34: 0x000000010006eb29 vim`eval0_retarg(arg="Child.new()", rettv=0x00007ff7bfefb238, eap=0x00007ff7bfefb3e8, evalarg=0x00007ff7bfefb1b0, retarg=0x0000000000000000) at eval.c:2654:11
    frame #35: 0x0000000100068862 vim`eval0(arg="Child.new()", rettv=0x00007ff7bfefb238, eap=0x00007ff7bfefb3e8, evalarg=0x00007ff7bfefb1b0) at eval.c:2589:12
    frame #36: 0x00000001000bcf26 vim`ex_eval(eap=0x00007ff7bfefb3e8) at ex_eval.c:951:9
    frame #37: 0x00000001000ab2df vim`do_one_cmd(cmdlinep=0x00007ff7bfefb650, flags=7, cstack=0x00007ff7bfefb688, fgetline=(vim`getsourceline at scriptfile.c:2320), cookie=0x00007ff7bfefbdc8) at ex_docmd.c:2582:2
    frame #38: 0x00000001000a83d2 vim`do_cmdline(cmdline="vim9script", fgetline=(vim`getsourceline at scriptfile.c:2320), cookie=0x00007ff7bfefbdc8, flags=7) at ex_docmd.c:994:17
    frame #39: 0x000000010020bf8b vim`do_source_ext(fname="test.vim", check_other=0, is_vimrc=0, ret_sid=0x0000000000000000, eap=0x0000000000000000, clearvars=0) at scriptfile.c:1760:5
    frame #40: 0x000000010020b481 vim`do_source(fname="test.vim", check_other=0, is_vimrc=0, ret_sid=0x0000000000000000) at scriptfile.c:1906:12
    frame #41: 0x000000010020b2f6 vim`cmd_source(fname="test.vim", eap=0x00007ff7bfefc078) at scriptfile.c:1251:14
    frame #42: 0x000000010020b12c vim`ex_source(eap=0x00007ff7bfefc078) at scriptfile.c:1277:2
    frame #43: 0x00000001000ab2df vim`do_one_cmd(cmdlinep=0x00007ff7bfefc2e0, flags=0, cstack=0x00007ff7bfefc318, fgetline=(vim`getexline at ex_getln.c:2844), cookie=0x0000000000000000) at ex_docmd.c:2582:2
    frame #44: 0x00000001000a83d2 vim`do_cmdline(cmdline=0x0000000000000000, fgetline=(vim`getexline at ex_getln.c:2844), cookie=0x0000000000000000, flags=0) at ex_docmd.c:994:17
    frame #45: 0x00000001001607a1 vim`nv_colon(cap=0x00007ff7bfefc9d8) at normal.c:3191:15
    frame #46: 0x000000010015946b vim`normal_cmd(oap=0x00007ff7bfefca60, toplevel=1) at normal.c:939:5
    frame #47: 0x0000000100357ef0 vim`main_loop(cmdwin=0, noexmode=0) at main.c:1539:3
    frame #48: 0x000000010035673a vim`vim_main2 at main.c:887:5
    frame #49: 0x0000000100353e71 vim`main(argc=1, argv=0x00007ff7bfefce28) at main.c:433:12
    frame #50: 0x00007ff806480310 dyld`start + 2432
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant