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

Executable linked with -g does not produce a stack backtrace #3928

Closed
vicuna opened this issue Dec 19, 2005 · 3 comments
Closed

Executable linked with -g does not produce a stack backtrace #3928

vicuna opened this issue Dec 19, 2005 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Dec 19, 2005

Original bug ID: 3928
Reporter: alexbaretta
Status: closed (set by @xavierleroy on 2012-03-16T12:09:36Z)
Resolution: won't fix
Priority: low
Severity: minor
Version: 3.11+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #4788

Bug description

I am surprised to observe that there exists a case where an executable compiled and linked with the -g option does not produce a stack backtrace when it is killed by an exception. This problem has been reproduced with ocamlc version 3.09.1+dev5 (2005-12-05) as well as 3.08.4.

Fatal error: exception Builder_algorithms.Path_map.Path_not_found("./dmd_sw5")
(Program not linked with -g, cannot print stack backtrace)

The error message is not consistently wrong: it depends on the exception being raised. As you can see from the attached shell transcript, in the first example the exception produces the wrong error messages, whereas in the second, a stack backtrace is correctly printed. The only difference between the two examples is the excepition constructor being raised, but I don't know how or why this should matter.

I attach the full source code of the mentioned examples.

Additional information

alex@alex:/dev/src-stable/tools/builder$ ocamlc -v
The Objective Caml compiler, u
Standard library directory: /opt/ocaml/cvs/lib/ocaml
alex@alex:
/dev/src-stable/tools/builder$ make bc
make bc BUILD=true
make[1]: Entering directory /home/alex/dev/src-stable/tools/builder' GNUmakefile:254: depend: No such file or directory cp ../../lib/ocamllib-addons/duality.ml ../../lib/ocamllib-addons/option.ml ../../lib/ocamllib-addons/option.mli ../../lib/ocamllib-addons/predicate.mli ../../lib/ocamllib-addons/predicate.ml ../../lib/ocamllib-addons/stream_utils.mli ../../lib/ocamllib-addons/stream_utils.ml ../../lib/ocamllib-addons/string_utils.ml ../../lib/ocamllib-addons/parse_argv.mli ../../lib/ocamllib-addons/parse_argv.ml ../../lib/ocamllib-addons/heap.mli ../../lib/ocamllib-addons/heap.ml ../../lib/ocamllib-addons/list_utils.ml ../../lib/ocamllib-addons/relation.mli ../../lib/ocamllib-addons/relation.ml ../../lib/ocamllib-addons/dir_utils.ml ../../lib/ocamllib-addons/filename_utils.mli ../../lib/ocamllib-addons/filename_utils.ml . touch local_copy Building builder_lexer.ml with ocamllex ... ocamllex builder_lexer.mll 201 states, 3832 transitions, table size 16534 bytes 14611 additional bytes used for bindings Making depend ... ocamldep -pp "camlp4o pa_openin.cmo" "" duality.ml option.ml option.mli predicate.mli predicate.ml stream_utils.mli stream_utils.ml string_utils.ml parse_argv.mli parse_argv.ml heap.mli heap.ml list_utils.ml relation.mli relation.ml dir_utils.ml filename_utils.mli filename_utils.ml builder_fs_helper.ml builder_options.ml builder_algorithms.ml builder_rules.ml builder_lexer.ml builder.ml > depend make[1]: Leaving directory /home/alex/dev/src-stable/tools/builder'
make[1]: Entering directory /home/alex/dev/src-stable/tools/builder' Making duality.cmo ... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c duality.ml Making option.cmi... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c option.mli Making option.cmo ... ocamlfind ocamlc -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c option.ml Making predicate.cmi... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c predicate.mli Making predicate.cmo ... ocamlfind ocamlc -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c predicate.ml Making stream_utils.cmi... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c stream_utils.mli Making stream_utils.cmo ... ocamlfind ocamlc -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c stream_utils.ml File "stream_utils.ml", line 29, characters 6-12: Warning Y: unused variable length. File "stream_utils.ml", line 34, characters 6-12: Warning Y: unused variable length. Making string_utils.cmo ... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c string_utils.ml Making parse_argv.cmi... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c parse_argv.mli Making parse_argv.cmo ... ocamlfind ocamlc -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c parse_argv.ml Making heap.cmi... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c heap.mliMaking heap.cmo ... ocamlfind ocamlc -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c heap.ml Making list_utils.cmo ... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c list_utils.ml File "list_utils.ml", line 442, characters 8-30: Warning Y: unused variable tl. Making relation.cmi... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c relation.mli Making relation.cmo ... ocamlfind ocamlc -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c relation.ml Making dir_utils.cmo ... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c dir_utils.ml Making filename_utils.cmi... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c filename_utils.mli Making filename_utils.cmo ... ocamlfind ocamlc -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c filename_utils.ml Making builder_fs_helper.cmo ... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c builder_fs_helper.ml Making builder_options.cmo ... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c builder_options.ml Making builder_algorithms.cmo ... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c builder_algorithms.ml Making builder_rules.cmo ... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c builder_rules.ml Making builder_lexer.cmo ... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c builder_lexer.ml File "builder_lexer.ml", line 2119, characters 6-15: Warning Y: unused variable extension. File "builder_lexer.ml", line 2120, characters 6-14: Warning Y: unused variable basename. File "builder_lexer.ml", line 2333, characters 6-15: Warning Y: unused variable extension. File "builder_lexer.ml", line 2334, characters 6-14: Warning Y: unused variable basename. File "builder_lexer.ml", line 2342, characters 6-15: Warning Y: unused variable extension. File "builder_lexer.ml", line 2343, characters 6-14: Warning Y: unused variable basename. File "builder_lexer.ml", line 2351, characters 6-15: Warning Y: unused variable extension. File "builder_lexer.ml", line 2352, characters 6-14: Warning Y: unused variable basename. Making builder.cmo ... ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c builder.ml File "builder.ml", line 82, characters 8-17: Warning Y: unused variable extension. File "builder.ml", line 144, characters 8-23: Warning Y: unused variable do_xdbs_phonies. File "builder.ml", line 143, characters 8-22: Warning Y: unused variable target_objects. File "builder.ml", line 140, characters 8-21: Warning Y: unused variable ocaml_sources. File "builder.ml", line 67, characters 6-19: Warning Y: unused variable rec_uses_list. File "builder.ml", line 227, characters 56-95: Warning Y: unused variable exn. File "builder.ml", line 236, characters 7-28: Warning Y: unused variable sources_list_filename. File "builder.ml", line 219, characters 6-21: Warning Y: unused variable dir_filter_pred. Linking builder ... ocamlfind ocamlc -g -rectypes -thread -linkpkg -package "unix str" duality.cmo option.cmo predicate.cmo stream_utils.cmo string_utils.cmo parse_argv.cmo heap.cmo list_utils.cmo relation.cmo dir_utils.cmo filename_utils.cmo builder_fs_helper.cmo builder_options.cmo builder_algorithms.cmo builder_rules.cmo builder_lexer.cmo builder.cmo -o builder make[1]: Leaving directory /home/alex/dev/src-stable/tools/builder'
alex@alex:~/dev/src-stable/tools/builder$ ./builder -o Makefile -R ../.. -S applications/dmd_sw5
Fatal error: exception Builder_algorithms.Path_map.Path_not_found("./dmd_sw5")
(Program not linked with -g, cannot print stack backtrace)
alex@alex:/tmp$ ./builder -R /nowhere/at/all
Fatal error: exception Sys_error("/nowhere/at/all: No such file or directory")
Raised by primitive operation at file "builder.ml", line 313, characters 4-47

