{"id":17933671,"url":"https://github.com/keyan/cgo_segfault","last_synced_at":"2025-08-15T16:31:00.068Z","repository":{"id":87742666,"uuid":"259978299","full_name":"keyan/cgo_segfault","owner":"keyan","description":"Catching C stacktraces from a Go parent process","archived":false,"fork":false,"pushed_at":"2020-04-30T02:05:59.000Z","size":2,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-28T21:50:22.067Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keyan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-29T16:20:26.000Z","updated_at":"2024-07-10T08:38:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"87414e33-b2cd-470b-9776-e21e0995df04","html_url":"https://github.com/keyan/cgo_segfault","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keyan%2Fcgo_segfault","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keyan%2Fcgo_segfault/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keyan%2Fcgo_segfault/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keyan%2Fcgo_segfault/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keyan","download_url":"https://codeload.github.com/keyan/cgo_segfault/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229927123,"owners_count":18145865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T21:41:11.706Z","updated_at":"2024-12-16T08:17:26.232Z","avatar_url":"https://github.com/keyan.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cgo_segfault\n\nExample code demonstrating setup of a global constructor to install a signal handler to catch signals occuring within [cgo](https://golang.org/cmd/cgo/) called C/C++ functions.\n\n## Background\nRecently I ran into an issue where I was calling into a C++ function, accessing invalid memory, and causing a segmentation fault which results in the operating system issuing a `SIGSEGV` signal to the parent Go process, which then crashes. Unfortunately, the Go signal handler doesn't know how to unwind the C stack and generate a panic so instead it just outputs something like:\n\n```\ngo fatal error: unexpected signal during runtime execution\n```\n\nThis code installs a signal handler in C before the Go process starts, intentionally casuses a segmentation fault, handles the resulting OS signal, and exits. It doesn't properly dump a backtrace, for reasons which are explained in more detail here: https://keyanp.com/cgo-segfault.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeyan%2Fcgo_segfault","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeyan%2Fcgo_segfault","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeyan%2Fcgo_segfault/lists"}