On 11/06/2013 08:55 PM, Dr. David Alan Gilbert wrote:
> Hi,
>   'trinity' generated an io_submit call with a ludicrous large
> 'nr' of requests, the result being strace sat there just printing out
> {...}, for nearly ever since the data didn't exist.
> 
>   Is the right thing to 'break' rather than 'continue' if either
> of the umove calls fail?     The alternative way is to break 
> if the iocbs read fails but allow individualy broken iocb reads.
> I'm not sure which is more sane - you could have a real call
> that fails for another reason before hitting the bad iocb.

Please try attached patch.

diff -d -urpN strace.2/desc.c strace.3/desc.c
--- strace.2/desc.c	2013-11-08 11:55:37.631529105 +0100
+++ strace.3/desc.c	2013-11-08 13:11:42.652327266 +0100
@@ -894,29 +894,30 @@ print_common_flags(struct iocb *iocb)
 int
 sys_io_submit(struct tcb *tcp)
 {
-	long nr;
 	if (entering(tcp)) {
-		tprintf("%lu, %ld, ", tcp->u_arg[0], tcp->u_arg[1]);
-		nr = tcp->u_arg[1];
-		/* and if nr is negative? */
-		if (nr == 0)
-			tprints("{}");
-		else {
 #ifdef HAVE_LIBAIO_H
+		long nr = tcp->u_arg[1];
+		/* if nr <= 0, we end up printing just "{}" */
+		tprintf("%lu, %ld, {", tcp->u_arg[0], tcp->u_arg[1]);
+		{
 			long i;
-			struct iocb *iocbp, **iocbs = (void *)tcp->u_arg[2];
+			struct iocb **iocbs = (void *)tcp->u_arg[2];
 
 			for (i = 0; i < nr; i++, iocbs++) {
 				enum iocb_sub sub;
+				struct iocb *iocbp;
 				struct iocb iocb;
-				if (i == 0)
-					tprints("{");
-				else
+				if (i)
 					tprints(", ");
 
-				if (umove(tcp, (unsigned long)iocbs, &iocbp) ||
-				    umove(tcp, (unsigned long)iocbp, &iocb)) {
-					tprints("{...}");
+				if (umove(tcp, (unsigned long)iocbs, &iocbp)) {
+					tprintf("%#lx", (unsigned long)iocbs);
+					/* No point in trying to read iocbs+1 etc */
+					/* (nr can be ridiculously large): */
+					break;
+				}
+				if (umove(tcp, (unsigned long)iocbp, &iocb)) {
+					tprintf("{%#lx}", (unsigned long)iocbp);
 					continue;
 				}
 				tprints("{");
@@ -964,13 +965,12 @@ sys_io_submit(struct tcb *tcp)
 				}
 				tprints("}");
 			}
-			if (i)
-				tprints("}");
+		}
+		tprints("}");
 #else
 #warning "libaio.h is not available => no io_submit decoding"
-			tprintf("%#lx", tcp->u_arg[2]);
+		tprintf("%lu, %ld, %#lx", tcp->u_arg[0], tcp->u_arg[1], tcp->u_arg[2]);
 #endif
-		}
 	}
 	return 0;
 }
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to