Skip to content

Instantly share code, notes, and snippets.

@binarybana
Created September 23, 2014 21:35
Show Gist options
  • Save binarybana/378a847f2e51db6c82c0 to your computer and use it in GitHub Desktop.
Save binarybana/378a847f2e51db6c82c0 to your computer and use it in GitHub Desktop.
Julia Segfault on Module Reloading
jason@toxicvm:~/test3$ ~/src/julia/julia testcase.jl
1
2
Warning: replacing module MPM
3
Warning: replacing module MPM
4
Warning: replacing module MPM
5
Warning: replacing module MPM
6
Warning: replacing module MPM
7
Warning: replacing module MPM
8
Warning: replacing module MPM
9
Warning: replacing module MPM
10
Warning: replacing module MPM
11
Warning: replacing module MPM
signal (11): Segmentation fault
broadcast! at broadcast.jl:220
quantile! at statistics.jl:498
quantile at statistics.jl:505
jlcall_quantile;1135 at (unknown line)
unknown function (ip: 796352956)
jl_apply_generic at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
anonymous at /home/jason/test3/testcase.jl:5
mapslices at abstractarray.jl:1240
unknown function (ip: 796352956)
jl_apply_generic at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
mapslices at abstractarray.jl:1220
jlcall_mapslices;1080 at (unknown line)
unknown function (ip: 796352956)
jl_apply_generic at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
anonymous at no file:12
unknown function (ip: 796392332)
jl_trampoline at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 796965716)
unknown function (ip: 796973306)
unknown function (ip: 796973945)
jl_load at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
jl_load_ at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
include at boot.jl:245
unknown function (ip: 796352956)
jl_apply_generic at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
include_from_node1 at loading.jl:128
unknown function (ip: 796392332)
jl_trampoline at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 796352956)
jl_apply_generic at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
process_options at client.jl:285
_start at client.jl:354
jlcall__start;376 at (unknown line)
unknown function (ip: 796392332)
jl_trampoline at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 796352956)
jl_apply_generic at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 4199848)
unknown function (ip: 4202869)
julia_trampoline at /home/jason/src/julia/usr/bin/../lib/libjulia-debug.so (unknown line)
unknown function (ip: 4203350)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 4199593)
unknown function (ip: 0)
Segmentation fault (core dumped)
jason@toxicvm:~/test3$ gdb ~/src/julia/julia
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/jason/src/julia/julia...done.
(gdb) run testcase.jl
Starting program: /home/jason/src/julia/julia testcase.jl
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff249f700 (LWP 32184)]
[New Thread 0x7ffff1c9e700 (LWP 32185)]
[New Thread 0x7fffef49d700 (LWP 32186)]
[New Thread 0x7fffecc9c700 (LWP 32187)]
[New Thread 0x7fffea49b700 (LWP 32188)]
[New Thread 0x7fffe7c9a700 (LWP 32189)]
[New Thread 0x7fffe5499700 (LWP 32190)]
[New Thread 0x7fffe2c98700 (LWP 32191)]
[New Thread 0x7fffe0497700 (LWP 32192)]
[New Thread 0x7fffddc96700 (LWP 32193)]
[New Thread 0x7fffdb495700 (LWP 32194)]
1
2
Warning: replacing module MPM
3
Warning: replacing module MPM
4
Warning: replacing module MPM
5
Warning: replacing module MPM
6
Warning: replacing module MPM
7
Warning: replacing module MPM
8
Warning: replacing module MPM
9
Warning: replacing module MPM
10
Warning: replacing module MPM
11
Warning: replacing module MPM
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5523191 in ?? ()
(gdb) bt
#0 0x00007ffff5523191 in ?? ()
#1 0x0000000000000002 in ?? ()
#2 0x000000000000001a in ?? ()
#3 0x00007fffffffcbe0 in ?? ()
#4 0x00000000056eb390 in ?? ()
#5 0x0000000000000000 in ?? ()
(gdb)
data = rand(0:1000,48,18000)
function test()
reload("uniquename.jl")
normfac = vec(mapslices(x->quantile(x,0.75), data, 2))
cls = MPM.mpm_classifier()
MPM.sample(cls,1)
end
for i=1:100
println(i)
test()
end
module MPM
using Distributions
abstract Sampler
abstract MCMC
type BinaryClassifier{T<:Sampler,S<:MCMC}
cls1 :: T
cls2 :: T
mcmc1 :: S
mcmc2 :: S
end
type AMWGRecord <: MCMC
obj :: Sampler
db :: Vector{Any}
end
AMWGRecord(obj::Sampler) = AMWGRecord(obj, Any[])
function sample(rec::AMWGRecord)
oldenergy = energy(rec.obj)
end
type MPMPrior
D :: Int
mu :: Vector{Float64}
mu_sigmas :: Vector{Float64} # Unvariate variances on mu
kappa :: Float64
S :: Matrix{Float64}
end
type MPMParams
mu :: Vector{Float64}
sigma :: Matrix{Float64}
sigpre :: Matrix{Float64}
lam :: Matrix{Float64}
energy :: Float64
function MPMParams(mu, sigpre, lam)
new(mu, sigpre'*sigpre, sigpre, lam, -Inf)
end
end
type MPMSampler <: Sampler
curr :: MPMParams
old :: MPMParams
prior :: MPMPrior
data :: Matrix{Int}
usepriors :: Bool
d :: Vector{Float64}
end
function MPMSampler(prior::MPMPrior, data::Matrix, obj::MPMParams, d::Float64)
MPMSampler(prior, data, obj, d*ones(size(data,1)))
end
function MPMSampler(prior::MPMPrior, data::Matrix, obj::MPMParams, d::Vector{Float64})
MPMSampler(obj, obj, prior, data, true, d)
end
function propose!(obj::MPMSampler, block::Int, sigma::Float64)
nothing
end
function energy(obj::MPMSampler, block::Int=0) #block currently unused
accum = 0.0
accum -= logpdf(InverseWishart(10.0, eye(2)), eye(2))
accum -= sum(logpdf(
DiagNormal(ones(2), ones(2)), ones(2)))
return accum
end
# Everything dealing with TWO classifier objects
function mpm_classifier()
data1 = rand(0:100,4,3)
data2 = rand(0:100,4,3)
kappa = 10.0
d1=20.0
d2=20.0
D = size(data1, 2)
prior = MPM.MPMPrior(D, ones(D), ones(D), kappa, eye(D))
# Class 1
start = MPM.MPMParams(ones(D), eye(D), ones(data1'))
obj_a = MPM.MPMSampler(prior, data1, start, d1)
mymh_a = MPM.AMWGRecord(obj_a)
# Class 2
obj_b = MPM.MPMSampler(prior, data2, start, d2)
mymh_b = MPM.AMWGRecord(obj_b)
BinaryClassifier(obj_a, obj_b, mymh_a, mymh_b)
end
function sample(cls::BinaryClassifier, iters=10000; verbose=false)
sample(cls.mcmc1)
sample(cls.mcmc2)
return nothing
end
end
==32100== Memcheck, a memory error detector
==32100== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==32100== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info
==32100== Command: /home/jason/src/julia/julia testcase.jl
==32100==
==32100== Syscall param msync(start) points to uninitialised byte(s)
==32100== at 0x5EB3B3D: ??? (syscall-template.S:81)
==32100== by 0x5876E98: msync_validate (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x5876FC5: validate_mem (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x5877100: access_mem (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x5874E67: dwarf_get (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x587511E: _ULx86_64_access_reg (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x58749F2: _ULx86_64_get_reg (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x5879A93: apply_reg_state (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x587A166: _ULx86_64_dwarf_find_save_locs (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x58765EB: _ULx86_64_dwarf_step (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x58752B3: _ULx86_64_step (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x4F9558A: rec_backtrace_ctx (task.c:620)
==32100== Address 0xffeff7000 is on thread 1's stack
==32100== Uninitialised value was created by a stack allocation
==32100== at 0x4F954C8: rec_backtrace_ctx (task.c:607)
==32100==
==32100== Syscall param msync(start) points to unaddressable byte(s)
==32100== at 0x5EB3B3D: ??? (syscall-template.S:81)
==32100== by 0x5876E98: msync_validate (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x5876FC5: validate_mem (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x5877100: access_mem (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x5874E67: dwarf_get (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x587511E: _ULx86_64_access_reg (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x58749F2: _ULx86_64_get_reg (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x5879A93: apply_reg_state (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x587A166: _ULx86_64_dwarf_find_save_locs (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x58765EB: _ULx86_64_dwarf_step (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x58752B3: _ULx86_64_step (in /home/jason/src/julia/usr/lib/libjulia-debug.so)
==32100== by 0x4F9558A: rec_backtrace_ctx (task.c:620)
==32100== Address 0xffeff6000 is not stack'd, malloc'd or (recently) free'd
==32100==
1
ERROR: A_k not defined
in _F_ at broadcast.jl:293
in broadcast! at broadcast.jl:227
in logdet2 at linalg/lu.jl:131
in logdet at linalg/lu.jl:136
in _logpdf at /home/jason/.julia/v0.3/Distributions/src/matrix/inversewishart.jl:56
in logpdf at /home/jason/.julia/v0.3/Distributions/src/matrixvariates.jl:16
in energy at /home/jason/test3/uniquename.jl:70
in energy at /home/jason/test3/uniquename.jl:69
in sample at /home/jason/test3/uniquename.jl:101
in anonymous at no file:12
in include at boot.jl:245
in include_from_node1 at loading.jl:128
in process_options at client.jl:285
in _start at client.jl:354
while loading /home/jason/test3/testcase.jl, in expression starting on line 10
==32100==
==32100== HEAP SUMMARY:
==32100== in use at exit: 219,548,245 bytes in 2,289,151 blocks
==32100== total heap usage: 9,034,508 allocs, 6,745,357 frees, 1,870,354,194 bytes allocated
==32100==
==32100== LEAK SUMMARY:
==32100== definitely lost: 940,679 bytes in 1,489 blocks
==32100== indirectly lost: 48 bytes in 6 blocks
==32100== possibly lost: 2,840,829 bytes in 22,838 blocks
==32100== still reachable: 215,766,689 bytes in 2,264,818 blocks
==32100== suppressed: 0 bytes in 0 blocks
==32100== Rerun with --leak-check=full to see details of leaked memory
==32100==
==32100== For counts of detected and suppressed errors, rerun with: -v
==32100== ERROR SUMMARY: 771 errors from 2 contexts (suppressed: 0 from 0)
julia> versioninfo(true)
Julia Version 0.3.2-pre+17
Commit 336bb5e* (2014-09-22 17:20 UTC)
DEBUG build
Platform Info:
System: Linux (x86_64-linux-gnu)
CPU: Intel(R) Xeon(R) CPU X5650 @ 2.67GHz
WORD_SIZE: 64
Ubuntu 14.04.1 LTS
uname: Linux 3.13.0-35-generic #62-Ubuntu SMP Fri Aug 15 01:58:42 UTC 2014 x86_64 x86_64
Memory: 20.101734161376953 GB (16770.421875 MB free)
Uptime: 441614.0 sec
Load Avg: 0.20068359375 0.11181640625 0.3173828125
Intel(R) Xeon(R) CPU X5650 @ 2.67GHz:
speed user nice sys idle irq
#1-12 2617 MHz 1467102 s 8496 s 208580 s 527766098 s 106 s
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Nehalem)
LAPACK: libopenblas
LIBM: libopenlibm
LLVM: libLLVM-3.3
Environment:
TERM = screen-256color
PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
HOME = /home/jason
Package Directory: /home/jason/.julia/v0.3
1 required packages:
- Distributions 0.5.4
3 additional packages:
- ArrayViews 0.4.6
- PDMats 0.2.4
- StatsBase 0.6.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment