Bug 270273 - cad/kicad: Fix kicad-cli
Summary: cad/kicad: Fix kicad-cli
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Christoph Moench-Tegeder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-16 21:28 UTC by bsd_orsolic
Modified: 2023-10-15 16:21 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (cmt)


Attachments
patch (1.83 KB, patch)
2023-03-16 21:28 UTC, bsd_orsolic
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bsd_orsolic 2023-03-16 21:28:52 UTC
Created attachment 240904 [details]
patch

Patch which enables kicad-cli to work as expected.

Otherwise kicad-cli won't crash, but it will return 2 (which is enum CLI::EXIT_CODES::ERR_UNKNOWN) and won't work, e.g.:
% kicad-cli sch export pdf file.kicad_sch -o file.pdf
zsh: exit 2     kicad-cli sch export pdf file.kicad_sch -o file.pdf
% echo $?
2

After some debugging, it was found that variable aPdfJob after dynamic_cast will be NULL. After changing to static_cast variable has normal address.

Tested on FreeBSD -STABLE and -CURRENT and it works - kicad-cli returns 0 and exports sch/pcb to PDF.
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-03-24 21:28:00 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=12ebb5e5de4b1107fbd48dda4ae44e2afda985ba

commit 12ebb5e5de4b1107fbd48dda4ae44e2afda985ba
Author:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
AuthorDate: 2023-03-24 21:24:45 +0000
Commit:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
CommitDate: 2023-03-24 21:24:45 +0000

    cad/kicad: fix failure in certain modes (e.g. exports)

    The use of dynamic_case here results in failures (error exits)
    and seems to be actually wrong, which is exposed by our clang
    (mabe gcc handles this just fine?

    PR:             270273
    Reported By:    Pero Orsolic

 cad/kicad/Makefile                                 |   1 +
 .../patch-job_use_dynamic_cast_for_updating (new)  | 171 +++++++++++++++++++++
 2 files changed, 172 insertions(+)
Comment 2 Christoph Moench-Tegeder freebsd_committer freebsd_triage 2023-03-24 21:31:18 UTC
That goes way deeper, there were quite a few more instances of problematic casting. There we go, feels fine for now.
Comment 3 Ed Maste freebsd_committer freebsd_triage 2023-10-15 16:21:30 UTC
Did this issue / patch ever make it upstream?