Skip to content

RBA::QSpacerItem: potential use-after-free bug due to Ruby GC #2273

@tskaar

Description

@tskaar

Hi!

When using the IHP PDK and opening up their DRC Options menu I saw a segfault happen at random times, after some trial-and-error I found the culprit to be RBA::QSpacerItem .

The file in question is this: https://github.com/IHP-GmbH/IHP-Open-PDK/blob/dev/ihp-sg13g2/libs.tech/klayout/tech/macros/sg13g2_drc_options.lym

Where the lines of interest are:

    ## --- Basic Settings Tab ---
    @spacer = RBA::QSpacerItem.new(0, 5) # <-- Initialized here
    @basic_tab = RBA::QWidget.new
    @basic_layout_setup = RBA::QFormLayout.new(@basic_tab)
    @basic_layout_setup.setSpacing(15)
    @basic_layout_setup.addRow("Top Cell:", create_combo_box(options['top_cell'], get_top_cell_names))
    @basic_layout_setup.addRow("Run Mode:", create_combo_box(options['run_mode'], ['deep', 'flat']))
    @basic_layout_setup.addRow("DRC Table:", create_combo_box(options['table'] || "main", get_table_files))
    @basic_layout_setup.addRow("Parallel Runs:", create_cores_threads_no(options['parallel_runs']))
    @basic_layout_setup.addItem(@spacer) # <-- Referenced here
    @basic_layout_setup.setSpacing(10)

Removing these two lines, also removes the segfault I've seen happen.

Considering there are multiple other ways of adding vertical space (that doesn't segfault), this is a very minor impact bug, but thought it would be "good to know" in case other people use QSpacerItem

Software

KLayout: v0.30.5
Qt: v6.10.2
Ruby: v3.4.8 +PRISM
Compiler: GCC: (GNU) 15.2.1 20251112
OS: ArchLinux

Additional information

Downstream bug report: IHP-GmbH/IHP-Open-PDK#815
That bug report also includes a video example of the trigger.

GDB backtrace: ihp_drc_options_segfault_backtrace.log


Let me know if you need any more information from me.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions