public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [Bug runtime/11325] New: Spaces and exclamation marks invalid as module arguments
@ 2010-02-25 21:11 chwang at redhat dot com
  2010-03-18  8:10 ` [Bug runtime/11325] " wenji dot huang at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: chwang at redhat dot com @ 2010-02-25 21:11 UTC (permalink / raw)
  To: systemtap

Examples:

$ stap -p4 -m mod1 -e 'global var1="foo";  probe  begin{printf("%s\n", var1);
exit()}'

$ staprun mod1.ko var1="hello!"
bash: !": event not found

$ staprun mod1.ko var1="hello world"
Error inserting module '/notnfs/chwang/systemtap/mod1.ko': Unknown symbol in module
Retrying, after attempted removal of module mod1 (rc -1)
Error inserting module '/notnfs/chwang/systemtap/mod1.ko': Unknown symbol in module


Also, escaping the exclamation mark results in the escape character also being
printed:

$ staprun mod1.ko var1="hello\!"
hello\!

-- 
           Summary: Spaces and exclamation marks invalid as module arguments
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: minor
          Priority: P2
         Component: runtime
        AssignedTo: systemtap at sources dot redhat dot com
        ReportedBy: chwang at redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=11325

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

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

* [Bug runtime/11325] Spaces and exclamation marks invalid as module arguments
  2010-02-25 21:11 [Bug runtime/11325] New: Spaces and exclamation marks invalid as module arguments chwang at redhat dot com
@ 2010-03-18  8:10 ` wenji dot huang at oracle dot com
  2010-03-18 15:10 ` fche at redhat dot com
  2010-03-19  2:19 ` wenji dot huang at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: wenji dot huang at oracle dot com @ 2010-03-18  8:10 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From wenji dot huang at oracle dot com  2010-03-18 08:10 -------
(In reply to comment #0)
> Examples:
> 
> $ stap -p4 -m mod1 -e 'global var1="foo";  probe  begin{printf("%s\n", var1);
> exit()}'
> 
> $ staprun mod1.ko var1="hello!"
> bash: !": event not found
...
> Also, escaping the exclamation mark results in the escape character also being
> printed:
> $ staprun mod1.ko var1="hello\!"
> hello\!

Same results as bash, 
$ echo "foo!"
-bash: !": event not found

$ echo "foo\!"
foo\!

> $ staprun mod1.ko var1="hello world"
> Error inserting module '/notnfs/chwang/systemtap/mod1.ko': Unknown symbol in
module
> Retrying, after attempted removal of module mod1 (rc -1)
> Error inserting module '/notnfs/chwang/systemtap/mod1.ko': Unknown symbol in
module

Seems a bug, maybe fixed by the following patch.

$staprun  mod1.ko var1="hello foo" 
hello foo

diff --git a/runtime/staprun/staprun_funcs.c b/runtime/staprun/staprun_funcs.c
index db58cd4..2f8076a 100644
--- a/runtime/staprun/staprun_funcs.c
+++ b/runtime/staprun/staprun_funcs.c
@@ -68,13 +68,14 @@ int insert_module(
                return -1;
        }
        for (i = 0; options[i] != NULL; i++) {
-               opts = realloc(opts, strlen(opts) + strlen(options[i]) + 2);
+               opts = realloc(opts, strlen(opts) + strlen(options[i]) + 4);
                if (opts == NULL) {
                        _perr("[re]allocating memory failed");
                        return -1;
                }
-               strcat(opts, " ");
+               strcat(opts, " \"");
                strcat(opts, options[i]);
+               strcat(opts, "\"");
        }
        dbug(2, "module options: %s\n", opts);

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11325

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

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

* [Bug runtime/11325] Spaces and exclamation marks invalid as module arguments
  2010-02-25 21:11 [Bug runtime/11325] New: Spaces and exclamation marks invalid as module arguments chwang at redhat dot com
  2010-03-18  8:10 ` [Bug runtime/11325] " wenji dot huang at oracle dot com
@ 2010-03-18 15:10 ` fche at redhat dot com
  2010-03-19  2:19 ` wenji dot huang at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: fche at redhat dot com @ 2010-03-18 15:10 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From fche at redhat dot com  2010-03-18 15:10 -------
I suspect we'll need some additional quoting to do the job right
(consider options[i] itself containing \" or other special chars.)


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11325

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

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

* [Bug runtime/11325] Spaces and exclamation marks invalid as module arguments
  2010-02-25 21:11 [Bug runtime/11325] New: Spaces and exclamation marks invalid as module arguments chwang at redhat dot com
  2010-03-18  8:10 ` [Bug runtime/11325] " wenji dot huang at oracle dot com
  2010-03-18 15:10 ` fche at redhat dot com
@ 2010-03-19  2:19 ` wenji dot huang at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: wenji dot huang at oracle dot com @ 2010-03-19  2:19 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From wenji dot huang at oracle dot com  2010-03-19 02:19 -------
(In reply to comment #2)
> I suspect we'll need some additional quoting to do the job right
> (consider options[i] itself containing \" or other special chars.)
> 

Same idea occurred to me. But I found the track of parameter is 
argv -> modoptions -> options

The quoting will be removed in argv. For example, 
$staprun  mod1.ko var1="hello foo" 

argv[N] : var1=hello foo
modoptions: var1=hello foo
options: var1=hello foo

So init_module regards foo as parameter and reports error.
Guess we need reorganize the passing way of parameter to 
completely resolve the problem. Seems the above patch can
be temporary workaround.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11325

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

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

end of thread, other threads:[~2010-03-19  2:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-25 21:11 [Bug runtime/11325] New: Spaces and exclamation marks invalid as module arguments chwang at redhat dot com
2010-03-18  8:10 ` [Bug runtime/11325] " wenji dot huang at oracle dot com
2010-03-18 15:10 ` fche at redhat dot com
2010-03-19  2:19 ` wenji dot huang at oracle 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).