public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [Bug translator/21173] New: odd translator behavior with overloaded functions
@ 2017-02-16 19:01 dsmith at redhat dot com
  2017-02-20 18:37 ` [Bug translator/21173] " dsmith at redhat dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dsmith at redhat dot com @ 2017-02-16 19:01 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=21173

            Bug ID: 21173
           Summary: odd translator behavior with overloaded functions
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: translator
          Assignee: systemtap at sourceware dot org
          Reporter: dsmith at redhat dot com
  Target Milestone: ---

Since bug #18431, the translator supports overloaded functions (2 functions
with the same name but different parameters). However, in certain situations,
this isn't acting correctly.

Here's a test script:

====
function foo:long(a:long, b:long)
{
        return (a + b)
}

function foo:string(a:long, b:string, c:long)
{
        return sprintf("%s %d", b, a + c)
}

probe begin
{
        println(__inode_vfsmount(1))
        println(foo(1, 2, 3))
}
====

====
stap --compatible=2.9 -vp4 ../src/test.stp
Pass 1: parsed user script and 465 library scripts using
135824virt/44664res/7380shr/37236data kb, in 240usr/50sys/293real ms.
WARNING: Eliding unused function 'foo': identifier 'foo' at
../src/test.stp:1:10
 source: function foo:long(a:long, b:long)
                  ^
semantic error: unknown type in dereference: operator '&' at
/usr/local/share/systemtap/tapset/linux/dentry.stp:93:24
        source:                 head = &sb->s_mounts
                                       ^

Pass 2: analyzed script: 1 probe, 8 functions, 3 embeds, 0 globals using
285440virt/195264res/8548shr/186852data kb, in 1830usr/320sys/2167real ms.
Pass 2: analysis failed.  [man error::pass2]
=====

There are at least 3 problems with that translator output:

- It doesn't warn/error on the fact the 'foo' function variants has 2 different
return values.
- Somehow this causes @cast() type errors to appear elsewhere.
- It doesn't realize that there is no overload that takes 3 longs.

It is possible the translator found the error earlier, but its message was
suppressed and it incidentally resulted in shortcuting some other processing
leading the @cast() or whatever to never be attempted.

Note that if the 'foo' function call is fixed to call either function
correctly, the script compiles just fine without any @cast-type errors. Also
note that I found this while debugging a systemtap.stress/tapset_functions.exp
failure.

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug translator/21173] odd translator behavior with overloaded functions
  2017-02-16 19:01 [Bug translator/21173] New: odd translator behavior with overloaded functions dsmith at redhat dot com
@ 2017-02-20 18:37 ` dsmith at redhat dot com
  2017-02-20 18:41 ` dsmith at redhat dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dsmith at redhat dot com @ 2017-02-20 18:37 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=21173

--- Comment #1 from David Smith <dsmith at redhat dot com> ---
I did some investigation and this bug doesn't appear to be related to the
'--compatible=2.9' option. I edited the tapset/linux/dentry.stp file, removed
and 'private' keyword from the __inode_vfsmount() function, and I get the same
error when running stap without the '--comatible=2.9" option.

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug translator/21173] odd translator behavior with overloaded functions
  2017-02-16 19:01 [Bug translator/21173] New: odd translator behavior with overloaded functions dsmith at redhat dot com
  2017-02-20 18:37 ` [Bug translator/21173] " dsmith at redhat dot com
@ 2017-02-20 18:41 ` dsmith at redhat dot com
  2017-02-20 21:16 ` dsmith at redhat dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dsmith at redhat dot com @ 2017-02-20 18:41 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=21173

--- Comment #2 from David Smith <dsmith at redhat dot com> ---
If I comment out the call to __inode_vfsmount(), I get the expected error about
a type mismatch:

====
# cat ../src/test.stp
function foo:long(a:long, b:long)
{
        return (a + b)
}

function foo:string(a:long, b:string, c:long)
{
        return sprintf("%s %d", b, a + c)
}

probe begin
{
#       println(__inode_vfsmount(1))
        println(foo(1, 2, 3))
}
# stap -p2 ../src/test.stp
WARNING: Eliding unused function 'foo': identifier 'foo' at
../src/test.stp:1:10
 source: function foo:long(a:long, b:long)
                  ^
semantic error: type mismatch: expected long but found string: number '2' at
:14:17
        source:         println(foo(1, 2, 3))
                                       ^

Pass 2: analysis failed.  [man error::pass2]
====

