Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006233OCamlOCaml generalpublic2013-11-10 02:392013-12-26 23:37
Reporterglondu 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformarmelOSDebianOS Versionsid
Product Version4.01.0 
Target VersionFixed in Version4.01.1+dev 
Summary0006233: Incomplete native backtraces on armel
DescriptionNative backtraces are incomplete on armel (armhf has not been tested yet).

The following tests fail:
    tests/backtrace/backtrace2.ml
    tests/backtrace/raw_backtrace.ml
Additional InformationHere are the diffs between expected and actual outputs:

--- backtrace2.reference 2013-06-19 14:26:10.000000000 +0000
+++ backtrace2.native.result 2013-11-09 11:23:20.000000000 +0000
@@ -24,4 +24,3 @@
 Called from file "backtrace2.ml", line 22, characters 4-11
 Called from file "backtrace2.ml", line 29, characters 11-23
 Uncaught exception Invalid_argument("index out of bounds")
-Raised by primitive operation at file "backtrace2.ml", line 29, characters 14-22
abel% diff -u raw_backtrace.reference raw_backtrace.native.result
--- raw_backtrace.reference 2013-06-19 14:27:10.000000000 +0000
+++ raw_backtrace.native.result 2013-11-09 11:23:21.000000000 +0000
@@ -24,4 +24,3 @@
 Called from file "raw_backtrace.ml", line 22, characters 4-11
 Called from file "raw_backtrace.ml", line 29, characters 11-23
 Uncaught exception Invalid_argument("index out of bounds")
-Raised by primitive operation at file "raw_backtrace.ml", line 29, characters 14-22
TagsNo tags attached.
Attached Files? file icon backtrace2.s [^] (12,235 bytes) 2013-11-12 16:43
? file icon raw_backtrace.s [^] (15,737 bytes) 2013-11-12 16:43
? file icon backtrace2.dumps.xz [^] (48,668 bytes) 2013-11-13 06:38

- Relationships

-  Notes
(0010612)
meurer (developer)
2013-11-11 08:12

Same for armhf.
(0010613)
gasche (developer)
2013-11-11 08:45
edited on: 2013-11-11 16:38

During 4.01 development there were some changes to the trace collection code. In particular:

- commit 13394 exposed "raw backtraces" (allowing to manipulate backtraces without slowly converting them to strings first), with a minor change to the runtime
- commit 13813 changed the runtime to also support collection of arbitrary stack traces, even in absence of a raise

Do you think it would be possible to test whether the regression is related to any of those two commits? I don't know how I would access an ARM myself.

(0010617)
glondu (reporter)
2013-11-11 16:19

None of these commits unapplies cleanly.

I have access to armel and armhf machines, and can do tests there if I am told what to do.
(0010618)
jacques-henri.jourdan (manager)
2013-11-12 15:01

Could you give me the generated assembly code for both files ?

E.g. run :
ocamlopt -g -S backtrace2.ml

And upload the file backtrace2.s
(0010620)
glondu (reporter)
2013-11-12 16:45

@gasche: this is not a regression. The tests start failing at r13816, which is when you introduced them.
(0010621)
glondu (reporter)
2013-11-12 16:46

@jacques-henri: I've uploaded the generated (by released version 4.01.0) assembly code for armhf.
(0010622)
jacques-henri.jourdan (manager)
2013-11-12 22:15

Debug information is not present at point of array bounds checking.

Could you please provide the dumps for all intermediate languages of the native chain ?

That is, run :
ocamlopt -g -S -dcmm -dsel -dcombine -dlive -dspill -dsplit -dinterf -dprefer -dalloc -dreload -dscheduling -dlinear backtrace2.ml

And upload all the backtrace2.* files (in a tarball, preferably).

Thanks !
(0010624)
glondu (reporter)
2013-11-13 06:39

The only generated backtrace2.* file is backtrace2.s. All the rest is on stdout/stderr. I've uploaded the output.
(0010626)
jacques-henri.jourdan (manager)
2013-11-13 11:45

Here is a tentative patch, could you test it ?

diff --git a/asmcomp/linearize.ml b/asmcomp/linearize.ml
index 963ffe9..ad96aa4 100644
--- a/asmcomp/linearize.ml
+++ b/asmcomp/linearize.ml
@@ -86,6 +86,12 @@ let instr_cons d a r n =
   { desc = d; next = n; arg = a; res = r;
     dbg = Debuginfo.none; live = Reg.Set.empty }
 
+(* Cons an instruction (live empty) *)
+
+let instr_cons_debug d a r dbg n =
+ { desc = d; next = n; arg = a; res = r;
+ dbg = dbg; live = Reg.Set.empty }
+
 (* Cons a simple instruction (arg, res, live empty) *)
 
 let cons_instr d n =
