From adrian at openwork.nz Sun Oct 1 20:47:52 2023 From: adrian at openwork.nz (Adrian Cochrane) Date: Mon, 2 Oct 2023 09:47:52 +1300 Subject: Advice on diagnosing segfaults? Message-ID: <84fa2100-6657-006f-0957-3a344f3f3c80@openwork.nz> Hi, I've got a segfault in one of the language bindings I'm developing (fontconfig-pure), and I'm struggling to locate it. I see it occur in another project calling the language binding (so unfortunately I don't know what exactly is causing it), but GDB tells me that it occurs within a particular function I'm language binding to (and nothing more). I've attempted a few theoretical fixes without improvement (beyond triggering an infinite loop instead). And setting a breakpoint on the wrapper-function I added to create a better ABI to language bind to shows that dozens (if not more) of these calls successfully before I hit the segfault. I'm not sure how to diagnose this issue, any help would be appreciated! Cheers, Adrian Cochrane OpenWork Ltd libdggs spatial analysis Rhapsode & Haphaestus web browsers From lemming at henning-thielemann.de Sun Oct 1 20:59:18 2023 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sun, 1 Oct 2023 22:59:18 +0200 (CEST) Subject: Advice on diagnosing segfaults? In-Reply-To: <84fa2100-6657-006f-0957-3a344f3f3c80@openwork.nz> References: <84fa2100-6657-006f-0957-3a344f3f3c80@openwork.nz> Message-ID: <7789447d-e520-4ffd-925f-f2fa37da9891@henning-thielemann.de> On Mon, 2 Oct 2023, Adrian Cochrane wrote: > I've got a segfault in one of the language bindings I'm developing > (fontconfig-pure), and I'm struggling to locate it. I could solve some problems in my C library bindings using ltrace. It logs all calls to external C libraries together with the function parameters. You can create a config file in order to improve reporting of passed parameters. Another useful tool might be valgrind. I think it should also point you to the crashing function call.