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

Misc. bug: #if doesn't have #else which leads to a broken binary #10947

Open
yurivict opened this issue Dec 22, 2024 · 1 comment
Open

Misc. bug: #if doesn't have #else which leads to a broken binary #10947

yurivict opened this issue Dec 22, 2024 · 1 comment

Comments

@yurivict
Copy link
Contributor

yurivict commented Dec 22, 2024

Name and Version

4372

Operating systems

BSD

Which llama.cpp modules do you know to be affected?

Test code

Problem description & steps to reproduce

This #if doesn't have a corresponding #else:

#if defined(__APPLE__)

This results in a broken code on FreeBSD 14.2 where none of the conditions are met, with crash like this:

┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│   0x2c51b790 <_ZL19get_executable_pathv>          push   %rbp                                                                                                                             │
│   0x2c51b791 <_ZL19get_executable_pathv+1>        mov    %rsp,%rbp                                                                                                                        │
│   0x2c51b794 <_ZL19get_executable_pathv+4>        mov    %rdi,-0x8(%rbp)                                                                                                                  │
│  >0x2c51b798 <_ZL19get_executable_pathv+8>        ud2                                                                                                                                     │
│   0x2c51b79a                                      nopw   0x0(%rax,%rax,1)                                                                                                                 │
│   0x2c51b7a0 <_ZL23backend_filename_suffixv>      push   %rbp                                                                                                                             │
│   0x2c51b7a1 <_ZL23backend_filename_suffixv+1>    mov    %rsp,%rbp                                                                                                                        │
│   0x2c51b7a4 <_ZL23backend_filename_suffixv+4>    sub    $0x10,%rsp                                                                                                                       │
│   0x2c51b7a8 <_ZL23backend_filename_suffixv+8>    mov    %rdi,%rax                                                                                                                        │
│   0x2c51b7ab <_ZL23backend_filename_suffixv+11>   mov    %rax,-0x10(%rbp)                                                                                                                 │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

First Bad Commit

No response

Relevant log output

No response

@yurivict
Copy link
Contributor Author

This appears to be a general code defect in many places: no #else clauses.

When no condition is satisfied - many code sections silently do nothing instead of alerting the user either during build or at run-time.

examples/server/httplib.h has another example of the same problem.

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

No branches or pull requests

1 participant