Bug 673085 - Changing return value is not reflected on retstr
Summary: Changing return value is not reflected on retstr
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: systemtap
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Frank Ch. Eigler
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-01-27 11:38 UTC by Miroslav Franc
Modified: 2016-02-01 02:27 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-01-27 14:46:36 UTC
Type: ---
Embargoed:
mfranc: needinfo+


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

Description Miroslav Franc 2011-01-27 11:38:04 UTC
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 13:17:49 UTC
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 14:34:18 UTC
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 14:46:36 UTC
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.