Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete native backtraces on armel #6233

Closed
vicuna opened this Issue Nov 10, 2013 · 16 comments

Comments

Projects
None yet
1 participant
@vicuna
Copy link
Collaborator

vicuna commented Nov 10, 2013

Original bug ID: 6233
Reporter: @glondu
Status: closed (set by @xavierleroy on 2015-12-11T18:25:32Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: armel
OS: Debian
OS Version: sid
Version: 4.01.0
Fixed in version: 4.01.1+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @gasche meurer

Bug description

Native 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 information

Here 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

File attachments

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 11, 2013

Comment author: meurer

Same for armhf.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 11, 2013

Comment author: @gasche

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.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 11, 2013

Comment author: @glondu

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.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 12, 2013

Comment author: @jhjourdan

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

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 12, 2013

Comment author: @glondu

@gasche: this is not a regression. The tests start failing at r13816, which is when you introduced them.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 12, 2013

Comment author: @glondu

@jacques-henri: I've uploaded the generated (by released version 4.01.0) assembly code for armhf.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 12, 2013

Comment author: @jhjourdan

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 !

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 13, 2013

Comment author: @glondu

The only generated backtrace2.* file is backtrace2.s. All the rest is on stdout/stderr. I've uploaded the output.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 13, 2013

Comment author: @jhjourdan

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
@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 13, 2013

Comment author: @glondu

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?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 13, 2013

Comment author: meurer

For i386 and amd64, scheduling is a no-op.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 28, 2013

Comment author: @xavierleroy

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).

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 28, 2013

Comment author: @glondu

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

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 30, 2013

Comment author: @xavierleroy

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.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 30, 2013

Comment author: @glondu

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

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Dec 26, 2013

Comment author: @glondu

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

@vicuna vicuna closed this Dec 11, 2015

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.