# SegFault related to logging

**URL:** <https://discourse.julialang.org/t/segfault-related-to-logging/18260>\
**Category:** General Usage\
**Created:** [December 3, 2018, 6:38pm UTC](https://discourse.julialang.org/t/segfault-related-to-logging/18260 "2018-12-03T18:38:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [December 3, 2018, 6:38pm UTC](https://discourse.julialang.org/t/segfault-related-to-logging/18260/1 "2018-12-03T18:38:28Z")

</div>

Hi fellows,

I am having trouble with my own logger. I am using Julia’s logging system.

and the following write line gives me an error. However the println before it works just fine.

```nohighlight
	    #IOBuffer
	    buf = IOBuffer()
	    iob = Indentable(IOContext(buf),indentlevel=logger[:indentlevel])
	    #iob = IOContext(buf, logger.stream)
	    levelstr = level == Warn ? "Warning" : string(level)
	    msglines = split(chomp(string(message)), '\n')
	    println(iob, "┌ ", levelstr, ": ", msglines[1])
	    
	    for i in 2:length(msglines)
	        println(iob,"│ ", msglines[i])
	    end
	    for (key, val) in kwargs
	        println(iob, "│ ", key, " = ", val)
	    end
	    println(iob, "└ @ ", something(_module, "nothing"), " ",
	            something(filepath, "nothing"), ":", something(line, "nothing"))
	    #println(String(take!(buf)))
	    **write(logger.stream,take!(buf))**

```

and the error is;

```julia
ignal (11): Segmentation fault: 11
in expression starting at no file:0
uv_write2 at /Users/osx/buildbot/slave/package_osx64/build/deps/srccache/libuv-ed3700c849289ed01fe04273a7bf865340b2bd7e/src/unix/stream.c:1432
uv_write at /Users/osx/buildbot/slave/package_osx64/build/deps/srccache/libuv-ed3700c849289ed01fe04273a7bf865340b2bd7e/src/unix/stream.c:1524
jl_uv_write at /Users/osx/buildbot/slave/package_osx64/build/src/jl_uv.c:454
uv_write_async at ./stream.jl:810
uv_write at ./stream.jl:778
flush at ./stream.jl:861
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1829

```

and the lldb says

```julia
Process 56036 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
    frame #0: 0x000000010023c928 libjulia.dylib`uv_write2 + 104
libjulia.dylib`uv_write2:
-> 0x10023c928 <+104>: cmpl $0xc, 0x10(%rax)
    0x10023c92f <+111>: je 0x10023c95e ; <+158>
    0x10023c935 <+117>: movq -0x18(%rbp), %rax
    0x10023c939 <+121>: cmpl $0x7, 0x10(%rax)
Target 0: (julia) stopped.

```
