Bug 1266572

Summary: restraint client segmentation fault in copy_job_as_template
Product: [Retired] Restraint Reporter: Jeff Bastian <jbastian>
Component: generalAssignee: Artem Savkov <asavkov>
Status: CLOSED NEXTRELEASE QA Contact: tools-bugs <tools-bugs>
Severity: high Docs Contact:
Priority: medium    
Version: 0.1.21CC: asavkov, beaker-dev-list, bpeck, dcallagh, mjia, rjoost
Target Milestone: 0.1.23Keywords: Patch
Target Release: ---   
Hardware: aarch64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-01-22 14:37:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jeff Bastian 2015-09-25 16:51:54 UTC
Description of problem:
The restraint client crashes with a segfault when I try to run a standalone job.

[root@centipede keyutils]# restraint --host=1=localhost --job=/root/keyutils/key
utils-testsuite.xml
No result
Using ./keyutils-testsuite.02 for job run
Segmentation fault (core dumped)

A backtrace from the core file:

(gdb) bt
#0  0x000000000040a670 in copy_job_as_template (
    job=0x11b79820 "/root/keyutils/keyutils-testsuite.xml", 
    app_data=0x11b6ad20) at client.c:1055
#1  0x000000000040b44c in main (argc=1, argv=0x3fff1412588) at client.c:1449


Version-Release number of selected component (if applicable):
restraint-0.1.21-3.aa7a.aarch64

How reproducible:
always

Steps to Reproduce:
1. restraint --host=1=localhost --job=job.xml

Actual results:
segfault

Expected results:
job runs

Additional info:

Comment 1 Bill Peck 2015-09-25 16:56:07 UTC
please provide the xml used as well.

thanks

Comment 2 Jeff Bastian 2015-09-25 16:59:04 UTC
recipe_nodes in client.c:1055 is a null pointer:

Program terminated with signal 11, Segmentation fault.
#0  0x000000000040a670 in copy_job_as_template (
    job=0x11b79820 "/root/keyutils/keyutils-testsuite.xml", 
    app_data=0x11b6ad20) at client.c:1055
1055        for (guint i = 0; i < recipe_nodes->nodesetval->nodeNr; i++) {
Missing separate debuginfos, use: debuginfo-install glibc-2.17-105.el7.aarch64
(gdb) print i
$1 = 0
(gdb) print recipe_nodes
$2 = (xmlXPathObjectPtr) 0x0
(gdb) print recipe_nodes->nodesetval
Cannot access memory at address 0x8



The job xml is simple enough:

<job>
  <recipe>
    <recipeSet>
      <task name="/kernel/keyutils/testsuite">
        <fetch url="git://example.com/keyutils-tests.git?master#testsuite"/>
      </task>
    </recipeSet>
  </recipe>
</job>

Comment 3 Jeff Bastian 2015-09-25 17:01:44 UTC
(In reply to Jeff Bastian from comment #2)
> The job xml is simple enough:
> 
> <job>
>   <recipe>
>     <recipeSet>

D'oh!  That's my mistake: I had recipe and recipeSet inverted...  It works fine once I fixed it.

Comment 4 Bill Peck 2015-09-25 17:02:43 UTC
still shouldn't segfault.  leave this open and I'll fix it.

Thanks Jeff

Comment 5 Jeff Bastian 2015-09-25 17:06:22 UTC
If it helps, I found my problem with xmllint:

$ xmllint --noout \
   --relaxng /usr/lib/python2.7/site-packages/bkr/common/schema/beaker-job.rng \
   keyutils-testsuite.xml
keyutils-testsuite.xml:1: element job: Relax-NG validity error : Expecting an element recipeSet, got nothing
keyutils-testsuite.xml:2: element recipe: Relax-NG validity error : Invalid sequence in interleave
keyutils-testsuite.xml:2: element recipe: Relax-NG validity error : Element job failed to validate content
keyutils-testsuite.xml fails to validate

Comment 6 Artem Savkov 2016-01-18 12:35:08 UTC
https://gerrit.beaker-project.org/#/c/4595/

Comment 7 Artem Savkov 2016-01-22 14:37:02 UTC
Merged, there is also this change https://gerrit.beaker-project.org/#/c/4607/2 that adds job xml validation to restraint.