getopt_long() crashes

98 views
Skip to first unread message

BL

unread,
Oct 16, 2013, 5:27:19 PM10/16/13
to native-cli...@googlegroups.com
Just check if there is a crash issue on getopt_long() api with pnacl when parsing to the last argument.
getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *indexptr)

It works well with nacl glibc no problem.
Thanks

Jan Voung

unread,
Oct 17, 2013, 12:52:48 PM10/17/13
to native-cli...@googlegroups.com
I will try to repro, but if you already have a reproducer that you don't mind sending to us, could you file an issue under: https://code.google.com/p/nativeclient/issues/list, and attach it to the bug report?  Thanks!




--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to native-client-di...@googlegroups.com.
To post to this group, send email to native-cli...@googlegroups.com.
Visit this group at http://groups.google.com/group/native-client-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Jan Voung

unread,
Oct 17, 2013, 1:32:14 PM10/17/13
to native-cli...@googlegroups.com
Hmm do you have a reproducer you can share?  I just tried the getopt_long example from the manpage with the following options:

1 --add=999999 --append  --delete=100313 -d 4 -a -c 10 --create xxx -b --file foo_bar_file.txt  2 3

and it was able to parse all the options and print the right thing without crashing. The pexe was compiled with -O2...


BL

unread,
Oct 17, 2013, 4:20:45 PM10/17/13
to native-cli...@googlegroups.com
Thanls Jan. Will check my end again to make sure js passing correct argv. 
The same js I used with nacl (glibc) module has no problem. I will double check with pnacl module.

BL

unread,
Oct 17, 2013, 7:15:24 PM10/17/13
to native-cli...@googlegroups.com, jvo...@chromium.org
Hi Jan,
It's weird, I got this user case crashes most of the time only if the host name provides as ip instead of name:
192.168.10.10 -u testuser -p testpassword -g 1024x768 -a 32

Debug output: negative (crash) and positive
Test 1: Crashed
===============

string=chrome-extension://ghoecokkcppedofniagnacalihpgmmig/connect.html connection.js:81
hostname=192.168.10.10
username=testuser
password=testpassword
resolution=1024x768

starts getopt_long()
argc=10 opt=u optind=3 optIndex=1044709248
starts getopt_long()
argc=10 opt=p optind=5 optIndex=1044709248
starts getopt_long()
argc=10 opt=g optind=7 optIndex=1044709248
starts getopt_long()
argc=10 opt=a optind=9 optIndex=1044709248
starts getopt_long()
NativeClient: NaCl module crashed


Test 2: Worked
==============

string=chrome-extension://ghoecokkcppedofniagnacalihpgmmig/connect.html connection.js:81
hostname=testhost
username=testuser
password=testpassword
resolution=1024x768


starts getopt_long()
argc=10 opt=u optind=3 optIndex=1044709248
starts getopt_long()
argc=10 opt=p optind=5 optIndex=1044709248
starts getopt_long()
argc=10 opt=g optind=7 optIndex=1044709248
starts getopt_long()
argc=10 opt=a optind=9 optIndex=1044709248
starts getopt_long()
argc=10 opt=-1 optind=9 optIndex=1044709248

Test Code:
extern void nacl_debug(char *debugstr);
extern int optind ;

int testgetopt_main( int argc, char ** argv )
{
   int opt ;
   int optIndex ;
   char dbgmsg[128];

   static const struct option options[] = {
{ "color", required_argument, 0, 'a' },
{ "resolution", required_argument, 0, 'g' },
{ "user", required_argument, 0, 'u' },
{ "password", required_argument, 0, 'p' },
//Terminate the list
{ NULL, 0, 0, 0  }
   } ;

#define OPTION_FLAGS ":045a:AbB:c:Cd:DeEfg:GhIk:KLmM:n:Np:Ps:S:r:t:T:u:x:X:z~:@:"

   while ( 1 ) {
      nacl_debug("starts getopt_long()");
      opt = getopt_long( argc, argv, OPTION_FLAGS, options, &optIndex ) ;

      if ( opt == -1 ) {
         sprintf(dbgmsg, "argc=%d opt=%d optind=%d optIndex=%d", argc, opt, optind, optIndex);
         nacl_debug(dbgmsg);
         break ;
      } else {
         sprintf(dbgmsg, "argc=%d opt=%c optind=%d optIndex=%d", argc, opt, optind, optIndex);
         nacl_debug(dbgmsg);
      }
   }
   argc -= optind;
   argv += optind;

   return 1;
}


On Thursday, October 17, 2013 10:32:14 AM UTC-7, Jan Voung wrote:
Hmm do you have a reproducer you can share?  I just tried the getopt_long example from the manpage with the following options:

1 --add=999999 --append  --delete=100313 -d 4 -a -c 10 --create xxx -b --file foo_bar_file.txt  2 3

and it was able to parse all the options and print the right thing without crashing. The pexe was compiled with -O2...


On Thu, Oct 17, 2013 at 9:52 AM, Jan Voung <jvo...@chromium.org> wrote:
I will try to repro, but if you already have a reproducer that you don't mind sending to us, could you file an issue under: https://code.google.com/p/nativeclient/issues/list, and attach it to the bug report?  Thanks!


On Wed, Oct 16, 2013 at 2:27 PM, BL <mele...@gmail.com> wrote:
Just check if there is a crash issue on getopt_long() api with pnacl when parsing to the last argument.
getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *indexptr)

It works well with nacl glibc no problem.
Thanks

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to native-client-discuss+unsub...@googlegroups.com.

BL

unread,
Oct 17, 2013, 7:57:23 PM10/17/13
to native-cli...@googlegroups.com
Hi Jan,
The Chrome browser version is 31.0.1650.26 Beta. No crash issue if i tried on Chrome browser Version 30.0.1599.101 m stable version. 
So ignore this until I try on 31 stable release. Thanks

On Wednesday, October 16, 2013 2:27:19 PM UTC-7, BL wrote:
Reply all
Reply to author
Forward
0 new messages