<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>183329</bug_id>
          
          <creation_ts>2018-03-05 06:44:40 -0800</creation_ts>
          <short_desc>Define GIGACAGE_ALLOCATION_CAN_FAIL on Linux</short_desc>
          <delta_ts>2022-11-23 08:59:25 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>bmalloc</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://launchpad.net/bugs/1751460</see_also>
    
    <see_also>https://bugzilla.redhat.com/show_bug.cgi?id=1554873</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=248267</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Gtk, InRadar</keywords>
          <priority>P3</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jeremy Bicha">jbicha</reporter>
          <assigned_to name="Michael Catanzaro">mcatanzaro</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>commit-queue</cc>
    
    <cc>dytynenko.roman</cc>
    
    <cc>fpizlo</cc>
    
    <cc>fweimer</cc>
    
    <cc>ggaren</cc>
    
    <cc>kondor.dani</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>tpopela</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1403608</commentid>
    <comment_count>0</comment_count>
    <who name="Jeremy Bicha">jbicha</who>
    <bug_when>2018-03-05 06:44:40 -0800</bug_when>
    <thetext>Ubuntu 18.04 (pre-Beta) recently upgraded to webkit2gtk 2.19.91. We are receiving lots of crash reports from Deja Dup at https://launchpad.net/bugs/1751460

Deja Dup is versioned 37.1.

Stacktrace
----------
#0  0x00007fac7224d588 in  () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#1  0x00007fac76c64827 in __pthread_once_slow (once_control=0x7fac724b502c, init_routine=0x7fac69330490 &lt;__once_proxy&gt;) at pthread_once.c:116
        _buffer = {__routine = 0x7fac76c64880 &lt;clear_once_control&gt;, __arg = 0x7fac724b502c, __canceltype = 2008932720, __prev = 0x0}
        val = &lt;optimized out&gt;
        newval = &lt;optimized out&gt;
#2  0x00007fac7224ce0d in Gigacage::ensureGigacage() () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#3  0x00007fac7224dd01 in bmalloc::Heap::Heap(bmalloc::HeapKind, std::lock_guard&lt;bmalloc::StaticMutex&gt;&amp;) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#4  0x00007fac7224bb10 in bmalloc::PerProcess&lt;bmalloc::PerHeapKind&lt;bmalloc::Heap&gt; &gt;::getSlowCase() () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#5  0x00007fac7224b7d4 in bmalloc::Cache::Cache(bmalloc::HeapKind) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#6  0x00007fac7224bbf6 in bmalloc::PerThread&lt;bmalloc::PerHeapKind&lt;bmalloc::Cache&gt; &gt;::getSlowCase() () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#7  0x00007fac7224b87f in bmalloc::Cache::allocateSlowCaseNullCache(bmalloc::HeapKind, unsigned long) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#8  0x00007fac72230f56 in WTF::StringImpl::createFromLiteral(char const*, unsigned int) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#9  0x00007fac72230fe1 in WTF::StringImpl::createFromLiteral(char const*) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#10 0x00007fac7223d3c0 in WTF::String::String(WTF::ASCIILiteral) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#11 0x00007fac729f7557 in  () at /usr/lib/x86_64-linux-gnu/libwebkit2gtk-4.0.so.37
#12 0x00007fac779c5733 in call_init (env=0x7ffc3677ae08, argv=0x7ffc3677adf8, argc=1, l=&lt;optimized out&gt;) at dl-init.c:72
        j = &lt;optimized out&gt;
        jm = &lt;optimized out&gt;
        addrs = &lt;optimized out&gt;
        init_array = &lt;optimized out&gt;
        env = 0x7ffc3677ae08
        argv = 0x7ffc3677adf8
        argc = 1
        l = &lt;optimized out&gt;
        preinit_array = &lt;optimized out&gt;
        preinit_array_size = &lt;optimized out&gt;
        i = 6
#13 0x00007fac779c5733 in _dl_init (main_map=0x7fac77bde170, argc=1, argv=0x7ffc3677adf8, env=0x7ffc3677ae08) at dl-init.c:119
        preinit_array = &lt;optimized out&gt;
        preinit_array_size = &lt;optimized out&gt;
        i = 6
#14 0x00007fac779b60ca in _dl_start_user () at /lib64/ld-linux-x86-64.so.2
#15 0x0000000000000001 in  ()
#16 0x00007ffc3677b9c3 in  ()
#17 0x0000000000000000 in  ()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403610</commentid>
    <comment_count>1</comment_count>
    <who name="Jeremy Bicha">jbicha</who>
    <bug_when>2018-03-05 06:45:36 -0800</bug_when>
    <thetext>Thread Stacktrace
=================
.
Thread 1 (Thread 0x7fac77b6aac0 (LWP 3178)):
#0  0x00007fac7224d588 in  () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#1  0x00007fac76c64827 in __pthread_once_slow (once_control=0x7fac724b502c, init_routine=0x7fac69330490 &lt;__once_proxy&gt;) at pthread_once.c:116
        _buffer = {__routine = 0x7fac76c64880 &lt;clear_once_control&gt;, __arg = 0x7fac724b502c, __canceltype = 2008932720, __prev = 0x0}
        val = &lt;optimized out&gt;
        newval = &lt;optimized out&gt;