diff --git a/asmcomp/linearize.mli b/asmcomp/linearize.mli
index ad5dc3a..b905860 100644
--- a/asmcomp/linearize.mli
+++ b/asmcomp/linearize.mli
@@ -42,6 +42,9 @@ val has_fallthrough : instruction_desc -> bool
 val end_instr: instruction
 val instr_cons:
   instruction_desc -> Reg.t array -> Reg.t array -> instruction -> instruction
+val instr_cons_debug:
+ instruction_desc -> Reg.t array -> Reg.t array -> Debuginfo.t ->
+ instruction -> instruction
 val invert_test: Mach.test -> Mach.test
 
 type fundecl =
diff --git a/asmcomp/schedgen.ml b/asmcomp/schedgen.ml
index 885c945..f1c7d5e 100644
--- a/asmcomp/schedgen.ml
+++ b/asmcomp/schedgen.ml
@@ -336,7 +336,8 @@ method private reschedule ready_queue date cont =
             if son.emitted_ancestors = son.ancestors then
               new_queue := son :: !new_queue)
           node.sons;
- instr_cons node.instr.desc node.instr.arg node.instr.res
+ instr_cons_debug node.instr.desc node.instr.arg node.instr.res
+ node.instr.dbg
           (self#reschedule !new_queue (date + issue_cycles) cont)
   end
(0010627)
glondu (reporter)
2013-11-13 14:47

All the tests pass on armhf with the patch applied.


However, this patch touches generic code and this bug affects only ARM. How come it doesn't happen on Intel architectures?
(0010628)
meurer (developer)
2013-11-13 15:00

For i386 and amd64, scheduling is a no-op.
(0010677)
xleroy (administrator)
2013-11-28 18:23

I ran into the same issue on PowerPC and independently came up with a similar analysis and fix. It's committed on the 4.01 bugfix branch (r14325) and on the trunk (r14323).
(0010678)
glondu (reporter)
2013-11-28 18:37
edited on: 2013-11-28 18:37

Interesting... by any chance, would it be possible to easily fix native backtraces on sparc as well?

(0010680)
xleroy (administrator)
2013-11-30 11:38

> would it be possible to easily fix native backtraces on sparc as well?

We lack real Sparc hardware to properly maintain the Sparc back-end. All I have right now is a QEMU-based setup that is barely usable. If anyone can provide us with a shell account on a well-configured Sparc machine, let us know.
(0010681)
glondu (reporter)
2013-11-30 11:47

I have access to sparc machines that are restricted to Debian Developers, but I think you can ask for an account on the GCC compile farm:

  http://gcc.gnu.org/wiki/CompileFarm [^]
(0010767)
glondu (reporter)
2013-12-26 23:37

Actually, native backtraces don't work at all on powerpc, even after r14325.

- Issue History
Date Modified Username Field Change
2013-11-10 02:39 glondu New Issue
2013-11-11 08:12 meurer Note Added: 0010612
2013-11-11 08:45 gasche Note Added: 0010613
2013-11-11 16:19 glondu Note Added: 0010617
2013-11-11 16:38 gasche Note Edited: 0010613 View Revisions
2013-11-12 15:01 jacques-henri.jourdan Note Added: 0010618
2013-11-12 16:43 glondu File Added: backtrace2.s
2013-11-12 16:43 glondu File Added: raw_backtrace.s
2013-11-12 16:45 glondu Note Added: 0010620
2013-11-12 16:46 glondu Note Added: 0010621
2013-11-12 22:15 jacques-henri.jourdan Note Added: 0010622
2013-11-13 06:38 glondu File Added: backtrace2.dumps.xz
2013-11-13 06:39 glondu Note Added: 0010624
2013-11-13 11:45 jacques-henri.jourdan Note Added: 0010626
2013-11-13 14:47 glondu Note Added: 0010627
2013-11-13 15:00 meurer Note Added: 0010628
2013-11-28 18:23 xleroy Note Added: 0010677
2013-11-28 18:23 xleroy Status new => resolved
2013-11-28 18:23 xleroy Resolution open => fixed
2013-11-28 18:23 xleroy Fixed in Version => 4.01.1+dev
2013-11-28 18:37 glondu Note Added: 0010678
2013-11-28 18:37 glondu Note Edited: 0010678 View Revisions
2013-11-30 11:38 xleroy Note Added: 0010680
2013-11-30 11:47 glondu Note Added: 0010681
2013-12-26 23:37 glondu Note Added: 0010767


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker