1

I have a "black box" question about an error I get when I run a discrete event simulation for about a minute. Everything works fine, and it completes successfully, but the system prints the following message once at some point during the simulation:

Error (202): Command token too long

I've never seen anything like it. I wonder what "command" it's referring to. Perhaps it's system("...") call that I make several times in the program in order to plot and visualize the data it generates.

I'm sorry I can't provide any code as I'm not sure where the error is coming from. Is there an efficient way to discover at which point the system generates this message? Or in any case, have you encountered such an error in your own C++ programming experience, and thus suggest where it could possibly be coming from?

I'm using Ubuntu 11.04 and compiling with GCC. The error appears at run-time during the simulation for simulations that are especially long (30+ seconds), and doesn't appear in shorter cases. I should emphasize that the "error" doesn't stop the execution of the code and doesn't actually cause any visible errors in the visual output of the simulation data.

Alan Turing
  • 12,223
  • 16
  • 74
  • 116
  • 1
    Platform/OS? How are you presented the error, in a terminal? – orlp Jul 21 '11 at 21:01
  • I updated the question with OS information. Thanks. – Alan Turing Jul 21 '11 at 21:30
  • I think that you need to provide more details on what your blackbox simulator does -- like does it read a command file which is passed with lex/yacc/bison or something similar. – Soren Jul 22 '11 at 03:47
  • It's an ad hoc wireless network simulator and does not do anything by design that should cause this error. It does however call a few programs like [AMPL](http://www.ampl.com/), [gnuplot](http://www.gnuplot.info/) but just basic 4-5 word commands, which perhaps are running into this error. I didn't want to specify the black box too much because the question is really a broader one about the error not about what in my code is causing the error (which would make it more of a code review question). – Alan Turing Jul 22 '11 at 04:34

2 Answers2

2

write a program similar to the following:

int trials 10000;
string str("ls ");
while( trials--)
{
system( str.c_str() );
str += "a";
cout << "chars in cmd =  " << trials << endl;
}

It will successively run commands like ls, ls a, ls aa, ls aaa, while simultaneously printing to the console what trial # it's on.

and if you're right about where the error is coming from, eventually it will get the same error message about "token too long", and if so, tell you how many characters the cmd may be. Then code this limit into your real C++ program so that it doesn't emit the error.

If it doesn't reproduce the error, try making # trials bigger, say up to 100k. If it still doesn't happen, the error is probably coming from somewhere else.

Harry Seward
  • 147
  • 1
0

It's coming from a lexer, telling you that one of the tokens (identifiers/preproc tokens/etc.) in your program is rather lengthy. Look through your code to see if there are any ridiculously long strings or preprocessor tokens.

andand
  • 17,134
  • 11
  • 53
  • 79
djhaskin987
  • 9,741
  • 4
  • 50
  • 86
  • Interesting. Since I only get the error for longer simulation runs (as the edited question describes), perhaps this would have to be a string that's dynamically generated (growing unbounded). Do you have an idea of what "ridiculously long" is, can you give an example? – Alan Turing Jul 21 '11 at 21:17
  • I don't know what 'rediculously long' could be; the example I saw was a string 4400 characters long. perhaps it exceeds some predefined limit, such as 128, 256, 1024... I'm not sure. – djhaskin987 Jul 22 '11 at 19:54