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

When compiling for ARM/Thumb, ocamlrun segfaults during build. #4953

Closed
vicuna opened this issue Jan 4, 2010 · 1 comment
Closed

When compiling for ARM/Thumb, ocamlrun segfaults during build. #4953

vicuna opened this issue Jan 4, 2010 · 1 comment
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Jan 4, 2010

Original bug ID: 4953
Reporter: NCommander
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2010-01-08T10:34:05Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 3.11.1
Fixed in version: 3.11.2+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

When building for Thumb2 on Ubuntu lucid, ocaml failed to build from source with ocamlrun segfaulting while running make world. The issue was tracked down to an issue when specifying specific registers on Thumb. Here's the output from GDB:

nc@arm:~/src/ocaml-3.11.1$ gdb boot/ocamlrun
GNU gdb (GDB) 7.0.1-ubuntu
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabi".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /home/nc/src/ocaml-3.11.1/boot/ocamlrun...done.
(gdb) r boot/ocamlc
Starting program: /home/nc/src/ocaml-3.11.1/boot/ocamlrun boot/ocamlc
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x00026bda in caml_interprete (prog=Cannot access memory at address 0x5
) at interp.c:526
526 int nvars = *pc++;
(gdb) l
521 }
522 Next;
523 }
524
525 Instruct(CLOSURE): {
526 int nvars = *pc++;
527 int i;
528 if (nvars > 0) *--sp = accu;
529 Alloc_small(accu, 1 + nvars, Closure_tag);
530 Code_val(accu) = pc + *pc;
(gdb) bt
#0 0x00026bda in caml_interprete (prog=Cannot access memory at address 0x5
) at interp.c:526
Cannot access memory at address 0x2cd
(gdb) info registers
r0 0x0 0
r1 0x0 0
r2 0x0 0
r3 0x40286f8c 1076391820
r4 0x0 0
r5 0x0 0
r6 0x0 0
r7 0x1 1
r8 0x46928 289064
r9 0x40286f8c 1076391820
r10 0x4001e000 1073864704
r11 0x0 0
r12 0x401210e1 1074925793
sp 0xbebae340 0xbebae340
lr 0x26197 156055
pc 0x26bda 0x26bda <caml_interprete+2810>
fps 0x0 0
cpsr 0x60000030 1610612784
(gdb)

I'm willing to help test any patches or provide any debugging information necessary.

Additional information

The following patch works around the issue by dropping the per-register assignments when compiling for Thumb:

Index: ocaml-3.11.1/byterun/interp.c

--- ocaml-3.11.1.orig/byterun/interp.c 2010-01-04 10:20:26.387208256 -0500
+++ ocaml-3.11.1/byterun/interp.c 2010-01-04 10:25:41.727191496 -0500
@@ -157,7 +157,8 @@
#define SP_REG asm("a4")
#define ACCU_REG asm("d7")
#endif
-#ifdef arm
+/* specifying a specific register breaks when compiling for thumb mode */
+#if defined (arm) && !defined(thumb)
#define PC_REG asm("r9")
#define SP_REG asm("r8")
#define ACCU_REG asm("r7")

@vicuna
Copy link
Author

vicuna commented Jan 8, 2010

Comment author: @xavierleroy

Thanks for the detective work. Patch applied in 3.11 release branch, will go in 3.11.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants