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

Stacktrace disappear on FreeBSD #20798

Closed
iblislin opened this issue Feb 25, 2017 · 14 comments
Closed

Stacktrace disappear on FreeBSD #20798

iblislin opened this issue Feb 25, 2017 · 14 comments
Labels
system:freebsd Affects only FreeBSD

Comments

@iblislin
Copy link
Member

Hi,
I found that there are some stacktrace messages missing on FreeBSD.

julia> 2^-1
ERROR: DomainError:
Stacktrace:
 [1] internal_pow(::Int64, ::Type{Val{-1}}) at ./intfuncs.jl:204

julia> versioninfo()
Julia Version 0.6.0-dev.2921
Commit 12624fb80a* (2017-02-23 05:41 UTC)
Platform Info:
  OS: FreeBSD (amd64-unknown-freebsd12.0)
  CPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT NO_AFFINITY SANDYBRIDGE)
  LAPACK: libopenblasp
  LIBM: libm
  LLVM: libLLVM-3.8.1 (ORCJIT, sandybridge)

And ... on Linux:

julia> versioninfo()
Julia Version 0.6.0-dev.2856
Commit 34b39f8718 (2017-02-19 00:02 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E3-1231 v3 @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)
  
julia> 2^-1
ERROR: DomainError:
Cannot raise an integer x to a negative power -n.
Make x a float by adding a zero decimal (e.g. 2.0^-n instead of 2^-n), or write 1/x^n, float(x)^-n, or (x//1)^-n.
Stacktrace:
 [1] power_by_squaring(::Int64, ::Int64) at ./intfuncs.jl:170
 [2] internal_pow(::Int64, ::Type{Val{-1}}) at ./intfuncs.jl:204
 [3] ^(::Int64, ::Type{T} where T) at ./intfuncs.jl:203

Quote from https://julia.iblis.cnmc.tw/#/builders/1/builds/152/steps/6/logs/stdio :

Error in testset replutil:

Test Failed

  Expression: contains(err_str, "Cannot raise an integer x to a negative power -n")

Error in testset cmdlineargs:

Test Failed

  Expression: contains(bt, "include_from_node1")

Error in testset cmdlineargs:

Test Failed

  Expression: contains(bt, "include_from_node1(::String) at $(joinpath(".", "loading.jl"))")

Error in testset cmdlineargs:

Error During Test

  Test threw an exception of type ErrorException

  Expression: length(lno.captures) == 1

  type Void has no field captures

  Stacktrace:

   [1] length at ./checked.jl:222 [inlined]

   [2] map(::Base.Distributed.##38#43, ::Array{Any,1}) at ./essentials.jl:186

Error in testset cmdlineargs:

Error During Test

  Test threw an exception of type ErrorException

  Expression: parse(Int, lno.captures[1]) > 0

  type Void has no field captures

  Stacktrace:

   [1] length at ./checked.jl:222 [inlined]

   [2] map(::Base.Distributed.##38#43, ::Array{Any,1}) at ./essentials.jl:186

Any idea about a starting point to fix this?

@ararslan ararslan added system:freebsd Affects only FreeBSD REPL Julia's REPL (Read Eval Print Loop) labels Feb 25, 2017
@tkelman
Copy link
Contributor

tkelman commented Feb 25, 2017

guessing, but what libunwind are you using?

@iblislin
Copy link
Member Author

@iblislin
Copy link
Member Author

libunwind-20121006_2 is actually version 1.1 .

@tkelman
Copy link
Contributor

tkelman commented Feb 25, 2017

can you try with the source build from deps? that has a bunch of patches.

@iblislin
Copy link
Member Author

Ok, I tried it. It make the messages more, but it's still not enough to pass the testing.

julia> 2^-1
ERROR: DomainError:
Stacktrace:
 [1] internal_pow(::Int64, ::Type{Val{-1}}) at ./intfuncs.jl:207
 [2] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [3] macro expansion at ./REPL.jl:97 [inlined]
 [4] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73

It missed [1] power_by_squaring(::Int64, ::Int64) at ./intfuncs.jl:170 line.

@iblislin
Copy link
Member Author

By observing the result of test-cmdlineargs, I found this issue only popup via precompile=yes.

$ cat foo.jl 
module FooBar
error("break me")
end
$ ../julia --precompile=yes foo.jl
ERROR: LoadError: break me
while loading /usr/home/iblis/git/julia/tmp/foo.jl, in expression starting on line 2
$ ../julia --precompile=no foo.jl 
ERROR: LoadError: break me
Stacktrace:
 [1] error(::String) at ./error.jl:21
 [2] include_from_node1(::String) at ./loading.jl:539
 [3] include(::String) at ./sysimg.jl:14
 [4] process_options(::Base.JLOptions) at ./client.jl:305
 [5] _start() at ./client.jl:371
while loading /usr/home/iblis/git/julia/tmp/foo.jl, in expression starting on line 2

Something wrong in codegen?

@yuyichao yuyichao removed the REPL Julia's REPL (Read Eval Print Loop) label Feb 25, 2017
@iblislin
Copy link
Member Author

Got tons of error with gdb. Is this related?

└─[iblis@abeing]% gdb ../julia                                                                                         
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
(gdb) run
Starting program: /usr/home/iblis/git/julia/julia
[New LWP 100795]
Error while reading shared library symbols:
Dwarf Error: wrong version in compilation unit header (is 4, should be 2) [in module /usr/local/lib/gcc49/libgcc_s.so.1]
[New Thread 804216000 (LWP 100795/julia)]
Error while reading shared library symbols:
Dwarf Error: wrong version in compilation unit header (is 4, should be 2) [in module /usr/local/lib/gcc49/libgcc_s.so.1]
Error while reading shared library symbols:
Dwarf Error: wrong version in compilation unit header (is 4, should be 2) [in module /usr/local/lib/gcc49/libgcc_s.so.1]
Error while reading shared library symbols:
Dwarf Error: wrong version in compilation unit header (is 4, should be 2) [in module /usr/local/lib/gcc49/libgcc_s.so.1]
Error while reading shared library symbols:
Dwarf Error: wrong version in compilation unit header (is 4, should be 2) [in module /usr/local/lib/gcc49/libgcc_s.so.1]
Error while reading shared library symbols:
...

@tkelman
Copy link
Contributor

tkelman commented Feb 28, 2017

that's a really old version of gdb, is it possible to get anything newer?

@iblislin
Copy link
Member Author

:-o ok, i will get one.

@iblislin
Copy link
Member Author

iblislin commented Mar 1, 2017

I think I got the pain point, but no idea how to resolve it (I have no related background knowledge), here is my gdb.
The function dladdr return _init as the dli_sname. dli_sname is power_by_squring on linux(i guess) and the replutil.jl will render the expected error message and stacktrace.
gdb

@yuyichao
Copy link
Contributor

yuyichao commented Mar 1, 2017

I assume FreeBSD uses ELF so it probably has the same problem on linux that the internal symbol is not in the exported symbol and not returned by dladdr. On linux, this is worked around by the libunwind call below to use debug info/symbol table so you either need to see if the libunwind on FreeBSD support that too or find another way to get that info. Ideally we can ask LLVM about this since we are already using it to parse debug info though I didn't figure out how it works in 5mins before finding the libunwind function that works....

@iblislin
Copy link
Member Author

iblislin commented Mar 1, 2017

@iblislin
Copy link
Member Author

@yuyichao Would you point out how to do function pointer <-> address resolving in libunwind on linux?
I will dig into the code if i get free time this weekend.

@yuyichao
Copy link
Contributor

if (!saddr && unw_get_proc_info_by_ip(unw_local_addr_space,

@tkelman tkelman mentioned this issue Mar 30, 2017
yuyichao added a commit that referenced this issue Jun 23, 2017
* Add a (slow but cross-platform) fallback lookup method of function name and base address
  using LLVM debug info reader
* Remove windows exported symbol lookup that never worked for sysimg function address lookup
  (since they are never exported)

Fix #17251
Fix #20798
yuyichao added a commit that referenced this issue Jun 23, 2017
* Add a (slow but cross-platform) fallback lookup method of function name and base address
  using LLVM debug info reader
* Remove windows exported symbol lookup that never worked for sysimg function address lookup
  (since they are never exported)

Fix #17251
Fix #20798
yuyichao added a commit that referenced this issue Jun 23, 2017
* Add a (slow but cross-platform) fallback lookup method of function name and base address
  using LLVM debug info reader
* Remove windows exported symbol lookup that never worked for sysimg function address lookup
  (since they are never exported)

Fix #17251
Fix #20798
yuyichao added a commit that referenced this issue Jun 23, 2017
* Add a (slow but cross-platform) fallback lookup method of function name and base address
  using LLVM debug info reader
* Disable windows exported symbol lookup that never worked for sysimg function
  address lookup (since they are never exported). Also move it after
  LLVM debug info reader since it is less accurate unless LLVM couldn't get any
  debug info.

Fix #17251
Fix #20798
@yuyichao yuyichao reopened this Jun 24, 2017
quinnj pushed a commit that referenced this issue Jun 24, 2017
* Add a (slow but cross-platform) fallback lookup method of function name and base address
  using LLVM debug info reader
* Disable windows exported symbol lookup that never worked for sysimg function
  address lookup (since they are never exported). Also move it after
  LLVM debug info reader since it is less accurate unless LLVM couldn't get any
  debug info.

Fix #17251
Fix #20798
iblislin added a commit to iblislin/julia that referenced this issue Jun 26, 2017
…n FreeBSD

There is a known bug in FreeBSD's dladdr(3):
    (Quote from manual dladdr(3))
    In dynamically linked programs,
    the address of a global function is considered to point to its
    program linkage table entry, rather than to the entry point of the
    function itself.  This causes most global functions to appear to be
    defined within the main executable, rather than in the shared
    libraries where the actual code resides.

Function `get_function_name_and_base` implemented in PR JuliaLang#22472 provides
a (slow but cross-platform) way to lookup function name and base address
via LLVM.

@yuyichao propose that getting info from `get_function_name_and_base`
first and making original `dladdr` as fallback.

Fix: JuliaLang#20798
See also: JuliaLang#22472 (comment)
yuyichao pushed a commit that referenced this issue Jun 26, 2017
Similar to Linux.
The LLVM fallback is currently not working on FreeBSD for some reason.

Fix: #20798
DrTodd13 pushed a commit to IntelLabs/julia that referenced this issue Jun 26, 2017
* Add a (slow but cross-platform) fallback lookup method of function name and base address
  using LLVM debug info reader
* Disable windows exported symbol lookup that never worked for sysimg function
  address lookup (since they are never exported). Also move it after
  LLVM debug info reader since it is less accurate unless LLVM couldn't get any
  debug info.

Fix JuliaLang#17251
Fix JuliaLang#20798
yuyichao pushed a commit that referenced this issue Jun 26, 2017
Similar to Linux.
The LLVM fallback is currently not working on FreeBSD for some reason.

Fix: #20798
ararslan pushed a commit that referenced this issue Sep 13, 2017
* Add a (slow but cross-platform) fallback lookup method of function name and base address
  using LLVM debug info reader
* Disable windows exported symbol lookup that never worked for sysimg function
  address lookup (since they are never exported). Also move it after
  LLVM debug info reader since it is less accurate unless LLVM couldn't get any
  debug info.

Fix #17251
Fix #20798

Ref #22472
(cherry picked from commit 8c658c5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:freebsd Affects only FreeBSD
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants