Bug 673085 - Changing return value is not reflected on retstr
Changing return value is not reflected on retstr
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: systemtap (Show other bugs)
rawhide
Unspecified Linux
unspecified Severity low
: ---
: ---
Assigned To: Frank Ch. Eigler
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-27 06:38 EST by Miroslav Franc
Modified: 2016-01-31 21:27 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-01-27 09:46:36 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
mfranc: needinfo+


Attachments (Terms of Use)
reproducer (293 bytes, application/octet-stream)
2011-01-27 06:38 EST, Miroslav Franc
no flags Details

  None (edit)
Description Miroslav Franc 2011-01-27 06:38:04 EST
Created attachment 475585 [details]
reproducer

Description of problem:
When modifying return value of syscall, the retstr doesn't reflect the change.

Version-Release number of selected component (if applicable):
systemtap-1.4-3.fc15.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Paste the following script to write.stp
probe begin {
        printf("%6s -> %6s | %7s\n", "name", "retstr", "$return");
}
probe syscall.write.return {
    if (pid() == target()) {
        printf("%6s -> %6s | %7d\n", name, retstr, $return);
        $return = -1;
        printf("%6s -> %6s | %7d\n", name, retstr, $return);
    }
}
2. Run `stap -g ./write.stp -c /bin/echo'
3. Output is something like:
/bin/echo: write error
  name -> retstr | $return
 write ->      1 |       1
 write ->      1 |      -1
 write ->     11 |      11
 write ->     11 |      -1
 write ->     11 |      11
 write ->     11 |      -1
 write ->      1 |       1
 write ->      1 |      -1

  
Actual results:
Value of retstr is not changed.

Expected results:
Value of retstr reflects value of $return

Additional info:
The same thing is at least on FC14, RHEL5 and RHEL6.
Comment 1 Frank Ch. Eigler 2011-01-27 08:17:49 EST
This is expected behaviour.  Script-level variables such as "retstr" that
are set by script aliases such as "syscall.write.return" are only *initialized*
by those aliases based upon any underlying $variables.  They do not constitute
some sort of macro that reevaluates the $variables every time.

Can you find some documentation that is ambiguous on this point?  We can
extend that.
Comment 2 Miroslav Franc 2011-01-27 09:34:18 EST
Ok, sorry, my bad. I should have looked at the source code. But it wouldn't hurt to explicitly state the info above as warning in stapprobes(3stap) manpage, end of SYSCALL section. Feel free to close this.
Comment 3 Frank Ch. Eigler 2011-01-27 09:46:36 EST
We'll add some documentation about this in a future version of systemtap.

Note You need to log in before you can comment on or make changes to this bug.