« Return to Thread: heisenbug disabling BBox

Re: heisenbug disabling BBox

by Bernhard R. Link-2 :: Rate this Message:

| View in Thread

* Bernhard R. Link <brlink@...> [110803 12:17]:
>   Looking at dsc_strncmp I see nothing that could explain why
>   a difference like that could have effects like that.
>   As it does this funny malloc/free every time (no idea why
>   it does that as it could just to strncasecmp(s1, s2, n-1))
>   that might mean that there simply is some harvoc going on
>   with the memory mangement code. Optimising that function to
>   not do the temporary copy makes the bug disappear, but that
>   might simply be a code moves around effect....

Actually, the bug still show up with the malloc/free/strncpy
removed with the following patch:

index 248081c..ccc3ca1 100644
--- a/gv/src/ps.c
+++ b/gv/src/ps.c
@@ -115,17 +119,10 @@ static int dsc_strncmp(s1, s2, n)
 {
- char *tmp;
-
  if (strncasecmp(s1, s2, n) == 0)
  return 0;
  if (s2[n-1] == ':'){
- tmp = (char *) malloc(n*sizeof(char));
- strncpy(tmp, s2, (n-1));
- tmp[n-1]=' ';
- if (strncasecmp(s1, tmp, n) == 0){
- free(tmp);
+ if (strncasecmp(s1, s2, n-1) == 0 && s1[n-1] == ' '){
  return 0;
  }
- free(tmp);
  }
 
  return 1;

In other words: I'm totally at loss how this effect can
cause this. I will try to run it in the debugger with some
read watchpoints for the changed parts to see where it can
have a difference, but ....

        Bernhard R. Link

 « Return to Thread: heisenbug disabling BBox