A subtle bug in pthread: another case 
Author Message
 A subtle bug in pthread: another case

In my preceding posting i gave an example, which causes a
segmentation fault.

Here is another, completely different example, with the same effect:

--- 8< ---------------------------------------------------------------
MODULE crash1;

(* (c) 16.3.00   Dr. Christian Maurer *)

FROM SYSTEM IMPORT ADDRESS, ADR;
FROM pc IMPORT null, write;
FROM procs IMPORT proc, init, wait;

CONST M = 1000;

PROCEDURE h (x, n: CARDINAL);
VAR C: CHAR;
BEGIN
  IF n = 0 THEN C:= "p" ELSE C:= "k" END;
  write (1, ADR (C), 1)
END h;

PROCEDURE f (a: ADDRESS): ADDRESS;
VAR n: CARDINAL;
BEGIN
  FOR n:= 0 TO M - 1 DO
(* a value as first parameter causes a segmentation fault: *)

    h (n MOD 10, 0)

(* with just a variable instead everythings seems to work: *)
(*
    h (n, 0)
*)
  END;
  RETURN null ()
END f;

PROCEDURE g (a: ADDRESS): ADDRESS;
VAR n: CARDINAL;
BEGIN
  FOR n:= 0 TO M - 1 DO
    h (n, 1)
  END;
  RETURN null ()
END g;

VAR p, q: proc;
BEGIN
  init (p, f);
  init (q, g);
  wait (p);
  wait (q)
END crash1.
--- 8< ---------------------------------------------------------------

--
Christian Maurer, email to: maurer at domain inf.fu-berlin.de
FU Berlin, Institut f. Informatik, Takustr. 9, D-14195 Berlin (Germany)
Work:    Tel: ++49-30-838 75 215      Fax: ++49-30-838 75 109
Private: Tel: ++49-30-214 78 530      Fax: ++49-30-236 20 635



Mon, 02 Sep 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Subtle bug in pthread (or MOCKA or glibc-2.1) ???

2. subtle bug in HTTP client

3. Subtle bug in Ruby/Tk? (Attn: Hidetoshi Nagai)

4. A subtle bug found

5. Backslash Newline - a subtle bug

6. subtle bug/feature of switch statements

7. Upper case / Lower case I'm a lost case

8. CASE vs case vs Case...

9. BUGS, BUGS, BUGS, BUGS, C4 BUGS

10. Subtle Smalltalk advantage over Java ?

11. Sharing a subtle awk problem

12. Win2K Subtle Changes

 

 
Powered by phpBB® Forum Software