Passing multi-line expression to macro on Raspberry Pi causes seg fault


#1

I am running Julia 0.6.0 as installed from apt on a Raspberry Pi 3 Model B using Raspbian. Whenever I run a multi-line expression passed to a macro e.g.

@p begin
    2 + 2 - 3
end

I get a segmentation fault

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
Segmentation fault

This happens whether I am running “interactively” within the REPL, or I run julia macro.jl from the shell. This does not occur in other begin end blocks, such as

z = begin
    x = 1
    y = 2
    x + y
end

Any thoughts on why this is happening?


#2

Unfortunately, on 0.6 on the Pi, Julia will segfault due to any uncaught exception. This is, I believe, due to a gcc bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728

Maybe that’s what happening here?


#3
pi@toybox:~ $ julia6
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _' |  |
  | | |_| | | | (_| |  |  Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  arm-linux-gnueabihf

shell> uname -a
Linux toybox 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux

shell> cat /etc/issue
Raspbian GNU/Linux 8 \n \l

I am also on Raspbian, Raspberry Pi 3 Model B. but my default Julia is 0.5.1. I had to install 0.6.2 from the generic binaries.

Whith this setup I am unable to reproduce:

julia> macro comment(block) end 
@comment (macro with 1 method)

julia> @comment begin
           1 + 1
       end

julia> macro pass(block) block end
@pass (macro with 1 method)

julia> @pass begin
           1 + 1
       end
2

Could you please share the deffinition of your @b macro? You could check out with 0.6.2 and see if you have the same issue over there.


#4

Thanks for the suggestion - I’ll try updating Julia.

With regard to the macro, @p isn’t a defined macro. I noticed this issue with a separate macro block and wanted to keep the example short.


#5

While short examples are ideal, in the case of bugs, there is also the need of the example to be reproducible.

If updating Julia doesn’t fix this, please try to come up with a minimal reproducible example, so we can help.

Maybe it’s just a specific macro that segfaults?


#6

I don’t get segfaults on my Pi for uncaught exceptions, they just bubble up as expected, do you know if there is an issue tracking this in the Julia repo?


#7

As already said in Passing multi-line expression to macro on Raspberry Pi causes seg fault this is RPI version specific and is caused by throwing an error and not about any macros.


#8

Agreed:

julia> 1 / "0"

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
Segmentation fault

#9

As I said on 0.6.2 on the same hardware? and same OS (freshly updated) I can’t reproduce the segfault.

pi@toybox:~ $ julia6
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _' |  |
  | | |_| | | | (_| |  |  Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  arm-linux-gnueabihf

julia> [1][1000]
ERROR: BoundsError: attempt to access 1-element Array{Int32,1} at index [1000]
Stacktrace:
 [1] getindex(::Array{Int32,1}, ::Int32) at ./array.jl:554

julia> 1/"0"
ERROR: MethodError: no method matching /(::Int32, ::String)
Closest candidates are:
  /(::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}, ::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) at int.jl:38
  /(::Union{Int16, Int32, Int8, UInt16, UInt32, UInt8}, ::BigInt) at gmp.jl:381
  /(::T<:Integer, ::T<:Integer) where T<:Integer at int.jl:36

shell> tail -n 3 /proc/cpuinfo
Hardware	: BCM2835
Revision	: a02082
Serial		: 00000000178d744d

julia> versioninfo()
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
  OS: Linux (arm-linux-gnueabihf)
  CPU: ARMv7 Processor rev 4 (v7l)
  WORD_SIZE: 32
  BLAS: libopenblas (NO_AFFINITY ARMV7)
  LAPACK: libopenblas
  LIBM: libm
  LLVM: libLLVM-3.9.1 (ORCJIT, generic)
Revision Release Date Model PCB Revision Memory Notes
a02082 Q1 2016 3 Model B 1.2 1 GB (Mfg by Sony)

#10

It has nothing to do with the hardware, the OS and the julia version number. It’s a known problem with the “RPI version” of the julia and that’s it.


#11

Oh I didn’t get what you meant by version in this case, thanks!


#12

I’ve opened an issue here: https://github.com/JuliaBerry/julia-raspbian/issues/5

In the meantime, if you are using a Pi 2 or Pi 3 you can simply use the generic ARM v7 binaries from https://julialang.org/downloads/.