Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Sim hangs on new target at dup_arg_p() in infinite loop.
@ 2013-09-09 20:13 Alexey Makhalov
  2013-09-11 22:28 ` Mike Frysinger
  2013-09-17 18:11 ` Tom Tromey
  0 siblings, 2 replies; 11+ messages in thread
From: Alexey Makhalov @ 2013-09-09 20:13 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 225 bytes --]

I've added checking for hash table overflow. It's better to have
internal error message instead of looping.

2013-09-09 Alexey Makhalov <makhaloff@gmail.com>
        * sim-options.c (dup_arg_p) Check for hash table overflow.

[-- Attachment #2: hash_table_overflow_checking.patch --]
[-- Type: application/octet-stream, Size: 985 bytes --]

Index: sim/common/sim-options.c
===================================================================
RCS file: /cvs/src/src/sim/common/sim-options.c,v
retrieving revision 1.31
diff -u -p -r1.31 sim-options.c
--- sim/common/sim-options.c	3 Sep 2013 20:45:08 -0000	1.31
+++ sim/common/sim-options.c	9 Sep 2013 20:12:25 -0000
@@ -495,6 +495,7 @@ static int
 dup_arg_p (const char *arg)
 {
   int hash;
+  int table_is_full = 0;
   static const char **arg_table = NULL;
 
   if (arg == NULL)
@@ -510,10 +511,15 @@ dup_arg_p (const char *arg)
     {
       if (strcmp (arg, arg_table[hash]) == 0)
 	return 1;
-      /* We assume there won't be more than ARG_HASH_SIZE arguments so we
-	 don't check if the table is full.  */
       if (++hash == ARG_HASH_SIZE)
+      {
 	hash = 0;
+	if (table_is_full++) {
+          fprintf (stderr, "Internal error - number of options more than %d\n",
+			  ARG_HASH_SIZE);
+          abort ();
+	}	
+      }
     }
   arg_table[hash] = arg;
   return 0;

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

end of thread, other threads:[~2013-11-27 18:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-09 20:13 Sim hangs on new target at dup_arg_p() in infinite loop Alexey Makhalov
2013-09-11 22:28 ` Mike Frysinger
2013-09-17 18:11 ` Tom Tromey
     [not found]   ` <CALd+sgeSJz46ja1xbbFYO12kiF=LjVCaF2Xy_TzeMUkPkwZVmw@mail.gmail.com>
2013-09-20  5:02     ` Alexey Makhalov
2013-09-20 17:33       ` Tom Tromey
2013-09-21  2:59         ` Alexey Makhalov
2013-11-07 15:20           ` Tom Tromey
2013-11-08  7:25             ` Alexey Makhalov
2013-11-27 11:28               ` Mike Frysinger
2013-11-27 12:22                 ` Joel Brobecker
2013-11-27 18:58                   ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox