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

Getting 'Segmentation fault', 'Bus error' and 'Illegal instruction' #4287

Open
tymbaca opened this issue Sep 21, 2024 · 1 comment
Open

Getting 'Segmentation fault', 'Bus error' and 'Illegal instruction' #4287

tymbaca opened this issue Sep 21, 2024 · 1 comment
Labels
needs-validation Reviewers need to validate that everything is in working order

Comments

@tymbaca
Copy link

tymbaca commented Sep 21, 2024

Context

  • Please paste odin report output:
        Odin:    dev-2024-09-nightly:dd1f151
        OS:      macOS Sonoma 14.3.1 (build: 23D2057, kernel: 23.3.0)
        CPU:     Apple M3
        RAM:     16384 MiB
        Backend: LLVM 18.1.8

Expected Behavior

Expected healthy compile and run

Current Behavior

I'm getting three different runtime (i guess) error depending on absolutely normal code changes

Failure Information (for bugs)

I was trying to implement ECS library. But at some point got stuck on this.

Steps to Reproduce

The error is really flaky and unpredictable. It may disappear on any code change. So please, try to reproduce by cloning the repo (branch: crap) and running make, repo: https://github.com/tymbaca/ecs/tree/crap

In cmd/main.odin there are 3 different main procedures, each will result in corresponding error:

package main

import ".."
import "core:fmt"
import rl "vendor:raylib"


WORLD := ecs.new_world(Component)

main :: proc() {
	mainSegFault() // <- change to any of main* proc below

	fmt.println("at the end of main") // this will not run
}

mainBus :: proc() {
	ecs.create_entity(
		&WORLD,
		Player_Control{},
		Movement{speed = 1.0},
		Box{size = {40, 50}, color = rl.RED},
		Transform{},
	)

	fmt.println("after entity create")
}

mainIlligal :: proc() {
	ecs.create_entity(
		&WORLD,
		Player_Control{},
		Movement{speed = 1.0},
		/*
		Box{size = {40, 50}, color = rl.RED},
		Transform{},
        */
	)

	fmt.println("after entity create")
}

mainSegFault :: proc() {
	ecs.create_entity(
		&WORLD,
		Movement{speed = 1.0},
		Box{size = {40, 50}, color = rl.RED},
		Transform{},
		Player_Control{}, // moved this to last position
	)

	fmt.println("after entity create")
}

mainOK :: proc() {
	ecs.create_entity(
		&WORLD,
		// Movement{speed = 1.0},
		// Box{size = {40, 50}, color = rl.RED},
		Transform{}, // this runs well LOL
		// Player_Control{},
	)

	fmt.println("after entity create")
}

The ecs.create_entity is pretty much a dummy:

// create_entity creates new entity with specified components, adds it to world and returns it
create_entity :: proc(world: ^World($T), components: ..T) {
	// nothing happens here
}

I guess there is something wrong with the combination of generic type World -> Union type Component -> component: ..T

Failure Logs

make: *** [run] Segmentation fault: 11
make: *** [run] Bus error: 10
make: *** [run] Illegal instruction: 4
@laytan laytan added the needs-validation Reviewers need to validate that everything is in working order label Oct 8, 2024
@tf2spi
Copy link
Contributor

tf2spi commented Oct 22, 2024

Are you still experiencing this issue? Having trouble reproducing it on Mac OS M2 and Linux. Might be finnicky like you said.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-validation Reviewers need to validate that everything is in working order
Projects
None yet
Development

No branches or pull requests

3 participants