From owner-freebsd-chromium@FreeBSD.ORG Fri May 16 20:26:07 2014 Return-Path: Delivered-To: freebsd-chromium@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 360B4DC5 for ; Fri, 16 May 2014 20:26:07 +0000 (UTC) Received: from mail-ee0-x22f.google.com (mail-ee0-x22f.google.com [IPv6:2a00:1450:4013:c00::22f]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ABDD32555 for ; Fri, 16 May 2014 20:26:06 +0000 (UTC) Received: by mail-ee0-f47.google.com with SMTP id c13so1848848eek.6 for ; Fri, 16 May 2014 13:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type; bh=lyxw1n+pcACGioWXx2QbaBy3mipcuphHO0f59ibrEc8=; b=fFd37+UbOaTRtGR8jaAsUssWiLMw7UuTB3Upmlh4lN8w7DOWtCp9Wm2O0hKOPsYWHD 0qWWWNCch8B7hxRLwaXyeNxJM7HFqXOtb1O6zI4uENalXVK1D02/S1yRYk4gYsUeV9QI F7JFFanfABD17dNQfHULdaX9WN2i3b6juVIXTh0kdaqLNR4wD7gtwkjmPKVWySusjlBv xSG/I5bLRHEdjJmw8vdLA+danyQKGnjJeyH3SR2Uwar5fgpttLjpsWVS5jj0IZRZKzPo rMGXycMoSOHhNk43Zp2jRrnJqNa9CAl4ljqQowEFQCvk/WRG+yfSpERKFLUshSddY0Rd /U9g== X-Received: by 10.15.24.201 with SMTP id j49mr6018289eeu.99.1400271964844; Fri, 16 May 2014 13:26:04 -0700 (PDT) Received: from ?IPv6:2001:980:d7ed:1:f96a:615b:6132:2aa7? ([2001:980:d7ed:1:f96a:615b:6132:2aa7]) by mx.google.com with ESMTPSA id w9sm22445547eev.4.2014.05.16.13.26.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 13:26:03 -0700 (PDT) Sender: =?UTF-8?Q?Ren=C3=A9_Ladan?= Message-ID: <5376745A.9050800@freebsd.org> Date: Fri, 16 May 2014 22:26:02 +0200 From: =?ISO-8859-1?Q?Ren=E9_Ladan?= User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: freebsd-chromium@freebsd.org Subject: Re: libffmpeg chromium crashes due to unaligned SSE accesses References: <536CDD30.40104@FreeBSD.org> <7C272AE1-BA6E-48A9-9662-79B1030D0903@FreeBSD.org> <9810619D-DF65-4A4F-9720-B22DC791EA65@FreeBSD.org> <9BF4309C-9D56-467F-B882-754B8C94AA29@FreeBSD.org> In-Reply-To: <9BF4309C-9D56-467F-B882-754B8C94AA29@FreeBSD.org> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------050001070804050701020205" X-Content-Filtered-By: Mailman/MimeDel 2.1.18 X-BeenThere: freebsd-chromium@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: FreeBSD-specific Chromium issues List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 May 2014 20:26:07 -0000 This is a multi-part message in MIME format. --------------050001070804050701020205 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 [continue top-posting ...] Can you try the attached patch (i.e. put in files/ and rebuild chromium) ? % patch < files/patch-third_party__ffmpeg__chromium* % rm work/.configure_done* work/.build_done* work/.stage_done* % make The patch should be invoked on both gcc and clang builds, on amd64 systems this should not rebuild anything. René On 05/13/2014 00:08, Dimitry Andric wrote: > Since I still can't reproduce any crashes with the current > multimedia/ffmpeg port, I made this patch for you to try out. I > think something similar can be applied to the version of ffmpeg > embedded in chromium, but that seems to use yet another NIH build > system of the month. This is probably something for the chromium > maintainers to figure out. > > The basic idea is to to add the following flags, if building with > clang on i386-freebsd (ffmpeg confusingly calls this x86_32, which > is something totally different in the rest of the world): > > -mstack-alignment=16 -mstackrealign > > The former forces clang to assume 16-byte stack alignment, even on > i386, and the latter forces a realignment to 16 bytes at the entry > point of each function. Something similar is probably needed for > gcc, but alignment is broken there anyway... > > -Dimitry > > > > > On 09 May 2014, at 23:53, Adrian Chadd > wrote: > >> Just using it for a day or so. You'll stumble across things like >> moving images in facebook, embedded youtube images, etc, that >> combined with whatever the stack alignment is, results in a >> crash. >> >> I've posted a coredump backtrace. I can generate chromium >> coredumps on my i386 laptop many, many times a day. It's actually >> happening. >> >> >> -a >> >> >> On 9 May 2014 14:49, Dimitry Andric wrote: >>> I think you are referring to the --enable-memalign-hack option >>> passed to ffmpeg's configure script? That is something related >>> to posix_memalign(), not to stack alignment. >>> >>> That said, I just built the chromium port with its default >>> options, and while I cannot get it to crash, I cannot get it to >>> display any video either. It must be because I'm running a >>> VMware guest, and chromium does not cope with that too well >>> (Firefox seems to work much better, though not terribly fast). >>> >>> What kind of activity should make chromium crash? Just running >>> it, or displaying a certain website? >>> >>> -Dimitry >>> >>> On 09 May 2014, at 21:11, Adrian Chadd >>> wrote: >>> >>>> There's an alignment hack option in the ffmpeg port though. >>>> It's not a cflags thing, it's a ./configure thing. >>>> >>>> >>>> >>>> >>>> -a >>>> >>>> >>>> On 9 May 2014 11:40, Dimitry Andric wrote: >>>>> I just tried building multimedia/ffmpeg on i386-freebsd11, >>>>> with the default port settings, and it seems to work just >>>>> fine. I tried transcoding a few files, and there were no >>>>> stack alignment problems or SIGBUSes. >>>>> >>>>> Looking at the build logs, I see >>>>> >>>>> C compiler cc ARCH x86 >>>>> (generic) big-endian no runtime cpu >>>>> detection yes yasm yes MMX enabled >>>>> yes MMXEXT enabled yes 3DNow! enabled >>>>> yes 3DNow! extended enabled yes SSE enabled >>>>> yes SSSE3 enabled yes AVX enabled >>>>> yes FMA4 enabled yes i686 features enabled >>>>> yes CMOV is fast no EBX available >>>>> yes EBP available yes ... >>>>> >>>>> The command line flags used for compilation (wrapped for >>>>> clarity) don't seem to include specific ones that change >>>>> stack alignment behavior: >>>>> >>>>> cc \ -I. \ -I./ \ -DLIBICONV_PLUG \ -D_ISOC99_SOURCE \ >>>>> -D_FILE_OFFSET_BITS=64 \ -D_LARGEFILE_SOURCE \ >>>>> -DHAVE_AV_CONFIG_H \ -O2 \ -pipe \ -march=corei7 \ >>>>> -DLIBICONV_PLUG \ -fno-strict-aliasing \ -msse \ >>>>> -I/usr/local/include/vorbis \ -I/usr/local/include \ >>>>> -std=c99 \ -fomit-frame-pointer \ -I/usr/local/include \ >>>>> -I/usr/local/include/freetype2 \ >>>>> -I/usr/local/include/libpng15 \ -I/usr/local/include \ >>>>> -I/usr/local/include/p11-kit-1 \ >>>>> -I/usr/local/include/freetype2 \ >>>>> -I/usr/local/include/libpng15 \ -I/usr/local/include/opencv >>>>> \ -I/usr/local/include \ >>>>> -I/usr/local/include/schroedinger-1.0 \ >>>>> -I/usr/local/include/orc-0.4 \ >>>>> -Wdeclaration-after-statement \ -Wall \ -Wno-parentheses \ >>>>> -Wno-switch \ -Wno-format-zero-length \ >>>>> -Wdisabled-optimization \ -Wpointer-arith \ >>>>> -Wredundant-decls \ -Wno-pointer-sign \ -Wwrite-strings \ >>>>> -Wtype-limits \ -Wundef \ -Wmissing-prototypes \ >>>>> -Wno-pointer-to-int-cast \ -Wstrict-prototypes \ -O3 \ >>>>> -fno-math-errno \ -fno-signed-zeros \ -Qunused-arguments \ >>>>> -Werror=implicit-function-declaration \ >>>>> -Werror=missing-prototypes \ -Werror=return-type \ -MMD \ >>>>> -c \ >>>>> >>>>> I'll build chromium with the default options, and see what >>>>> happens. >>>>> >>>>> -Dimitry >>>>> >>>>> On 09 May 2014, at 19:09, Adrian Chadd >>>>> wrote: >>>>> >>>>>> What's the magic to get the normal ffmpeg port to work >>>>>> right? >>>>>> >>>>>> >>>>>> -a >>>>>> >>>>>> >>>>>> On 9 May 2014 10:05, Dimitry Andric >>>>>> wrote: >>>>>>> On 09 May 2014, at 18:42, Adrian Chadd >>>>>>> wrote: >>>>>>>> On 9 May 2014 06:50, Pedro Giffuni >>>>>>>> wrote: >>>>>>>>> Hello; >>>>>>>>> >>>>>>>>> El 5/9/2014 5:56 AM, Adrian Chadd escribió: >>>>>>>>> >>>>>>>>>> Hi guys, >>>>>>>>>> >>>>>>>>>> I filed a PR recently with chromium crashes in >>>>>>>>>> its internal libffmpeg: >>>>>>>>>> >>>>>>>>>> http://www.freebsd.org/cgi/query-pr.cgi?pr=189317 >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> What do you two think? It's that Linux 16 byte alignment on i386 issue >>>>>>>>>> that has been creeping up every few years. >>>>>>>>>> >>>>>>>>> >>>>>>>>> Ouch, that's clang, right? >>>>>>>> >>>>>>>> I gather so? It's whatever the binary package >>>>>>>> building cluster is using. I think it's clang for >>>>>>>> i386. >>>>>>> >>>>>>> For 10.x and 11.x, that should indeed be clang. >>>>>>> >>>>>>> >>>>>>>> >>>>>>>>> I recently brought this from OpenBSD, no idea if >>>>>>>>> it's related: >>>>>>>>> >>>>>>>>> http://svnweb.freebsd.org/base?view=revision&revision=265231 >>>>>>>>> >>>>>>>>> >>>>>>>>> For now I guess we should just patch the libffmpeg port like the NetBSD guys >>>>>>>>> did. >>>>>>>> >>>>>>>> Kind of? The x86-64 ABI requires 16 byte alignment >>>>>>>> for a lot of stuff. The i386 32 bit ABI doesn't >>>>>>>> require 16 byte alignment as per everything >>>>>>>> pre-Linux-in-2005ish. Linux / gcc flipped the "i386 >>>>>>>> == 16 byte alignment now" switch. I vaguely recall >>>>>>>> that they made _everything_ 16 byte aligned but I >>>>>>>> can't be sure. >>>>>>> >>>>>>> Yes, actually the gcc guys just flipped the switch >>>>>>> somewhere in 2008, without any consideration for >>>>>>> backwards compatibility, and this lead to quite a bit >>>>>>> of wailing, but they WONTFIXed it anyway: >>>>>>> >>>>>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38496 >>>>>>> >>>>>>> So the problem is that there are quite a lot of >>>>>>> projects that simply assume everything on x86 has >>>>>>> 16-byte aligned stacks, and you can use SSE >>>>>>> instructions that require strict alignment (e.g. >>>>>>> movaps) on any random stack-allocated variable. >>>>>>> Obviously, on i386-freebsd, that is not the case, as we >>>>>>> still maintain the old SysV 4-byte alignment. >>>>>>> >>>>>>> FFmpeg is one of those projects that assumes 16-byte >>>>>>> alignment, and also has a lot of hand-written SSE >>>>>>> assembly, either inline or in separate yasm sources. >>>>>>> The brute-force way of fixing trouble with alignment >>>>>>> is to add -mstackrealign to CFLAGS, but I'm not sure if >>>>>>> that is the correct solution here. >>>>>>> >>>>>>> As far as I know, the current FFmpeg port seems to work >>>>>>> OK on i386-freebsd, so maybe it could be enough to fix >>>>>>> up the Chromium version of FFmpeg in a similar manner >>>>>>> as the regular FFmpeg port? I'm not sure I will have >>>>>>> enough time to have look at it soon, though... >>>>>>> >>>>>>> -Dimitry >>>>>>> >>>>> >>> > -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQJ8BAEBCgBmBQJTdnRZXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxMDFBNzE2QjE2MkIwMEU1NUJFREVBMDVB REJCRjg2MTBBMzc4OUI3AAoJEK27+GEKN4m3pO8P/j3N+F08rGR0EddqyIk0EckM oP529QME5jfHe4st2L4YieROGyTZ52f9FgorcDXja0oKlmqdXQ0gLxRgthHkJNOw UWmLP8x4Dfe8h3lY2BwXijGq9kdu1EV9bXucQpQuArYCvAVqgHC3ZuH9y2E5xmGo xHJrRlelZ8cXUVXmOsBhtTk7Vs13Hj//GLUGUI70M9Uwi3nr7+ZV1/2okmnqsFtO WCiLw8ErRjBZ0dn/xlRdTEpQbzFyCohjKxjGRyrHo3BQcGth6WTvKIQvO7mzxxgC vZr50NNjAHTGYlJZVbyooA28pO2NKl8ykBMIDnxAMTWN5oHfYH2HNOgWq+UWpwRB ukPNrnT0YiOK9k00HKuqMl3v1vupXP95nbEL4xHAirE1xZV7dzoPh/7aN6qfpGS8 K7Azl5/2ADxBh73z8xdPHVPTX/4QcRg7jeSUwkTkRAcj24LEAxWlpgo34Okwa1If wVxjPFqjHOyAT29sLY50SpByqe/uVMzDKsbLEHI9F8u96MeAwbiDDZhq+DSH10uU 0OqcK9KbdkQrCjbmBxL0mIb6ziDtEhgs0gRnT8cMgGgLvbtLQRCqJT4D6djzyevS i1/hv+Rk8mdu8WlJ7J/SpxelBijxZse/E2JCWwt7XaNjHRT/9VI1o0KxBBwPvWTE rPYEDE/EVtis3SKWQ32o =ifpL -----END PGP SIGNATURE----- --------------050001070804050701020205 Content-Type: application/octet-stream; name="patch-third_party__ffmpeg__chromium__config__Chromium__linux__ia32__config.h.sig" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename*0="patch-third_party__ffmpeg__chromium__config__Chromium__linux"; filename*1="__ia32__config.h.sig" iQJ8BAABCgBmBQJTdnRaXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9wZW5wZ3Au ZmlmdGhob3JzZW1hbi5uZXQxMDFBNzE2QjE2MkIwMEU1NUJFREVBMDVBREJCRjg2MTBBMzc4 OUI3AAoJEK27+GEKN4m30DQP/0pH8dirLHgJcYpju2LaKxwFyrFVBWKSbWz4q8b99/Mb7zwo 48U/jO21VW2aC0iDb3NnXVFJOdxJiRVYwZGgTM/Wd3weyVYn1MqoTxhRCChw8pddjC5aM895 xwS5qz8GgcqHitJvno5Dugr8E7+czxyH06QVPyZuGp8TP9izts+xbNlerAAQeEV7/Xnq+kIl 5aDNV0UQIA+RrEu5ygmiUG2sgc6Qd9qEhkw9LclVBOMGOH/kZ7EFuUvtrq5UMKVI64dWE90X v/s6Naf2qAvJs/T6Q6jVtnqWjsKJRWykUFV+wOLfB6wVrCjfSowOObZ6q7LYj/aEyIAHH+DK 6+Uppxq+iKFBWLI7G6Le4gmqYuVWSKSpMA7elMqjvtrwbtpT+DcaQFgpcQgGBwz/yRMUaW6q JEHMT+YVC/307/qmNw0OSTvpYq8Iw+K++c0tKqQxqDg959CefEs7POHZCnoEpxHxQbIvsXfz 0jG5kxJFX1mFL0H524p/JxYWlHh4f1sUYs8XvylfRw89s1AMDehs1/FaYSbzWw2wNWoEZL/g j06YU5tR7FaD5brbkmVPGCUrPs9plQltVLQDSlBT3YyoPE0k8xuRJ38wDTN9gD3ZHTXjok+F 0xcUZMUr0trIvNmogjArfGeHCbk/WPoHnZh7uoYDcECUTlT2qLeu2NK5BKME --------------050001070804050701020205--