Skip to content

LLVM backend panic when comparing array of strings with empty string literal #4873

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

Open
FourteenBrush opened this issue Feb 23, 2025 · 6 comments
Labels

Comments

@FourteenBrush
Copy link
Contributor

Context

Odin:    dev-2025-02
OS:      NixOS 25.05 (Warbler), Linux 6.6.71
CPU:     AMD Ryzen 7 5800H with Radeon Graphics         
RAM:     15847 MiB
Backend: LLVM 18.1.8

Current Behavior

package test

main :: proc() {
    x: [4]string
    if x == "" {}
}

src/llvm_backend_expr.cpp(3195): Panic: Unknown handled type: [4]string -> [4]string

This does not happen when using anything else than an empty string literal

Failure Information (for bugs)

Relevant gdb output:

src/llvm_backend_expr.cpp(3195): Panic: Unknown handled type: [4]string -> [4]string

Thread 13 ".odin-wrapped" received signal SIGILL, Illegal instruction.
[Switching to Thread 0x7fffe86a56c0 (LWP 759814)]
0x000055555570489e in lb_emit_comp_against_nil(lbProcedure*, TokenKind, lbValue) ()
(gdb) 

Steps to Reproduce

Use the above code, and attempt to build it with odin build main.odin -file

@rezwanahmedsami
Copy link

ok , let me check on that

rezwanahmedsami added a commit to rezwanahmedsami/Odin that referenced this issue Feb 24, 2025
@rezwanahmedsami
Copy link

Context

Odin:    dev-2025-02
OS:      NixOS 25.05 (Warbler), Linux 6.6.71
CPU:     AMD Ryzen 7 5800H with Radeon Graphics         
RAM:     15847 MiB
Backend: LLVM 18.1.8

Current Behavior

package test

main :: proc() {
x: [4]string
if x == "" {}
}

src/llvm_backend_expr.cpp(3195): Panic: Unknown handled type: [4]string -> [4]string

This does not happen when using anything else than an empty string literal

Failure Information (for bugs)

Relevant gdb output:

src/llvm_backend_expr.cpp(3195): Panic: Unknown handled type: [4]string -> [4]string

Thread 13 ".odin-wrapped" received signal SIGILL, Illegal instruction.
[Switching to Thread 0x7fffe86a56c0 (LWP 759814)]
0x000055555570489e in lb_emit_comp_against_nil(lbProcedure*, TokenKind, lbValue) ()
(gdb) 

Steps to Reproduce

Use the above code, and attempt to build it with odin build main.odin -file

This issue has been solved: #4876

@rezwanahmedsami

This comment has been minimized.

@laytan laytan added the bug label Mar 21, 2025
@laytan
Copy link
Collaborator

laytan commented Mar 21, 2025

@gingerBill should this error in the frontend or be allowed and handled in the backend?

@FourteenBrush
Copy link
Contributor Author

@gingerBill should this error in the frontend or be allowed and handled in the backend?

I mean this comparison works fine with a non empty string, so this should be allowed right?

Seems to be an issue with lb_emit_comp_against_nil here

backtrace
#0  0x000055555570489e in lb_emit_comp_against_nil(lbProcedure*, TokenKind, lbValue) ()
#1  0x0000555555702322 in lb_emit_comp(lbProcedure*, TokenKind, lbValue, lbValue) ()
#2  0x00005555556f42cf in lb_build_binary_expr(lbProcedure*, Ast*) ()
#3  0x00005555556eab0c in lb_build_expr(lbProcedure*, Ast*) ()
#4  0x00005555556eea72 in lb_build_cond(lbProcedure*, Ast*, lbBlock*, lbBlock*) ()
#5  0x0000555555729a99 in lb_build_stmt(lbProcedure*, Ast*) ()
#6  0x000055555572e77c in lb_build_stmt_list(lbProcedure*, Slice<Ast*> const&) ()
#7  0x0000555555729d0e in lb_build_stmt(lbProcedure*, Ast*) ()
#8  0x000055555574c358 in lb_generate_procedure(lbModule*, lbProcedure*) ()
#9  0x000055555574c2b9 in lb_generate_procedures_worker_proc(void*) ()
#10 0x00005555555cf182 in internal_thread_proc(void*) ()
#11 0x00007fffeea968e3 in start_thread ()

@laytan
Copy link
Collaborator

laytan commented Mar 23, 2025

Ah I see, then it should be allowed and handled yep.

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.

3 participants