diff mbox

Best way to inspect the parse tree from Sparse

Message ID CANeU7Qk37J8WTVmzDhzjCbpmJ6cf59LNB6sX6ncRFHP=wvJFQw@mail.gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Christopher Li Aug. 9, 2017, 7:22 p.m. UTC
On Wed, Aug 9, 2017 at 2:47 PM, Dibyendu Majumdar
<mobile@majumdar.org.uk> wrote:
>
> Thread 1 "test-inspect" received signal SIGSEGV, Segmentation fault.
> ast_iter_n_children (tree_model=0x725400, iter=0x0) at ast-model.c:404

Err, iter == NULL.

The function comment said it all. if iter == NULL, should return the
root node's children number.

Can you try the following one line change?
I can only verify it compiles. But I have no way to test it.

I also totally forget how this tree view model works now.
Let's hope that fix it.

Thanks

Chris

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Dibyendu Majumdar Aug. 9, 2017, 7:46 p.m. UTC | #1
Hi Chris,

I am getting a different crash after making the change:

Starting program: /home/dylan/github/linux-sparse/test-inspect parse.c
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffede40700 (LWP 19684)]
[New Thread 0x7fffed63f700 (LWP 19685)]
[New Thread 0x7fffece3e700 (LWP 19686)]

Thread 1 "test-inspect" received signal SIGSEGV, Segmentation fault.
0x00007ffff6ed963b in __GI__IO_default_xsputn (f=0x7fffff7ff590,
    data=0x42aaf3, n=16) at genops.c:422
422    genops.c: No such file or directory.
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christopher Li Aug. 9, 2017, 7:57 p.m. UTC | #2
Can you do a "ldd test-inspect"?

Which version of Ubuntu are you using? I think I need to get one of those to
test it.

Chris

On Wed, Aug 9, 2017 at 3:46 PM, Dibyendu Majumdar
<mobile@majumdar.org.uk> wrote:
> Hi Chris,
>
> I am getting a different crash after making the change:
>
> Starting program: /home/dylan/github/linux-sparse/test-inspect parse.c
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> [New Thread 0x7fffede40700 (LWP 19684)]
> [New Thread 0x7fffed63f700 (LWP 19685)]
> [New Thread 0x7fffece3e700 (LWP 19686)]
>
> Thread 1 "test-inspect" received signal SIGSEGV, Segmentation fault.
> 0x00007ffff6ed963b in __GI__IO_default_xsputn (f=0x7fffff7ff590,
>     data=0x42aaf3, n=16) at genops.c:422
> 422    genops.c: No such file or directory.
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dibyendu Majumdar Aug. 9, 2017, 8:03 p.m. UTC | #3
On 9 August 2017 at 12:57, Christopher Li <sparse@chrisli.org> wrote:
> Can you do a "ldd test-inspect"?
>
> Which version of Ubuntu are you using? I think I need to get one of those to
> test it.
>

I am using ubuntu 16.04 LTS.

Here is the output from ldd:

ldd ./test-inspect
    linux-vdso.so.1 =>  (0x00007ffd449d2000)
    libgtk-x11-2.0.so.0 =>
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 (0x00007fbdf76d5000)
    libgobject-2.0.so.0 =>
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007fbdf7482000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0
(0x00007fbdf7170000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbdf6da6000)
    libgdk-x11-2.0.so.0 =>
/usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0 (0x00007fbdf6af1000)
    libgmodule-2.0.so.0 =>
/usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007fbdf68ec000)
    libpangocairo-1.0.so.0 =>
/usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007fbdf66df000)
    libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fbdf63a5000)
    libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3
(0x00007fbdf619e000)
    libatk-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0
(0x00007fbdf5f79000)
    libcairo.so.2 => /usr/lib/x86_64-linux-gnu/libcairo.so.2
(0x00007fbdf5c65000)
    libgdk_pixbuf-2.0.so.0 =>
/usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007fbdf5a42000)
    libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
(0x00007fbdf56ba000)
    libpangoft2-1.0.so.0 =>
/usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007fbdf54a4000)
    libpango-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
(0x00007fbdf5257000)
    libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1
(0x00007fbdf5014000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbdf4d0b000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007fbdf4aed000)
    libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fbdf48e5000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fbdf4674000)
    /lib64/ld-linux-x86-64.so.2 (0x000055ca0ccca000)
    libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1
(0x00007fbdf446a000)
    libXinerama.so.1 => /usr/lib/x86_64-linux-gnu/libXinerama.so.1
(0x00007fbdf4267000)
    libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007fbdf4057000)
    libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2
(0x00007fbdf3e4b000)
    libXcursor.so.1 => /usr/lib/x86_64-linux-gnu/libXcursor.so.1
(0x00007fbdf3c41000)
    libXcomposite.so.1 => /usr/lib/x86_64-linux-gnu/libXcomposite.so.1
(0x00007fbdf3a3e000)
    libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1
(0x00007fbdf383a000)
    libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fbdf3628000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fbdf3423000)
    libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6
(0x00007fbdf3179000)
    libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fbdf2f57000)
    libpixman-1.so.0 => /usr/lib/x86_64-linux-gnu/libpixman-1.so.0
(0x00007fbdf2cae000)
    libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007fbdf2a89000)
    libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0
(0x00007fbdf2885000)
    libxcb-render.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render.so.0
(0x00007fbdf267a000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fbdf2460000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fbdf2258000)
    libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1
(0x00007fbdf2035000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fbdf1e1a000)
    libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0
(0x00007fbdf1bbc000)
    libthai.so.0 => /usr/lib/x86_64-linux-gnu/libthai.so.0 (0x00007fbdf19b2000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fbdf1789000)
    libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fbdf1584000)
    libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6
(0x00007fbdf137e000)
    libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3
(0x00007fbdf1158000)
    libdatrie.so.1 => /usr/lib/x86_64-linux-gnu/libdatrie.so.1
(0x00007fbdf0f50000)
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christopher Li Aug. 9, 2017, 8:21 p.m. UTC | #4
On Wed, Aug 9, 2017 at 4:03 PM, Dibyendu Majumdar
<mobile@majumdar.org.uk> wrote:
> On 9 August 2017 at 12:57, Christopher Li <sparse@chrisli.org> wrote:
>> Can you do a "ldd test-inspect"?
>>
>> Which version of Ubuntu are you using? I think I need to get one of those to
>> test it.
>>
>
> I am using ubuntu 16.04 LTS.
>
> Here is the output from ldd:
>
> ldd ./test-inspect
>     linux-vdso.so.1 =>  (0x00007ffd449d2000)
>     libgtk-x11-2.0.so.0 =>
> /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 (0x00007fbdf76d5000)
>     libgobject-2.0.so.0 =>

Thanks.

Your GTK lib looks good.

I will get a ubuntu 16.04 to reproduce it.

Thanks

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/ast-model.c b/ast-model.c
index 704c487..cbfdc1f 100644
--- a/ast-model.c
+++ b/ast-model.c
@@ -401,7 +401,7 @@  static gint
 ast_iter_n_children (GtkTreeModel *tree_model,
                           GtkTreeIter  *iter)
 {
-       AstNode  *node = iter->user_data;
+       AstNode  *node = iter ? iter->user_data : AST_NODE(tree_model);

        inspect_child_node(node);
        return node->childnodes->len;