Andras Gyomrey | 12 Dec 17:54 2012
Picon

Yesod double free or corruption

Hi,

i got the following error using "yesod devel" it happened after adding the file which seems to have invalid content (not true). What should i do?

Andras Gyomrey

Yesod devel server. Press ENTER to quit
yesod: ./Handler/Model/Season.hs: hGetContents: invalid argument (invalid byte sequence)
*** glibc detected *** yesod: double free or corruption (out): 0x00002b5fe0006b10 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x75916)[0x2b5fda07b916]
/lib64/libc.so.6(+0x78443)[0x2b5fda07e443]
/lib64/libc.so.6(+0x203c6)[0x2b5fda0263c6]
/lib64/libc.so.6(iconv_close+0xf)[0x2b5fda02595f]
yesod[0x317d93a]
======= Memory map: ========
00400000-035a6000 r-xp 00000000 00:1b 112951588                          /home/paxer/.cabal/bin/yesod
037a5000-03bc1000 rwxp 031a5000 00:1b 112951588                          /home/paxer/.cabal/bin/yesod
03bc1000-03bca000 rwxp 03bc1000 00:00 0
05e7f000-05ec1000 rwxp 05e7f000 00:00 0                                  [heap]
2b5fd8ec1000-2b5fd8ee1000 r-xp 00000000 00:1b 99617724                   /lib64/ld-2.12.so
2b5fd8eef000-2b5fd8ef0000 rwxp 2b5fd8eef000 00:00 0
2b5fd90e0000-2b5fd90e1000 r-xp 0001f000 00:1b 99617724                   /lib64/ld-2.12.so
2b5fd90e1000-2b5fd90e2000 rwxp 00020000 00:1b 99617724                   /lib64/ld-2.12.so
2b5fd90e2000-2b5fd90e3000 rwxp 2b5fd90e2000 00:00 0
2b5fd90e3000-2b5fd90f8000 r-xp 00000000 00:1b 99617828                   /lib64/libz.so.1.2.3
2b5fd90f8000-2b5fd92f7000 ---p 00015000 00:1b 99617828                   /lib64/libz.so.1.2.3
2b5fd92f7000-2b5fd92f8000 r-xp 00014000 00:1b 99617828                   /lib64/libz.so.1.2.3
2b5fd92f8000-2b5fd92f9000 rwxp 00015000 00:1b 99617828                   /lib64/libz.so.1.2.3
2b5fd92f9000-2b5fd9300000 r-xp 00000000 00:1b 99628779                   /lib64/librt-2.12.so
2b5fd9300000-2b5fd94ff000 ---p 00007000 00:1b 99628779                   /lib64/librt-2.12.so
2b5fd94ff000-2b5fd9500000 r-xp 00006000 00:1b 99628779                   /lib64/librt-2.12.so
2b5fd9500000-2b5fd9501000 rwxp 00007000 00:1b 99628779                   /lib64/librt-2.12.so
2b5fd9501000-2b5fd9503000 r-xp 00000000 00:1b 99625968                   /lib64/libutil-2.12.so
2b5fd9503000-2b5fd9702000 ---p 00002000 00:1b 99625968                   /lib64/libutil-2.12.so
2b5fd9702000-2b5fd9703000 r-xp 00001000 00:1b 99625968                   /lib64/libutil-2.12.so
2b5fd9703000-2b5fd9704000 rwxp 00002000 00:1b 99625968                   /lib64/libutil-2.12.so
2b5fd9704000-2b5fd9705000 rwxp 2b5fd9704000 00:00 0
2b5fd9705000-2b5fd9707000 r-xp 00000000 00:1b 99623838                   /lib64/libdl-2.12.so
2b5fd9707000-2b5fd9907000 ---p 00002000 00:1b 99623838                   /lib64/libdl-2.12.so
2b5fd9907000-2b5fd9908000 r-xp 00002000 00:1b 99623838                   /lib64/libdl-2.12.so
2b5fd9908000-2b5fd9909000 rwxp 00003000 00:1b 99623838                   /lib64/libdl-2.12.so
2b5fd9909000-2b5fd995f000 r-xp 00000000 00:1b 99624917                   /usr/lib64/libgmp.so.3.5.0
2b5fd995f000-2b5fd9b5f000 ---p 00056000 00:1b 99624917                   /usr/lib64/libgmp.so.3.5.0
2b5fd9b5f000-2b5fd9b64000 rwxp 00056000 00:1b 99624917                   /usr/lib64/libgmp.so.3.5.0
2b5fd9b64000-2b5fd9be7000 r-xp 00000000 00:1b 99625157                   /lib64/libm-2.12.so
2b5fd9be7000-2b5fd9de6000 ---p 00083000 00:1b 99625157                   /lib64/libm-2.12.so
2b5fd9de6000-2b5fd9de7000 r-xp 00082000 00:1b 99625157                   /lib64/libm-2.12.so
2b5fd9de7000-2b5fd9de8000 rwxp 00083000 00:1b 99625157                   /lib64/libm-2.12.so
2b5fd9de8000-2b5fd9de9000 rwxp 2b5fd9de8000 00:00 0
2b5fd9de9000-2b5fd9e00000 r-xp 00000000 00:1b 99617779                   /lib64/libpthread-2.12.so
2b5fd9e00000-2b5fda000000 ---p 00017000 00:1b 99617779                   /lib64/libpthread-2.12.so
2b5fda000000-2b5fda001000 r-xp 00017000 00:1b 99617779                   /lib64/libpthread-2.12.so
2b5fda001000-2b5fda002000 rwxp 00018000 00:1b 99617779                   /lib64/libpthread-2.12.so
2b5fda002000-2b5fda006000 rwxp 2b5fda002000 00:00 0
2b5fda006000-2b5fda18f000 r-xp 00000000 00:1b 99617771                   /lib64/libc-2.12.so
2b5fda18f000-2b5fda38f000 ---p 00189000 00:1b 99617771                   /lib64/libc-2.12.so
2b5fda38f000-2b5fda393000 r-xp 00189000 00:1b 99617771                   /lib64/libc-2.12.so
2b5fda393000-2b5fda394000 rwxp 0018d000 00:1b 99617771                   /lib64/libc-2.12.so
2b5fda394000-2b5fda39b000 rwxp 2b5fda394000 00:00 0
2b5fda400000-2b5fda500000 rwxp 2b5fda400000 00:00 0
2b5fda500000-2b5fda501000 ---p 2b5fda500000 00:00 0
2b5fda501000-2b5fdaf01000 rwxp 2b5fda501000 00:00 0
2b5fdaf01000-2b5fdaf08000 r-xs 00000000 00:1b 99630484                   /usr/lib64/gconv/gconv-modules.cache
2b5fdaf08000-2b5fdaf0a000 r-xp 00000000 00:1b 99625937                   /usr/lib64/gconv/UTF-32.so
2b5fdaf0a000-2b5fdb109000 ---p 00002000 00:1b 99625937                   /usr/lib64/gconv/UTF-32.so
2b5fdb109000-2b5fdb10a000 r-xp 00001000 00:1b 99625937                   /usr/lib64/gconv/UTF-32.so
2b5fdb10a000-2b5fdb10b000 rwxp 00002000 00:1b 99625937                   /usr/lib64/gconv/UTF-32.so
2b5fdb10b000-2b5fdb10c000 ---p 2b5fdb10b000 00:00 0
2b5fdb10c000-2b5fdbb0c000 rwxp 2b5fdb10c000 00:00 0
2b5fdc000000-2b5fdc021000 rwxp 2b5fdc000000 00:00 0
2b5fdc021000-2b5fe0000000 ---p 2b5fdc021000 00:00 0
2b5fe0000000-2b5fe0045000 rwxp 2b5fe0000000 00:00 0
2b5fe0045000-2b5fe4000000 ---p 2b5fe0045000 00:00 0
2b5fe4000000-2b5fe4001000 ---p 2b5fe4000000 00:00 0
2b5fe4001000-2b5fe4a02000 rwxp 2b5fe4001000 00:00 0
2b5fe4b00000-2b5fe4d00000 rwxp 2b5fe4b00000 00:00 0
2b5fe4d00000-2b5fe4d16000 r-xp 00000000 00:1b 99630780                   /lib64/libgcc_s-4.4.6-20120305.so.1
2b5fe4d16000-2b5fe4f15000 ---p 00016000 00:1b 99630780                   /lib64/libgcc_s-4.4.6-20120305.so.1
2b5fe4f15000-2b5fe4f16000 rwxp 00015000 00:1b 99630780                   /lib64/libgcc_s-4.4.6-20120305.so.1
2b5fe8000000-2b5fe8021000 rwxp 2b5fe8000000 00:00 0
2b5fe8021000-2b5fec000000 ---p 2b5fe8021000 00:00 0
7ffffce38000-7ffffce4d000 rwxp 7ffffffe9000 00:00 0                      [stack]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0                  [vdso]
Aborted
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Manuel Gómez | 12 Dec 23:53 2012
Picon