#2  0x00007fac7224ce0d in Gigacage::ensureGigacage() () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#3  0x00007fac7224dd01 in bmalloc::Heap::Heap(bmalloc::HeapKind, std::lock_guard&lt;bmalloc::StaticMutex&gt;&amp;) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#4  0x00007fac7224bb10 in bmalloc::PerProcess&lt;bmalloc::PerHeapKind&lt;bmalloc::Heap&gt; &gt;::getSlowCase() () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#5  0x00007fac7224b7d4 in bmalloc::Cache::Cache(bmalloc::HeapKind) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#6  0x00007fac7224bbf6 in bmalloc::PerThread&lt;bmalloc::PerHeapKind&lt;bmalloc::Cache&gt; &gt;::getSlowCase() () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#7  0x00007fac7224b87f in bmalloc::Cache::allocateSlowCaseNullCache(bmalloc::HeapKind, unsigned long) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#8  0x00007fac72230f56 in WTF::StringImpl::createFromLiteral(char const*, unsigned int) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#9  0x00007fac72230fe1 in WTF::StringImpl::createFromLiteral(char const*) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#10 0x00007fac7223d3c0 in WTF::String::String(WTF::ASCIILiteral) () at /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#11 0x00007fac729f7557 in  () at /usr/lib/x86_64-linux-gnu/libwebkit2gtk-4.0.so.37
#12 0x00007fac779c5733 in call_init (env=0x7ffc3677ae08, argv=0x7ffc3677adf8, argc=1, l=&lt;optimized out&gt;) at dl-init.c:72
        j = &lt;optimized out&gt;
        jm = &lt;optimized out&gt;
        addrs = &lt;optimized out&gt;
        init_array = &lt;optimized out&gt;
        env = 0x7ffc3677ae08
        argv = 0x7ffc3677adf8
        argc = 1
        l = &lt;optimized out&gt;
        preinit_array = &lt;optimized out&gt;
        preinit_array_size = &lt;optimized out&gt;
        i = 6
#13 0x00007fac779c5733 in _dl_init (main_map=0x7fac77bde170, argc=1, argv=0x7ffc3677adf8, env=0x7ffc3677ae08) at dl-init.c:119
        preinit_array = &lt;optimized out&gt;
        preinit_array_size = &lt;optimized out&gt;
        i = 6
#14 0x00007fac779b60ca in _dl_start_user () at /lib64/ld-linux-x86-64.so.2
#15 0x0000000000000001 in  ()
#16 0x00007ffc3677b9c3 in  ()
#17 0x0000000000000000 in  ()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403614</commentid>
    <comment_count>2</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2018-03-05 06:51:05 -0800</bug_when>
    <thetext>The bt looks similar to the one in https://bugs.webkit.org/show_bug.cgi?id=179914#c39</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403628</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-05 09:08:26 -0800</bug_when>
    <thetext>The failure occurs here:

            // FIXME: Randomize where this goes.
            // https://bugs.webkit.org/show_bug.cgi?id=175245
            void* base = tryVMAllocate(maxAlignment, totalSize);
            if (!base) {
                if (GIGACAGE_ALLOCATION_CAN_FAIL)
                    return;
                fprintf(stderr, &quot;FATAL: Could not allocate gigacage memory with maxAlignment = %lu, totalSize = %lu.\n&quot;, maxAlignment, totalSize);
                BCRASH();
            }

So tryVMAllocate fails. That means bmalloc was unable to allocate virtual memory. That&apos;s not supposed to fail (obviously). Implementation is here:

inline void* tryVMAllocate(size_t vmSize)
{
    vmValidate(vmSize);
    void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | BMALLOC_NORESERVE, BMALLOC_VM_TAG, 0);
    if (result == MAP_FAILED)
        return nullptr;
    return result;
}

So the problem boils down to this mmap call. It&apos;s very strange that this is only happening with Deja Dup. Other applications are unaffected?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403629</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-05 09:13:36 -0800</bug_when>
    <thetext>Jeremy, here&apos;s some debug you could try adding to Source/bmalloc/bmalloc/VMAllocate.h:

// At the top of the file, before the bmalloc namespace
#include &lt;cstring&gt;
#include &lt;errno.h&gt;

inline void* tryVMAllocate(size_t vmSize)
{
    vmValidate(vmSize);
    void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | BMALLOC_NORESERVE, BMALLOC_VM_TAG, 0);
    if (result == MAP_FAILED)
{
WTFLogAlways(&quot;%s: mmap failed: %d (%s)&quot;, __FUNCTION__, errno, strerror(errno));
        return nullptr;
}
    return result;
}

That would tell us which of the many possible errors are occurring here.

And if you need an immediate workaround, you can of course build with -DUSE_SYSTEM_MALLOC=ON. That will be bad, so I can&apos;t recommend that... but you&apos;re already disabling GStreamerGL and web fonts.... :P</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403633</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-05 09:15:35 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #3)
&gt;                 fprintf(stderr, &quot;FATAL: Could not allocate gigacage memory
&gt; with maxAlignment = %lu, totalSize = %lu.\n&quot;, maxAlignment, totalSize);

This might be helpful too. That should also print before the crash.

(In reply to Michael Catanzaro from comment #4)
&gt; inline void* tryVMAllocate(size_t vmSize)
&gt; {
&gt;     vmValidate(vmSize);
&gt;     void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE |
&gt; MAP_ANON | BMALLOC_NORESERVE, BMALLOC_VM_TAG, 0);
&gt;     if (result == MAP_FAILED)
&gt; {
&gt; WTFLogAlways(&quot;%s: mmap failed: %d (%s)&quot;, __FUNCTION__, errno,
&gt; strerror(errno));
&gt;         return nullptr;
&gt; }
&gt;     return result;
&gt; }

I forgot we can&apos;t use WTF here. Got to use fprintf:

