OS-7663: ctf_dwarf_convert_type() relies on un-initialized id

Details

Issue Type:Bug
Priority:5 - Low
Status:Resolved
Created at:2019-03-14T13:16:41.172Z
Updated at:2019-05-03T13:27:56.341Z

People

Created by:Former user
Reported by:Former user
Assigned to:Former user

Resolution

Fixed: A fix for this issue is checked into the tree and tested.
(Resolution Date: 2019-04-02T10:36:12.189Z)

Fix Versions

2019-04-11 Pete Hornberger (Release Date: 2019-04-11)

Description

A ctfconvert of a pkgsrc libjvm.so fails with EINVAL. This is not a great surprise, since it's full of C++, but I took a look as to why, and found the following:

We are trying to create a pointer to a class. That is:

ctf_dwarf_convert_type(tag == DW_TAG_pointer_type)
ctf_dwarf_create_reference()
ctf_dwarf_convert_type(tag == DW_TAG_class_type)

class_type is ignored in the enumeration, and we return 0. But in this case, we also never set *idp. And we have:

1494 static int                                                                       
1495 ctf_dwarf_create_reference(ctf_cu_t *cup, Dwarf_Die die, ctf_id_t *idp,          
1496     int kind, int isroot)                                                        
1497 {                                                                                
1498         int ret;                                                                 
1499         ctf_id_t id;                                                             
...
1541         if ((*idp = ctf_add_reftype(cup->cu_ctfp, isroot, name, id, kind)) ==    
1542             CTF_ERR) {                                                           

"Luckily", this ends up as < 0 in my build, and we then error out with EINVAL. But we could equally charge on with an ID that happens to be valid. We should explicitly initialize id in this case to CTF_ERR.

Comments

Comment by Jira Bot
Created at 2019-04-02T10:29:29.121Z

illumos-joyent commit 495dfd0ac49c1326af24c839ba967d1e8264782d (branch master, by John Levon)

OS-6428 bad free in ctf_dwarf_init_die
OS-6486 ctfconvert -i never converts
OS-6488 ctfconvert should handle empty dies
OS-6505 Improve ctfconvert error messages
OS-7639 ctfconvert -i option is mis-handled
OS-7663 ctf_dwarf_convert_type() relies on un-initialized id
OS-7688 shouldn't build gcore.c as part of kmdb
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>