Re: Yesod double free or corruption

On Wed, Dec 12, 2012 at 12:24 PM, Andras Gyomrey <lgandras <at> gmail.com> wrote:
> Hi,
>
> i got the following error using "yesod devel" it happened after adding the
> file which seems to have invalid content (not true). What should i do?

The first bit of your error message indeed indicates
`./Handler/Model/Season.hs` isn’t encoded as `hGetContents` expects:

> yesod: ./Handler/Model/Season.hs: hGetContents: invalid argument (invalid byte sequence)

`System.IO.hGetContents` converts into Unicode from the default
encoding configured in your system unless explicitly told otherwise
with `hSetEncoding`[1].  You can check what this encoding is with the
GHC primitive `GHC.IO.Encoding.getLocaleEncoding`[2], or with the
somewhat less reliable `System.IO.localeEncoding` runtime constant.

This StackOverflow answer has some good pointers on inference and
validation of file encoding: <http://unix.stackexchange.com/a/11648>

The simplest solution is, of course, to set your system encoding to
UTF‐8, and make sure your source code is encoded accordingly.  GNU
iconv is quite handy for encoding conversions.  Remember to tell your
editor to default to UTF‐8 in case it doesn’t detect the system
encoding — or better yet, switch to a better editor that does.

The heap corruption does indeed indicate a bug somewhere, though not
necessarily in Yesod code.  If I understand this correctly, the
exception is uncaught (and printed by the default uncaught exception
handler[4] that, in turn, calls `errorBelch` in the RTS[5]) and the
heap corruption becomes evident only later during the GHC runtime’s
cleanup, whatever that may be.

[1]: <http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#g:23>
[2]: <http://www.haskell.org/ghc/docs/latest/html/libraries/base/GHC-IO-Encoding.html#v:getLocaleEncoding>
[3]: <http://www.gnu.org/savannah-checkouts/gnu/libiconv/documentation/libiconv-1.13/iconv.1.html>
[4]: <http://hackage.haskell.org/packages/archive/base/4.2.0.0/doc/html/src/GHC-Conc.html#uncaughtExceptionHandler>
[5]: Lines 34 and 174–202 of <rts/RTSMessages.c> in the GHC source
<http://darcs.haskell.org/ghc.git/rts/RtsMessages.c>

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane