janet-lang / janet-lang/jaylib

math_cfuns being a constant causes a sigsev on macos

Open
#73 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
193
Forks
47
PR merge metrics
No merged PRs in 30d

Description

Working with jaylib for the first time and it seems like `math_cfuns` being a constant causes an immediate sigsev on macos.

### Reproduction steps:

(on a m2 macbook air)

- `jpm install jaylib`
- `janet`
```
Janet 1.39.1-homebrew macos/aarch64/clang - '(doc)' for help
repl:1:> (import jaylib)
fish: Job 1, 'janet' terminated by signal SIGSEGV (Address boundary error)
```

I then cloned jaylib locally and used `lldb` to do some debugging. Didn't really find anything helpful since I was too lazy to rebuild janet with debug symbols. I found, by slowly reducing the `janet_cfuns` calls in `main.c` that by not including the math functions it would import without crashing. Commented out the whole contents of `math_cfuns` and it still crashed. I noticed the only major difference between the math functions and everything else was that `math_cfuns` was a constant. By removing the constant declaration it compiled, and imported successfully.

Not sure I know enough about C to understand why this might be happening but since it seemed consistently reproducible and the math bindings look relatively new I wanted to file an issue. Let me know if there's anything else I can include to help debug this.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with main.c and inspect how math_cfuns is declared and included alongside the janet_cfuns calls. Reproduce the import on macOS/aarch64, then verify that importing jaylib completes without SIGSEGV while the math bindings remain available.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.