fprintf(stderr, &quot;%s: mmap failed: %d (%s)&quot;, __FUNCTION__, errno, strerror(errno));</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403634</commentid>
    <comment_count>6</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-03-05 09:22:47 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #4)
&gt; Jeremy, here&apos;s some debug you could try adding to
&gt; Source/bmalloc/bmalloc/VMAllocate.h:
&gt; 
&gt; // At the top of the file, before the bmalloc namespace
&gt; #include &lt;cstring&gt;
&gt; #include &lt;errno.h&gt;
&gt; 
&gt; inline void* tryVMAllocate(size_t vmSize)
&gt; {
&gt;     vmValidate(vmSize);
&gt;     void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE |
&gt; MAP_ANON | BMALLOC_NORESERVE, BMALLOC_VM_TAG, 0);
&gt;     if (result == MAP_FAILED)
&gt; {
&gt; WTFLogAlways(&quot;%s: mmap failed: %d (%s)&quot;, __FUNCTION__, errno,
&gt; strerror(errno));
&gt;         return nullptr;
&gt; }
&gt;     return result;
&gt; }
&gt; 
&gt; That would tell us which of the many possible errors are occurring here.
&gt; 
&gt; And if you need an immediate workaround, you can of course build with
&gt; -DUSE_SYSTEM_MALLOC=ON. That will be bad, so I can&apos;t recommend that... but
&gt; you&apos;re already disabling GStreamerGL and web fonts.... :P

The immediate fix is disabling Gigacage by setting GIGACAGE_ENABLED 0 in bmalloc/Gigacage.h.
This keeps bmalloc, but disables Gigacage.

