pcb

Crash when loading vendor resource from an action string.

Bug #1206882 reported by Traumflug
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pcb
Fix Released
Undecided
Unassigned

Bug Description

This bash script lets pcb die:

# Apply vendor drill mapping.
# See http://pcb.geda-project.org/pcb-cvs/pcb.html#Vendor-drill-mapping
echo "units = mm" > vendor.res
echo "drillmap = {" >> vendor.res
echo " round = nearest" >> vendor.res
echo " 0.75" >> vendor.res
echo " 1.0" >> vendor.res
echo "}" >> vendor.res

"${PCB}" --action-string "
  LoadFrom(Layout, input.pcb)
  LoadVendorFrom(vendor.res)
  "

${PCB} points to a binary compiled from git HEAD as of 31/07/2013. ${PCB_PATHS} and ${PCB_CMDS} are set up just like it's done in pcbtest.sh coming with the sources.

Loading the same resource file from the menu works as expected. The backtrace hints on a conflict between parsing the vendor resource file and parsing the menu resource file:

(gdb) bt
#0 0x00007ffff50f7bbd in getc () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x000000000048d5c5 in res_parse_getchars (buf=0x87e9c0 "", max_size=<optimized out>) at res_parse.y:85
#2 0x000000000048ea4e in yy_get_next_buffer () at res_lex.c:1111
#3 reslex () at res_lex.c:953
#4 0x000000000048dccc in resparse () at res_parse.c:1323
#5 0x000000000048df96 in resource_parse (filename=filename@entry=0x0, strings=strings@entry=0x771280 <gpcb_menu_default>)
    at res_parse.y:132
#6 0x00000000004cde27 in ghid_load_menus () at hid/gtk/gui-top-window.c:2105
#7 ghid_build_pcb_top_window () at hid/gtk/gui-top-window.c:1292
#8 ghid_create_pcb_widgets () at hid/gtk/gui-top-window.c:1576
#9 0x00000000004cefa6 in ghid_do_export (options=<optimized out>) at hid/gtk/gui-top-window.c:1801
#10 0x0000000000426a87 in main (argc=1, argv=0x7fffffffe008) at main.c:2072

Tags: crash
Revision history for this message
gpleda.org commit robot (gpleda-launchpad-robot) wrote :

A commit was made which affects this bug
git master commit 32941c402015bcdcee2b55cb4f75ace616d8f518
http://git.geda-project.org/pcb/commit/?id=32941c402015bcdcee2b55cb4f75ace616d8f518

commit 32941c402015bcdcee2b55cb4f75ace616d8f518
Author: Markus Hitter <email address hidden>
Commit: Markus Hitter <email address hidden>

    src/res_parse.y: handle resource globals gracefully.

    Likely, res_file is used somewhere to check something. In case a
    resource file was loaded earlier, but the current parsing is from
    a string, res_file is still != NULL, so this check would mislead.

    Solution: Clear res_file and res_filename as soon as the file
              behind it gets closed.

    Also replace a number of zeros with the more appropriate NULL.

    Affects-bug: lp-1206882

Traumflug (mah-jump-ing)
Changed in pcb:
status: New → Fix Committed
Revision history for this message
gpleda.org commit robot (gpleda-launchpad-robot) wrote :

A commit which affected this bug was removed from the repository
git master commit 32941c402015bcdcee2b55cb4f75ace616d8f518
http://git.geda-project.org/pcb/commit/?id=32941c402015bcdcee2b55cb4f75ace616d8f518

commit 32941c402015bcdcee2b55cb4f75ace616d8f518
Author: Markus Hitter <email address hidden>
Commit: Markus Hitter <email address hidden>

    src/res_parse.y: handle resource globals gracefully.

    Likely, res_file is used somewhere to check something. In case a
    resource file was loaded earlier, but the current parsing is from
    a string, res_file is still != NULL, so this check would mislead.

    Solution: Clear res_file and res_filename as soon as the file
              behind it gets closed.

    Also replace a number of zeros with the more appropriate NULL.

    Affects-bug: lp-1206882

Revision history for this message
gpleda.org commit robot (gpleda-launchpad-robot) wrote :

A commit was made which affects this bug
git master commit 772f77db0d384295e48473ee7da8127071cea72f
http://git.geda-project.org/pcb/commit/?id=772f77db0d384295e48473ee7da8127071cea72f

commit 772f77db0d384295e48473ee7da8127071cea72f
Author: Markus Hitter <email address hidden>
Commit: Markus Hitter <email address hidden>

    src/res_parse.y: handle resource globals gracefully.

    Likely, res_file is used somewhere to check something. In case a
    resource file was loaded earlier, but the current parsing is from
    a string, res_file is still != NULL, so this check would mislead.

    Solution: Clear res_file and res_filename as soon as the file
              behind it gets closed.

    Also replace a number of zeros with the more appropriate NULL.

    Affects-bug: lp-1206882

Revision history for this message
Traumflug (mah-jump-ing) wrote :

The difference between the first and the last commit is just an indentation fix I amended and force-pushed.

Changed in pcb:
status: Fix Committed → Fix Released
Changed in pcb:
milestone: none → pcb-20140316
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.