File attachments

@vicuna
Copy link
Author

vicuna commented Jan 5, 2006

Comment author: @damiendoligez

I'm trying to reproduce the problem, but some files are missing:

$ make bc
make bc BUILD=true
Making duality.cmo ...
ocamlfind ocamlc -pp "camlp4o pa_openin.cmo" -g -rectypes -pp "camlp4o pa_openin.cmo" -thread -package "unix str" -c duality.ml
Error while loading "pa_openin.cmo": file not found in path.
Preprocessor error

@vicuna
Copy link
Author

vicuna commented Jan 5, 2006

Comment author: alexbaretta

Ah, I'm sorry! There was a bug in the Makefile, which would allow to build the project only within the context of the full as_xcaml source directory. Now the dependencies have been fixed so that it does not require the presence of the ocamllib-addons directory. Yet, this has nothing to do with the problem you mention. pa_openin is a camlp4 syntax extension by Alain Frisch (http://www.eleves.ens.fr/home/frisch/info/openin-20020205.tar.gz) defining the following construct:

open M in

Let me know if you have any other difficulty reproducing the problem.

Alex

@vicuna
Copy link
Author

vicuna commented Oct 8, 2008

Comment author: @damiendoligez

The bug happens if your executable name is relative to the current directory and the program changes the current directory before the exception is raised.

The obvious workaround is to launch your program with an absolute path name instead of a relative name:
pwd/build -R blah
instead of
./build -R blah

Now that we know what is happening, it is clear that this bug is unlikely to be fixed in the near future.

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

No branches or pull requests

1 participant