My guess is that Linux fails to mmap regions and returns MAP_FAILED if the size is very large.
But I&apos;m not sure right now since it is working on my environment...
Anyway, @mcatanzaro, do you know the way to allocate virtual memory region which does not have actual backing pages?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403646</commentid>
    <comment_count>7</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-03-05 09:48:33 -0800</bug_when>
    <thetext>(In reply to Yusuke Suzuki from comment #6)
&gt; (In reply to Michael Catanzaro from comment #4)
&gt; &gt; Jeremy, here&apos;s some debug you could try adding to
&gt; &gt; Source/bmalloc/bmalloc/VMAllocate.h:
&gt; &gt; 
&gt; &gt; // At the top of the file, before the bmalloc namespace
&gt; &gt; #include &lt;cstring&gt;
&gt; &gt; #include &lt;errno.h&gt;
&gt; &gt; 
&gt; &gt; inline void* tryVMAllocate(size_t vmSize)
&gt; &gt; {
&gt; &gt;     vmValidate(vmSize);
&gt; &gt;     void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE |
&gt; &gt; MAP_ANON | BMALLOC_NORESERVE, BMALLOC_VM_TAG, 0);
&gt; &gt;     if (result == MAP_FAILED)
&gt; &gt; {
&gt; &gt; WTFLogAlways(&quot;%s: mmap failed: %d (%s)&quot;, __FUNCTION__, errno,
&gt; &gt; strerror(errno));
&gt; &gt;         return nullptr;
&gt; &gt; }
&gt; &gt;     return result;
&gt; &gt; }
&gt; &gt; 
&gt; &gt; That would tell us which of the many possible errors are occurring here.
&gt; &gt; 
&gt; &gt; And if you need an immediate workaround, you can of course build with
&gt; &gt; -DUSE_SYSTEM_MALLOC=ON. That will be bad, so I can&apos;t recommend that... but
&gt; &gt; you&apos;re already disabling GStreamerGL and web fonts.... :P
&gt; 
&gt; The immediate fix is disabling Gigacage by setting GIGACAGE_ENABLED 0 in
&gt; bmalloc/Gigacage.h.
&gt; This keeps bmalloc, but disables Gigacage.
&gt; 
&gt; My guess is that Linux fails to mmap regions and returns MAP_FAILED if the
&gt; size is very large.
&gt; But I&apos;m not sure right now since it is working on my environment...
&gt; Anyway, @mcatanzaro, do you know the way to allocate virtual memory region
&gt; which does not have actual backing pages?

My guess is that mmap with READ/WRITE starts populating backing pages and it fails.
I think we potentially have two ways to fix this issue.

The first way is,
1. first allocate region with mmap NO_PROTO
2. set read/write if necessary

But since Darwin is not requiring this mechanism, I think we need to change the current code a bit.
For example, vmAllocate() assumes that returned memory is accessible. But this assumption is slightly broken in Linux if we take this way. We need a bit additional code for Linux.

The second way is
1. first allocate region with mmap NO_PROTO
2. deallocate backing pages
3. set read/write for this region immediately

I&apos;m not sure it works. But if it works, the change should be minimum.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403651</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-05 09:55:48 -0800</bug_when>
    <thetext>One thing I just noticed, from https://bugzilla.gnome.org/show_bug.cgi?id=794056, is that this stack trace is exactly the same as the one valgrind hits when trying to use valgrind to debug epiphany since gigacage was enabled. That&apos;s probably expected, since valgrind attempts to allocate shadow bytes to keep track of the entire address space, which isn&apos;t practical under gigacage.

(In reply to Yusuke Suzuki from comment #6)
&gt; Anyway, @mcatanzaro, do you know the way to allocate virtual memory region
&gt; which does not have actual backing pages?

I have no clue about this. I thought actual backing pages were only employed once the memory region is actually used.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403652</commentid>
    <comment_count>9</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-05 10:00:35 -0800</bug_when>
    <thetext>(In reply to Yusuke Suzuki from comment #6)
&gt; My guess is that Linux fails to mmap regions and returns MAP_FAILED if the
&gt; size is very large.

Keep in mind, we&apos;ve had gigacage enabled and working fine for half a year....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403653</commentid>
    <comment_count>10</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-03-05 10:03:36 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #8)
&gt; One thing I just noticed, from
&gt; https://bugzilla.gnome.org/show_bug.cgi?id=794056, is that this stack trace
&gt; is exactly the same as the one valgrind hits when trying to use valgrind to
&gt; debug epiphany since gigacage was enabled. That&apos;s probably expected, since
&gt; valgrind attempts to allocate shadow bytes to keep track of the entire
&gt; address space, which isn&apos;t practical under gigacage.

It sounds reasonable assumption to me.

&gt; 
&gt; (In reply to Yusuke Suzuki from comment #6)
&gt; &gt; Anyway, @mcatanzaro, do you know the way to allocate virtual memory region
&gt; &gt; which does not have actual backing pages?
&gt; 
&gt; I have no clue about this. I thought actual backing pages were only employed
&gt; once the memory region is actually used.

(In reply to Michael Catanzaro from comment #9)
&gt; (In reply to Yusuke Suzuki from comment #6)
&gt; &gt; My guess is that Linux fails to mmap regions and returns MAP_FAILED if the
&gt; &gt; size is very large.
&gt; 
&gt; Keep in mind, we&apos;ve had gigacage enabled and working fine for half a year....

Yeah, right. If it returns MAP_FAILED due to this issue, we should more constantly see this issue in our daily development. So my guess seems wrong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403672</commentid>
    <comment_count>11</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-05 10:37:00 -0800</bug_when>
    <thetext>Something could be different in Ubuntu, or in Deja Dup specifically?

I&apos;m actually really surprised that Deja Dup now depends on WebKit. Must be via gnome-online-accounts.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403673</commentid>
    <comment_count>12</comment_count>
    <who name="Jeremy Bicha">jbicha</who>
    <bug_when>2018-03-05 10:39:54 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #11)
&gt; I&apos;m actually really surprised that Deja Dup now depends on WebKit. Must be
&gt; via gnome-online-accounts.

Good question. I don&apos;t see any webkit code in Deja Dup but it does use GOA.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406115</commentid>
    <comment_count>13</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-13 09:00:09 -0700</bug_when>
    <thetext>*** Bug 183594 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406120</commentid>
    <comment_count>14</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-13 09:25:25 -0700</bug_when>
    <thetext>So now we have:

 * Our first bug reports against applications other than Deja Dup
 * Our first bug report from a distro other than Ubuntu

Seems like a serious problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406121</commentid>
    <comment_count>15</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-13 09:26:39 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #4)
&gt; Jeremy, here&apos;s some debug you could try adding to
&gt; Source/bmalloc/bmalloc/VMAllocate.h

^ This remains the next step here. We need to know why the mmap() call is failing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406307</commentid>
    <comment_count>16</comment_count>
    <who name="Jeremy Bicha">jbicha</who>
    <bug_when>2018-03-13 17:25:51 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #4)
&gt; Jeremy, here&apos;s some debug you could try adding to
&gt; Source/bmalloc/bmalloc/VMAllocate.h:

webkit2gtk failed to build for me with those lines.

https://launchpad.net/~jbicha/+archive/ubuntu/tempdeja/+sourcepub/8853741/+listing-archive-extra

Build log excerpt
=================

In file included from /&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/SmallPage.h:32:0,
                 from /&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/Deallocator.h:31,
                 from /&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/Cache.h:31,
                 from /&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/bmalloc.h:29,
                 from /&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/BMalloced.h:28,
                 from /&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/IsoHeapImpl.h:28,
                 from /&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/AllIsoHeaps.h:28,
                 from /&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/AllIsoHeaps.cpp:26:
/&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/VMAllocate.h: In function ‘void* tryVMAllocate(size_t)’:
/&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/VMAllocate.h:48:5: error: ‘vmValidate’ was not declared in this scope
     vmValidate(vmSize);
     ^~~~~~~~~~
/&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/VMAllocate.h:49:85: error: ‘BMALLOC_NORESERVE’ was not declared in this scope
     void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | BMALLOC_NORESERVE, BMALLOC_VM_TAG, 0);
                                                                                     ^~~~~~~~~~~~~~~~~
/&lt;&lt;PKGBUILDDIR&gt;&gt;/Source/bmalloc/bmalloc/VMAllocate.h:49:104: error: ‘BMALLOC_VM_TAG’ was not declared in this scope
     void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | BMALLOC_NORESERVE, BMALLOC_VM_TAG, 0);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406309</commentid>
    <comment_count>17</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-13 17:37:08 -0700</bug_when>
    <thetext>(In reply to Jeremy Bicha from comment #16)
&gt; (In reply to Michael Catanzaro from comment #4)
&gt; &gt; Jeremy, here&apos;s some debug you could try adding to
&gt; &gt; Source/bmalloc/bmalloc/VMAllocate.h:
&gt; 
&gt; webkit2gtk failed to build for me with those lines.

Do: keep the two new #includes where you added them, at the top, above the bmalloc namespace

Don&apos;t: add a new definition of tryVMAllocate. Just add the print to the one that already exists, lower in the file. Watch the braces.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406341</commentid>
    <comment_count>18</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-13 19:58:02 -0700</bug_when>
    <thetext>Here&apos;s a debug patch:

diff --git a/Source/bmalloc/bmalloc/VMAllocate.h b/Source/bmalloc/bmalloc/VMAllocate.h
index 713e9c9fbb6..5c9c8553b1a 100644
--- a/Source/bmalloc/bmalloc/VMAllocate.h
+++ b/Source/bmalloc/bmalloc/VMAllocate.h
@@ -35,6 +35,9 @@
 #include &lt;sys/mman.h&gt;
 #include &lt;unistd.h&gt;
 
+#include &lt;cstdio&gt;
+#include &lt;errno.h&gt;
+
 #if BOS(DARWIN)
 #include &lt;mach/vm_page_size.h&gt;
 #include &lt;mach/vm_statistics.h&gt;
@@ -123,7 +126,10 @@ inline void* tryVMAllocate(size_t vmSize)
     vmValidate(vmSize);
     void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | BMALLOC_NORESERVE, BMALLOC_VM_TAG, 0);
     if (result == MAP_FAILED)
+{
+fprintf(stderr, &quot;%s: mmap failed: vmSize=%zu errno=%d (%s)&quot;, __FUNCTION__, vmSize, errno, strerror(errno));
         return nullptr;
+}
     return result;
 }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406365</commentid>
    <comment_count>19</comment_count>
    <who name="Tomas Popela">tpopela</who>
    <bug_when>2018-03-14 01:46:26 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #18)
&gt; Here&apos;s a debug patch:

It&apos;s missing &lt;cstring&gt; include for strerror..

diff -up webkitgtk-2.20.0/Source/bmalloc/bmalloc/VMAllocate.h.bmalloc_debug webkitgtk-2.20.0/Source/bmalloc/bmalloc/VMAllocate.h
--- webkitgtk-2.20.0/Source/bmalloc/bmalloc/VMAllocate.h.bmalloc_debug	2018-02-19 08:45:33.000000000 +0100
+++ webkitgtk-2.20.0/Source/bmalloc/bmalloc/VMAllocate.h	2018-03-14 09:26:14.977674938 +0100
@@ -35,6 +35,10 @@
 #include &lt;sys/mman.h&gt;
 #include &lt;unistd.h&gt;
 
+#include &lt;cstdio&gt;
+#include &lt;errno.h&gt;
+#include &lt;cstring&gt;
+
 #if BOS(DARWIN)
 #include &lt;mach/vm_page_size.h&gt;
 #include &lt;mach/vm_statistics.h&gt;
@@ -122,8 +126,10 @@ inline void* tryVMAllocate(size_t vmSize
 {
     vmValidate(vmSize);
     void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | BMALLOC_NORESERVE, BMALLOC_VM_TAG, 0);
-    if (result == MAP_FAILED)
-        return nullptr;
+    if (result == MAP_FAILED) {
+         fprintf(stderr, &quot;%s: mmap failed: vmSize=%zu errno=%d (%s)&quot;, __FUNCTION__, vmSize, errno, strerror(errno));
+         return nullptr;
+    }
     return result;
 }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406372</commentid>
    <comment_count>20</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-14 06:47:41 -0700</bug_when>
    <thetext>I swear I tested it, but I tested on trunk, so maybe cstring was getting pulled in elsewhere.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406373</commentid>
    <comment_count>21</comment_count>
    <who name="Tomas Popela">tpopela</who>
    <bug_when>2018-03-14 06:53:14 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #20)
&gt; I swear I tested it, but I tested on trunk, so maybe cstring was getting
&gt; pulled in elsewhere.

Nevermind, see Jiri&apos;s response in https://bugzilla.redhat.com/show_bug.cgi?id=1554873#c6. Updating mutter fixed the issue..</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406375</commentid>
    <comment_count>22</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-14 07:04:32 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #15)
&gt; ^ This remains the next step here. We need to know why the mmap() call is
&gt; failing.

Jeremy discovered Deja Dup is setting a virtual memory limit in its desktop file:

Exec=sh -c &quot;ulimit -v 1000000; exec @pkglibexecdir@/deja-dup-monitor&quot;

which is incompatible with Gigacage. It needs to not do that. This is NOTABUG. Good find, Jeremy!

(In reply to Tomas Popela from comment #21)
&gt; Nevermind, see Jiri&apos;s response in
&gt; https://bugzilla.redhat.com/show_bug.cgi?id=1554873#c6. Updating mutter
&gt; fixed the issue..

The mutter update would definitely fix the problem described (app fails to launch another app), but I don&apos;t see how it could possibly be related to the ensureGigacage() backtrace. Anyway, that bug is closed now too... we can always revisit if it becomes a problem again.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406376</commentid>
    <comment_count>23</comment_count>
    <who name="Jeremy Bicha">jbicha</who>
    <bug_when>2018-03-14 07:11:31 -0700</bug_when>
    <thetext>To give some more context about what Deja Dup was doing…

See 
https://salsa.debian.org/gnome-team/deja-dup/blob/debian/master/data/org.gnome.DejaDup.Monitor.desktop.in

which points to https://launchpad.net/bugs/1302416

And here&apos;s the output when I ran the command via webkit2gtk 2.20 built with the debugging patch proposed earlier here

$ ulimit -v 1000000; /usr/lib/deja-dup/deja-dup-monitor
tryVMAllocate: mmap failed: vmSize=154618822656 errno=12 (Cannot allocate memory)
FATAL: Could not allocate gigacage memory with
 maxAlignment = 34359738368, totalSize = 120259084288.
Segmentation fault (core dumped)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406382</commentid>
    <comment_count>24</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-14 07:32:02 -0700</bug_when>
    <thetext>Seb from Ubuntu is worried that people will have set a vmlimit for the entire desktop session, and requests that we improve the error message here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406385</commentid>
    <comment_count>25</comment_count>
      <attachid>335768</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-14 07:41:23 -0700</bug_when>
    <thetext>Created attachment 335768
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406386</commentid>
    <comment_count>26</comment_count>
    <who name="Tomas Popela">tpopela</who>
    <bug_when>2018-03-14 07:43:23 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #25)
&gt; Created attachment 335768 [details]
&gt; Patch

Informal r+ as we spoke together on IRC..</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406409</commentid>
    <comment_count>27</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-14 09:06:59 -0700</bug_when>
    <thetext>Filip, Geoffrey, does this error message look OK to you? Want any adjustments?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406437</commentid>
    <comment_count>28</comment_count>
    <who name="">dytynenko.roman</who>
    <bug_when>2018-03-14 10:39:47 -0700</bug_when>
    <thetext>ulimit -a returned virtual memory unlimited, but I figured out that this error was triggered because I explicitly disabled overcommit by
vm.overcommit_memory = 2
setting it to 1 fixed the issue</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406444</commentid>
    <comment_count>29</comment_count>
      <attachid>335768</attachid>
    <who name="Filip Pizlo">fpizlo</who>
    <bug_when>2018-03-14 10:53:06 -0700</bug_when>
    <thetext>Comment on attachment 335768
Patch

You might want to set GIGACAEG_ALLOCATION_CAN_FAIL to true on Linux until that&apos;s fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1406471</commentid>
    <comment_count>30</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-14 12:46:10 -0700</bug_when>
    <thetext>(In reply to dytynenko.roman from comment #28)
&gt; ulimit -a returned virtual memory unlimited, but I figured out that this
&gt; error was triggered because I explicitly disabled overcommit by
&gt; vm.overcommit_memory = 2
&gt; setting it to 1 fixed the issue

Oh boy...

(In reply to Filip Pizlo from comment #29)
&gt; Comment on attachment 335768 [details]
&gt; Patch
&gt; 
&gt; You might want to set GIGACAEG_ALLOCATION_CAN_FAIL to true on Linux until
&gt; that&apos;s fixed.

I&apos;m not sure what we should do here. We definitely don&apos;t need to change anything for Deja Dup; it&apos;s easier to fix Deja Dup than to update WebKit, anyway. Disabling overcommit is worth considering, though, and the connection between overcommit and browser security is not obvious.

 * If we leave things unchanged, WebKit will crash with overcommit disabled.
 * If we set GIGACAGE_ALLOCATION_CAN_FAIL, WebKit will not crash, but an important security feature will be lost, and users will not notice.

My inclination is to say Gigacage is sufficiently important that WebKit should crash if overcommit is disabled. Perhaps that&apos;s not very kind, though. Thoughts?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1407004</commentid>
    <comment_count>31</comment_count>
      <attachid>335768</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-03-16 09:41:04 -0700</bug_when>
    <thetext>Comment on attachment 335768
Patch

Let&apos;s keep this error message. System administrators should consider the needs of the software they are running before setting virtual memory limits or disabling overcommit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1407020</commentid>
    <comment_count>32</comment_count>
      <attachid>335768</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-03-16 10:06:07 -0700</bug_when>
    <thetext>Comment on attachment 335768
Patch

Clearing flags on attachment: 335768

Committed r229669: &lt;https://trac.webkit.org/changeset/229669&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1407021</commentid>
    <comment_count>33</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-03-16 10:06:09 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1407022</commentid>
    <comment_count>34</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-03-16 10:07:18 -0700</bug_when>
    <thetext>&lt;rdar://problem/38548430&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1407049</commentid>
    <comment_count>35</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-03-16 10:57:40 -0700</bug_when>
    <thetext>(In reply to dytynenko.roman from comment #28)
&gt; ulimit -a returned virtual memory unlimited, but I figured out that this
&gt; error was triggered because I explicitly disabled overcommit by
&gt; vm.overcommit_memory = 2
&gt; setting it to 1 fixed the issue

OVERCOMMIT_NEVER (2) makes mmap&apos;s flag MAP_NORESERVE meaningless.
It makes Gigacage address space allocation failed.
https://github.com/torvalds/linux/blob/master/mm/mmap.c#L1475
So it sounds reasonable to me that vm.overcommit_memory=0 or 1 fixes this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1416832</commentid>
    <comment_count>36</comment_count>
    <who name="Tomas Popela">tpopela</who>
    <bug_when>2018-04-23 01:32:41 -0700</bug_when>
    <thetext>So it looks like there is a way of avoiding this in most cases. Florian Weimer suggested the following in https://bugzilla.redhat.com/show_bug.cgi?id=1570021:


mmap(NULL, 154618822656, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = -1 ENOMEM (Cannot allocate memory)

MAP_NORESERVE does not have the intended effect with vm.overcommit_memory=2 (which enables the beancounter/disables overcommit).

The standard way of reserving address space is to use a PROT_NONE mapping and make parts readable/writable as needed using mprotect later.  This will work with vm.overcommit_memory=2 as well because initially PROT_NONE mappings do not count towards the commit limit.


Yusuke, would you mind looking at this? You seem to know this low level stuff best.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1416853</commentid>
    <comment_count>37</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-04-23 05:59:29 -0700</bug_when>
    <thetext>Of course he notices due to Emacs... OK, reopening.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1422632</commentid>
    <comment_count>38</comment_count>
    <who name="Daniel Kondor">kondor.dani</who>
    <bug_when>2018-05-09 22:33:38 -0700</bug_when>
    <thetext>Hi,

I just started having problems due to this issue recently on Ubuntu 16.04.4 with libjavascriptcoregtk-4.0-18 version 2.20.1-0ubuntu0.16.04.1. Several Gnome 3.18 applications will crash on startup (including Rhythmbox 3.3, yelp, gnome-control-center, unity-control-center 15.04.0+16.04.20171130-0ubuntu1, zenity, but basically anything that depends on WebKit I guess). I get the following (or similar) error message:

FATAL: Could not allocate gigacage memory with maxAlignment = 34359738368, totalSize = 103079215104.
(Make sure you have not set a virtual memory limit.)

Setting the environment variable GIGACAGE_ENABLED=0 is a good workaround.

I have overcommit_memory = 2, and I prefer to have it that way (short reason: I develop and run various programs for scientific computations, which sometimes need a lot of memory -- in my case, it is clearly preferable to have a memory allocation fail, producing a meaningful error message than having a seemingly random crash later or invoking the OOM killer). Nevertheless, I still use Gnome desktop applications, which depend on WebKit, producing this issue. 

My understanding is that the only way to fix this is to use PROT_NONE when allocating address space and later use mprotect() before actually using it. I understand that depending the structure of the code, that could be a lot of work to do for a somewhat specialized use case.

Let me know if I can provide any more info.


Stack trace:

Thread 1 (Thread 0x7ffff7edda80 (LWP 16799)):
#0  0x00007fffeccdb905 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#1  0x00007ffff66b4a99 in __pthread_once_slow (once_control=0x7fffecf49008, 
    init_routine=0x7fffe8aceac0 &lt;__once_proxy&gt;) at pthread_once.c:116
#2  0x00007fffeccdb243 in Gigacage::ensureGigacage() ()
   from /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#3  0x00007fffecce05a8 in bmalloc::mapToActiveHeapKind(bmalloc::HeapKind) ()
   from /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#4  0x00007fffeccd9d3e in bmalloc::Cache::allocateSlowCaseNullCache(bmalloc::HeapKind, unsigned long) ()
   from /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#5  0x00007fffeccbf6f6 in WTF::StringImpl::createFromLiteral(char const*, unsigned int) () from /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#6  0x00007fffeccbf781 in WTF::StringImpl::createFromLiteral(char const*) ()
   from /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#7  0x00007fffecccbc20 in WTF::String::String(WTF::ASCIILiteral) ()
   from /usr/lib/x86_64-linux-gnu/libjavascriptcoregtk-4.0.so.18
#8  0x00007ffff3865a17 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libwebkit2gtk-4.0.so.37
#9  0x00007ffff7de76ba in call_init (l=&lt;optimized out&gt;, argc=argc@entry=1, 
    argv=argv@entry=0x7fffffffe608, env=env@entry=0x7fffffffe618)
    at dl-init.c:72
#10 0x00007ffff7de77cb in call_init (env=0x7fffffffe618, argv=0x7fffffffe608, 
    argc=1, l=&lt;optimized out&gt;) at dl-init.c:30
#11 _dl_init (main_map=0x7ffff7ffe168, argc=1, argv=0x7fffffffe608, 
    env=0x7fffffffe618) at dl-init.c:120
#12 0x00007ffff7dd7c6a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#13 0x0000000000000001 in ?? ()
#14 0x00007fffffffe91c in ?? ()
#15 0x0000000000000000 in ?? ()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1422710</commentid>
    <comment_count>39</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-05-10 07:14:24 -0700</bug_when>
    <thetext>(In reply to Daniel Kondor from comment #38)
&gt; My understanding is that the only way to fix this is to use PROT_NONE when
&gt; allocating address space and later use mprotect() before actually using it.
&gt; I understand that depending the structure of the code, that could be a lot
&gt; of work to do for a somewhat specialized use case.

Yeah, that&apos;s exactly what needs to happen here. I took a look at this, but wasn&apos;t sure where the mprotect()s were needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1422711</commentid>
    <comment_count>40</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-05-10 07:15:27 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #39)
&gt; (In reply to Daniel Kondor from comment #38)
&gt; &gt; My understanding is that the only way to fix this is to use PROT_NONE when
&gt; &gt; allocating address space and later use mprotect() before actually using it.
&gt; &gt; I understand that depending the structure of the code, that could be a lot
&gt; &gt; of work to do for a somewhat specialized use case.
&gt; 
&gt; Yeah, that&apos;s exactly what needs to happen here. I took a look at this, but
&gt; wasn&apos;t sure where the mprotect()s were needed.

I&apos;m a bit worried about this approach in terms of performance...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1423097</commentid>
    <comment_count>41</comment_count>
    <who name="Daniel Kondor">kondor.dani</who>
    <bug_when>2018-05-11 03:01:45 -0700</bug_when>
    <thetext>Just another thought on a potential further implication:
if PROT_NONE was the default and mprotect() used to make individual pages writable / readable, any out of bounds accesses (due to e.g. any bugs / exploits that might come up later) have some chance of triggering a segfault if it falls to another page not reserved with mprotect(). 

Not being familiar with the code, I&apos;m not sure if this would be a feature or if guard pages like this are already implemented. Just to point out that any change will probably have more implications than I originally would have thought :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1425637</commentid>
    <comment_count>42</comment_count>
      <attachid>340850</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-05-21 06:30:57 -0700</bug_when>
    <thetext>Created attachment 340850
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1425647</commentid>
    <comment_count>43</comment_count>
      <attachid>340850</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-05-21 08:11:31 -0700</bug_when>
    <thetext>Comment on attachment 340850
Patch

Well I&apos;m not sure if we should do this, because Gigacage is an important security feature. There are some notes at https://labs.mwrinfosecurity.com/blog/some-brief-notes-on-webkit-heap-hardening/ about all the hardening features that this will silently disable.

But I guess not crashing is good, so r=me.

Did you try Florian&apos;s suggestion? Were there problems with performance?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1426089</commentid>
    <comment_count>44</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-05-22 03:45:55 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #43)
&gt; Comment on attachment 340850 [details]
&gt; Patch
&gt; 
&gt; Well I&apos;m not sure if we should do this, because Gigacage is an important
&gt; security feature. There are some notes at
&gt; https://labs.mwrinfosecurity.com/blog/some-brief-notes-on-webkit-heap-
&gt; hardening/ about all the hardening features that this will silently disable.
&gt; 
&gt; But I guess not crashing is good, so r=me.
&gt; 
&gt; Did you try Florian&apos;s suggestion? Were there problems with performance?

Currently, I&apos;m not trying this.
I think currently this patch is OK since it avoids crashing. And users can enable gigacage by enabling overcommit :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1426092</commentid>
    <comment_count>45</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-05-22 03:49:22 -0700</bug_when>
    <thetext>Committed r232059: &lt;https://trac.webkit.org/changeset/232059&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>335768</attachid>
            <date>2018-03-14 07:41:23 -0700</date>
            <delta_ts>2018-05-21 06:30:55 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-183329-20180314094122.patch</filename>
            <type>text/plain</type>
            <size>1980</size>
            <attacher name="Michael Catanzaro">mcatanzaro</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjI5NTg2CmRpZmYgLS1naXQgYS9Tb3VyY2UvYm1hbGxvYy9D
aGFuZ2VMb2cgYi9Tb3VyY2UvYm1hbGxvYy9DaGFuZ2VMb2cKaW5kZXggMTNjYWQ2MWZjMDBkOTM3
Nzc0NTcxZDAxNDc0MTc1ZGI0ODZiZWE2Yi4uOGYzZTQ3OTVlNzllOGFiNTkyMmIwMjgxMmIwNDVl
MTg3YjcwMDM2OSAxMDA2NDQKLS0tIGEvU291cmNlL2JtYWxsb2MvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9ibWFsbG9jL0NoYW5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pemUpOworICAgICAgICAgICAgICAgIGZwcmludGYoc3RkZXJyLCAiKE1h
a2Ugc3VyZSB5b3UgaGF2ZSBub3Qgc2V0IGEgdmlydHVhbCBtZW1vcnkgbGltaXQuKVxuIik7CiAg
ICAgICAgICAgICAgICAgQkNSQVNIKCk7CiAgICAgICAgICAgICB9CiAK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>340850</attachid>
            <date>2018-05-21 06:30:57 -0700</date>
            <delta_ts>2018-05-21 08:11:31 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-183329-20180521223056.patch</filename>
            <type>text/plain</type>
            <size>1579</size>
            <attacher name="Yusuke Suzuki">ysuzuki</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjMyMDE0CmRpZmYgLS1naXQgYS9Tb3VyY2UvYm1hbGxvYy9D
aGFuZ2VMb2cgYi9Tb3VyY2UvYm1hbGxvYy9DaGFuZ2VMb2cKaW5kZXggODc4MjBhN2I2NzE1N2M5
NDYwNjkzYjQwNjJmZTk0ZmZhODM2ODNlYy4uZDVlMTQxZmIxN2E0YzFjNDYzOWUyZWYwOTNlMTQ1
MDE2NDgwN2NlMCAxMDA2NDQKLS0tIGEvU291cmNlL2JtYWxsb2MvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9ibWFsbG9jL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE2IEBACisyMDE4LTA1LTIxICBZdXN1
a2UgU3V6dWtpICA8dXRhdGFuZS50ZWFAZ21haWwuY29tPgorCisgICAgICAgIEltcHJvdmUgaG93
IEdpZ2FjYWdlIHJlc2VydmVzIGFkZHJlc3Mgc3BhY2Ugb24gTGludXgKKyAgICAgICAgaHR0cHM6
Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE4MzMyOQorCisgICAgICAgIFJldmll
d2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIF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ZSBvZiBSQU0uCisvLyBTbyB3ZSBzcGVjaWZ5IEdJR0FD
QUdFX0FMTE9DQVRJT05fQ0FOX0ZBSUwgPSAxLgorI2lmIEJPUyhMSU5VWCkKKyN1bmRlZiBHSUdB
Q0FHRV9BTExPQ0FUSU9OX0NBTl9GQUlMCisjZGVmaW5lIEdJR0FDQUdFX0FMTE9DQVRJT05fQ0FO
X0ZBSUwgMQorI2VuZGlmCisKIHN0YXRpY19hc3NlcnQoYm1hbGxvYzo6aXNQb3dlck9mVHdvKFBS
SU1JVElWRV9HSUdBQ0FHRV9TSVpFKSwgIiIpOwogc3RhdGljX2Fzc2VydChibWFsbG9jOjppc1Bv
d2VyT2ZUd28oSlNWQUxVRV9HSUdBQ0FHRV9TSVpFKSwgIiIpOwogCg==
</data>
<flag name="review"
          id="359071"
          type_id="1"
          status="+"
          setter="mcatanzaro"
    />
          </attachment>
      

    </bug>

</bugzilla>