-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey all,
I've patched (I think) a bunch of flowgraph checking code. (1) error messages were weird -- I got something like "2 expected, 1 given" when the min_ports was 1 and the connected was 0. I think this is because the +1's that I removed were bad. (2) didn't check to see that the min was satisfied if nports > 0 (my block has minports = maxports = 2). (3) didn't check max. But, it doesn't quite work (on r7518 or so, I haven't updated since flowgraph was removed) -- see below. - -Dan - -- I get seg faults when I run this code, and I don't know why. I have a test case that has too few connected ports (min == 2), 1 is connected. I'm using the patched gr_flowgraph.cc with a single debug output added: if (nports < min_ports) { fprintf(stderr, "HI!\n"); fflush(stderr); msg << block << ": insufficient connected " << (check_inputs ? "input ports " : "output ports ") << "(" << min_ports << " needed, " << nports << " connected)"; throw std::runtime_error(msg.str()); } Python segfaults after printing HI! to the console. In GDB, I get: (gdb) cont Continuing. Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 47251368560352 (LWP 20540)] PyErr_Restore (type=0x7230a0, value=0xf793f0, traceback=0x0) at ../Python/errors.c:39 39 ../Python/errors.c: No such file or directory. in ../Python/errors.c (gdb) bt #0 PyErr_Restore (type=0x7230a0, value=0xf793f0, traceback=0x0) at ../Python/errors.c:39 #1 0x0000000000499a1c in PyErr_SetString (exception=0x7230a0, string=<value optimized out>) at ../Python/errors.c:57 #2 0x00002af9910b7639 in SWIG_Python_SetErrorMsg (errtype=0x7230a0, msg=0xf793f0 "\002") at gnuradio_swig_py_runtime.cc:1049 #3 0x00002af9910c98ab in _wrap_top_block_run_unlocked ( args=<value optimized out>) at gnuradio_swig_py_runtime.cc:15958 #4 0x0000000000417e53 in PyObject_Call (func=0x7230a0, arg=0xf793f0, kw=0x0) at ../Objects/abstract.c:1860 #5 0x0000000000486997 in PyEval_EvalFrameEx (f=0xffc7f0, throwflag=<value optimized out>) at ../Python/ceval.c:3844 #6 0x0000000000489d60 in PyEval_EvalCodeEx (co=0x81cdc8, globals=<value optimized out>, locals=<value optimized out>, args=0xffcb48, argcount=1, kws=0xffcb50, kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python/ceval.c:2831 #7 0x0000000000487f32 in PyEval_EvalFrameEx (f=0xffc9c0, throwflag=<value optimized out>) at ../Python/ceval.c:3660 #8 0x0000000000488c3e in PyEval_EvalFrameEx (f=0x7bb950, throwflag=<value optimized out>) at ../Python/ceval.c:3650 #9 0x0000000000489d60 in PyEval_EvalCodeEx (co=0x2af990301828, globals=<value optimized out>, locals=<value optimized out>, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python/ceval.c:2831 #10 0x0000000000489da2 in PyEval_EvalCode (co=0x7230a0, globals=0xf793f0, locals=0x0) at ../Python/ceval.c:494 #11 0x00000000004ab4fe in PyRun_FileExFlags (fp=0x75a010, filename=0x7fff1a829b76 "./dial_tone.py", start=<value optimized out>, globals=0x77d6a0, locals=0x77d6a0, closeit=1, flags=0x7fff1a8280b0) at ../Python/pythonrun.c:1273 #12 0x00000000004ab790 in PyRun_SimpleFileExFlags (fp=0x75a010, filename=0x7fff1a829b76 "./dial_tone.py", closeit=1, flags=0x7fff1a8280b0) at ../Python/pythonrun.c:879 #13 0x0000000000414725 in Py_Main (argc=<value optimized out>, argv=0x7fff1a8281d8) at ../Modules/main.c:523 #14 0x00002af990d5eb44 in __libc_start_main () from /lib/libc.so.6 #15 0x0000000000413c69 in _start () (gdb) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFHv6Kdy9GYuuMoUJ4RAg2IAKDAqxAt+XRCrSLW3ZAlRJBM9ah0QwCgvzBm G1m6GRJZ+jSSUD1opO3gU7I= =Mzf9 -----END PGP SIGNATURE-----
Index: gr_flowgraph.cc =================================================================== --- gr_flowgraph.cc (revision 7791) +++ gr_flowgraph.cc (working copy) @@ -124,7 +124,7 @@ } int max = sig->max_streams(); - if (max >= 0 && port >= max) { + if (max != gr_io_signature::IO_INFINITE && port >= max) { msg << "port number " << port << " exceeds max of "; if (max == 0) msg << "(none)"; @@ -230,18 +230,25 @@ int nports = used_ports.size(); int min_ports = sig->min_streams(); + int max_ports = sig->max_streams(); - if (nports == 0) { - if (min_ports == 0) - return; - else { - msg << block << ": insufficient connected " - << (check_inputs ? "input ports " : "output ports ") - << "(" << min_ports+1 << " needed, " << nports+1 << " connected)"; - throw std::runtime_error(msg.str()); - } + if (nports == 0 && min_ports == 0) + return; + + if (nports < min_ports) { + msg << block << ": insufficient connected " + << (check_inputs ? "input ports " : "output ports ") + << "(" << min_ports << " needed, " << nports << " connected)"; + throw std::runtime_error(msg.str()); } + if (nports > max_ports && max_ports != gr_io_signature::IO_INFINITE) { + msg << block << ": too many connected " + << (check_inputs ? "input ports " : "output ports ") + << "(" << max_ports << " allowed, " << nports << " connected)"; + throw std::runtime_error(msg.str()); + } + if (used_ports[nports-1]+1 != nports) { for (int i = 0; i < nports; i++) { if (used_ports[i] != i) {
_______________________________________________ Patch-gnuradio mailing list Patch-gnuradio@gnu.org http://lists.gnu.org/mailman/listinfo/patch-gnuradio