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

**URL:** <https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980>\
**Category:** General Usage\
**Created:** [February 10, 2018, 7:49pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980 "2018-02-10T19:49:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacobcvt12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacobcvt12/32/2695_2.png) [@jacobcvt12](https://discourse.julialang.org/u/jacobcvt12)\
**Post date:** [February 10, 2018, 7:49pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/1 "2018-02-10T19:49:44Z")

</div>

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.

```julia
@p begin
    2 + 2 - 3
end

```

I get a segmentation fault

```julia
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

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

```

Any thoughts on why this is happening?

---

<div class="post-metadata">

**Author:** ![avik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/avik/32/17_2.png) [@avik](https://discourse.julialang.org/u/avik)\
**Post date:** [February 10, 2018, 10:05pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/2 "2018-02-10T22:05:46Z")

</div>

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](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728)

Maybe that’s what happening here?

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [February 12, 2018, 4:54pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/3 "2018-02-12T16:54:05Z")

</div>

```julia
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
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.

---

<div class="post-metadata">

**Author:** ![jacobcvt12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacobcvt12/32/2695_2.png) [@jacobcvt12](https://discourse.julialang.org/u/jacobcvt12)\
**Post date:** [February 12, 2018, 8:11pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/4 "2018-02-12T20:11:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [February 12, 2018, 11:18pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/5 "2018-02-12T23:18:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [February 12, 2018, 11:22pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/6 "2018-02-12T23:22:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [February 12, 2018, 11:25pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/7 "2018-02-12T23:25:51Z")

</div>

As already said in [Passing multi-line expression to macro on Raspberry Pi causes seg fault - #2 by avik](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/2) this is RPI version specific and is caused by throwing an error and not about any macros.

---

<div class="post-metadata">

**Author:** ![jacobcvt12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacobcvt12/32/2695_2.png) [@jacobcvt12](https://discourse.julialang.org/u/jacobcvt12)\
**Post date:** [February 13, 2018, 12:03am UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/8 "2018-02-13T00:03:50Z")

</div>

Agreed:

```julia
julia> 1 / "0"

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

```

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [February 13, 2018, 2:10am UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/9 "2018-02-13T02:10:43Z")

</div>

> [@jacobcvt12](#):
>
> Agreed:
> 
> julia\> 1 / “0”
> 
> signal (11): Segmentation fault  
> while loading no file, in expression starting on line 0  
> Segmentation fault

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

```julia
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) |

- [RPi HardwareHistory - eLinux.org](https://elinux.org/RPi_HardwareHistory#Board_Revision_History)

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [February 13, 2018, 2:15pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/10 "2018-02-13T14:15:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [February 13, 2018, 2:28pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/11 "2018-02-13T14:28:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Post date:** [February 13, 2018, 3:26pm UTC](https://discourse.julialang.org/t/passing-multi-line-expression-to-macro-on-raspberry-pi-causes-seg-fault/8980/12 "2018-02-13T15:26:02Z")

</div>

I’ve opened an issue here: [https://github.com/JuliaBerry/julia-raspbian/issues/5](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 [Download Julia](https://julialang.org/downloads/).