If I comment out the call to foo(), the script gets passes the semantic pass
with no problems (other than warning about unused function 'foo').

====
# cat ../src/test.stp
function foo:long(a:long, b:long)
{
        return (a + b)
}

function foo:string(a:long, b:string, c:long)
{
        return sprintf("%s %d", b, a + c)
}

probe begin
{
        println(__inode_vfsmount(1))
#       println(foo(1, 2, 3))
}
# stap -p2 ../src/test.stp > /dev/null
WARNING: Eliding unused function 'foo': identifier 'foo' at
../src/test.stp:1:10
 source: function foo:long(a:long, b:long)
                  ^
Number of similar warning messages suppressed: 1.
Rerun with -v to see them.
====

Somehow it is the combination of the two that causes the odd behavior.

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug translator/21173] odd translator behavior with overloaded functions
  2017-02-16 19:01 [Bug translator/21173] New: odd translator behavior with overloaded functions dsmith at redhat dot com
  2017-02-20 18:37 ` [Bug translator/21173] " dsmith at redhat dot com
  2017-02-20 18:41 ` dsmith at redhat dot com
@ 2017-02-20 21:16 ` dsmith at redhat dot com
  2017-02-20 22:47 ` dsmith at redhat dot com
  2020-11-14 18:43 ` fche at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: dsmith at redhat dot com @ 2017-02-20 21:16 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=21173

--- Comment #3 from David Smith <dsmith at redhat dot com> ---
It looks like an overloaded function doesn't have to be involved, just a
function call with the right number of arguments but the wrong types:

====
# cat ../src/test.stp
#function foo:long(a:long, b:long)
#{
#       return (a + b)
#}

function foo:string(a:long, b:string, c:long)
{
        return sprintf("%s %d", b, a + c)
}

probe begin
{
        println(__inode_vfsmount(1))
        println(foo(1, 2, 3))
}
# stap -p2 ../src/test.stp
semantic error: unknown type in dereference: operator '&' at
/usr/local/share/systemtap/tapset/linux/dentry.stp:93:24
        source:                 head = &sb->s_mounts
                                       ^

Pass 2: analysis failed.  [man error::pass2]
====

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug translator/21173] odd translator behavior with overloaded functions
  2017-02-16 19:01 [Bug translator/21173] New: odd translator behavior with overloaded functions dsmith at redhat dot com
                   ` (2 preceding siblings ...)
  2017-02-20 21:16 ` dsmith at redhat dot com
@ 2017-02-20 22:47 ` dsmith at redhat dot com
  2020-11-14 18:43 ` fche at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: dsmith at redhat dot com @ 2017-02-20 22:47 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=21173

--- Comment #4 from David Smith <dsmith at redhat dot com> ---
A 'git bisect' shows this was introduced by commit 6540f55, part of the fix for
bug #18455.

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug translator/21173] odd translator behavior with overloaded functions
  2017-02-16 19:01 [Bug translator/21173] New: odd translator behavior with overloaded functions dsmith at redhat dot com
                   ` (3 preceding siblings ...)
  2017-02-20 22:47 ` dsmith at redhat dot com
@ 2020-11-14 18:43 ` fche at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: fche at redhat dot com @ 2020-11-14 18:43 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=21173

Frank Ch. Eigler <fche at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WORKSFORME
                 CC|                            |fche at redhat dot com
             Status|NEW                         |RESOLVED

--- Comment #5 from Frank Ch. Eigler <fche at redhat dot com> ---
stap 4.3+ish reports the errors correctly:

% stap --compatible=2.9 -p4 -e [...]
semantic error: unknown type in dereference: operator '&' at
/usr/share/systemtap/tapset/linux/dentry.stp:93:24
        source:                 head = &sb->s_mounts
                                       ^

semantic error: type mismatch: expected long but found string: number '2' at
<input>:15:17
        source:         println(foo(1, 2, 3))
                                       ^

Pass 2: analysis failed.  [man error::pass2]

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-14 18:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-16 19:01 [Bug translator/21173] New: odd translator behavior with overloaded functions dsmith at redhat dot com
2017-02-20 18:37 ` [Bug translator/21173] " dsmith at redhat dot com
2017-02-20 18:41 ` dsmith at redhat dot com
2017-02-20 21:16 ` dsmith at redhat dot com
2017-02-20 22:47 ` dsmith at redhat dot com
2020-11-14 18:43 ` fche at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).