Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release version of app crashing with out of memory error since upgrading Flutter from v1.0.0 to v1.2.1 #29007

Closed
ghunter99 opened this issue Mar 7, 2019 · 31 comments

Comments

@ghunter99
Copy link

commented Mar 7, 2019

Hi

Since upgrading to the latest stable release of Flutter v1.2.1 from v1.0.0
I'm encountering out of memory crashes when my app runs on devices in release mode.

Prior to upgrading Flutter the app ran reliably and has been downloaded >10,000 times in open beta
in the Play Store without reports reports of crashing.

The error I'm getting when I run using:
flutter run --release --verbose
is
[ +674 ms] E/DartVM ( 2112): ../../third_party/dart/runtime/vm/zone.cc: 50: error: Out of memory.

It occurs less frequently on more powerful devices e.g. Samsung Galaxy S9
and more frequently on less powerful devices e.g. Samsung Galaxy J5 Pro

It can occur when using different parts of the app but it is particularly easy to reproduce
went showing screens that display charts using the charts_flutter package

When I downgrade to Flutter v1.0.0 everything if fine.

Has anybody else been reporting this out of memory error?

Thanks,
Gary

Here's my Flutter doctor output:

[✓] Flutter (Channel beta, v1.2.1, on Mac OS X 10.14.2 18C54, locale en-AU)
• Flutter version 1.2.1 at /Users/garyhunter/Documents/Development/flutter
• Framework revision 8661d8a (3 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/garyhunter/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.4
• CocoaPods version 1.6.0

[✓] Android Studio (version 3.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 33.3.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] Connected device (1 available)
• SM J530Y • 5200803c58ed65eb • android-arm • Android 7.0 (API 24)

• No issues found!

@dnfield

This comment has been minimized.

Copy link
Member

commented Mar 8, 2019

I'm wondering if this could be related to the rendering issues we're seeing when people use flutter_charts with flutter_svg somehow...

@dnfield

This comment has been minimized.

Copy link
Member

commented Mar 8, 2019

@liyuqian

This comment has been minimized.

Copy link
Contributor

commented Mar 8, 2019

Given the information above, it's hard to tell. A single-file Flutter app that reliably reproduces the out-of-memory issue in a less powerful Android device (e.g., we have many MotoG4 in our lab) would tremendously help identify the problem.

@ghunter99

This comment has been minimized.

Copy link
Author

commented Mar 9, 2019

Yes, reproducing the 'out of memory' crash from my description is probably hard.
I was hoping others might be reporting the same issue.
I'll try and create a simple app that reproduces the problem.
I also have a MotoG4 for testing.

@hummer-studio

This comment has been minimized.

Copy link

commented Mar 10, 2019

I have the same problem

@luizgpa

This comment has been minimized.

Copy link

commented Mar 12, 2019

I'm having a similar issue, but in my case, it only occurs if I build the binary (flutter build apk) and manually install it on the device (a Galaxy S6). The apk generated by flutter run --release seems to work fine.
Also, the issue doesn't occur with Flutter version 1.2.0, only with 1.2.1.

Here is a simplified version of my app. It's a section that always crashes with my device within a few taps
https://github.com/luizgpa/memory_crash

The flutter doctor output:

[√] Flutter (Channel unknown, v1.2.1, on Microsoft Windows [Version 10.0.17134.590], locale pt-BR)
• Flutter version 1.2.1 at C:\Projects\flutter
• Framework revision 8661d8a (4 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.

[√] Android Studio (version 3.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 33.3.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[√] Connected device (1 available)
• SM G920I • 06157df643b94731 • android-arm64 • Android 7.0 (API 24)

• No issues found!

@DevonteDC

This comment has been minimized.

Copy link

commented Mar 14, 2019

Also receiving the same issues, but so far it is only happening on certain phones. On Samsung s10+ it works fine, Nexus 6 it is crashing with './../third_party/dart/runtime/vm/zone.cc: 50: error: Out of memory'. I check the actual memory on the phone and there is plenty, and it says the app barely uses any.

Can confirm that it definitely works once I downgraded to Flutter 1.2.0!

@pgulegin

This comment has been minimized.

Copy link

commented Mar 20, 2019

I believe I am having the same issue.
Galaxy Tab A and LG Aristo 2 out of memory crash in release mode, but not in debug mode.
Downgrading to Flutter v1.2.0 corrects the issue.

Here is a link to another ticket I created: #29315
And, a link to reproducing the issue: https://github.com/pgulegin/memory_issue_flutter_1_2_1

@loongliu

This comment has been minimized.

Copy link

commented Mar 28, 2019

Having same issue.
Flutter 1.2.1, Sumsung S8, out of memory in release mode, other test devices are ok.

It may be releated that i used flutter_svg.

@csshuai

This comment has been minimized.

Copy link

commented Mar 28, 2019

I have the same problem

@ymback

This comment has been minimized.

Copy link

commented Mar 29, 2019

I have the same problem
Only happens on some phone
Channel dev 1.3.8
Oppo R11

@mulderpf

This comment has been minimized.

Copy link

commented Mar 30, 2019

I had this same issue reported to me yesterday on a build done on Flutter 1.2.1. My app is fairly large, so I am unable to isolate exactly what caused the issue right now (also unable to recreate it myself as I suspect my test devices are all fairly high-end. It is a production build which works fine on my own devices, but this was a test done by a test lab in South Korea I believe (so the devices might have some additional software on which eats up memory).
Edit: this test lab has also tested all of my previous builds, I cannot guarantee that they ran the same tests, although fairly likely - this is the first time they have reported this (all my previous builds were done with something other than Flutter 1.2.1).

(Initial investigations point that I may have built a long expandable list view which caused it to run out of memory, but I cannot tell for sure).

This is the stack trace which was also sent with it which may or may not be of use:

03-29 11:50:44.738 28353 28380 E DartVM  : ../../third_party/dart/runtime/vm/zone.cc: 50: error: Out of memory.
03-29 11:50:44.738 28353 28380 F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 28380 (1.ui)
03-29 11:50:44.739  2605  2605 W         : debuggerd: handling request: pid=28353 uid=10535 gid=10535 tid=28380
03-29 11:50:44.755  2612  2612 E audit   : type=1400 audit(1553827844.744:682): avc:  denied  { search } for  pid=29368 comm="debuggerd" name="com.mulder.buspal" dev="mmcblk0p22" ino=285673 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir SEPF_SECMOBILE_7.0_0010 audit_filtered
03-29 11:50:44.755  2612  2612 E audit   : type=1300 audit(1553827844.744:682): arch=40000028 syscall=322 per=800008 success=no exit=-13 a0=ffffff9c a1=a7797180 a2=20000 a3=0 items=1 ppid=2605 ppcomm=debuggerd pid=29368 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 ses=4294967295 tty=(none) comm="debuggerd" exe="/system/bin/debuggerd" subj=u:r:debuggerd:s0 key=(null) audit_filtered
03-29 11:50:44.755  2612  2612 E audit   : type=1307 audit(1553827844.744:682):  cwd="/" audit_filtered
03-29 11:50:44.756  2612  2612 E audit   : type=1302 audit(1553827844.744:682): item=0 name=2F646174612F646174612F636F6D2E6D756C6465722E62757370616C2F63616368652F313534323635383733313130382E646578202864656C6574656429 audit_filtered
03-29 11:50:44.756  2612  2612 E audit   : type=1327 audit(1553827844.744:682): proctitle="/system/bin/debuggerd" audit_filtered
03-29 11:50:44.756  2612  2612 E audit   : type=1320 audit(1553827844.744:682):  audit_filtered
03-29 11:50:44.765  2612  2612 E audit   : type=1400 audit(1553827844.759:683): avc:  denied  { search } for  pid=29368 comm="debuggerd" name="com.mulder.buspal" dev="mmcblk0p22" ino=285673 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir SEPF_SECMOBILE_7.0_0010 audit_filtered
03-29 11:50:44.765  2612  2612 E audit   : type=1300 audit(1553827844.759:683): arch=40000028 syscall=322 per=800008 success=no exit=-13 a0=ffffff9c a1=a77978c0 a2=20000 a3=0 items=1 ppid=2605 ppcomm=debuggerd pid=29368 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 ses=4294967295 tty=(none) comm="debuggerd" exe="/system/bin/debuggerd" subj=u:r:debuggerd:s0 key=(null) audit_filtered
03-29 11:50:44.765  2612  2612 E audit   : type=1307 audit(1553827844.759:683):  cwd="/" audit_filtered
03-29 11:50:44.766  2612  2612 E audit   : type=1302 audit(1553827844.759:683): item=0 name="/data/data/com.mulder.buspal/app_flutter/isolate_snapshot_instr" audit_filtered
03-29 11:50:44.766  2612  2612 E audit   : type=1327 audit(1553827844.759:683): proctitle="/system/bin/debuggerd" audit_filtered
03-29 11:50:44.766  2612  2612 E audit   : type=1320 audit(1553827844.759:683):  audit_filtered
03-29 11:50:44.766  2612  2612 E audit   : type=1400 audit(1553827844.759:684): avc:  denied  { search } for  pid=29368 comm="debuggerd" name="com.google.android.gms" dev="mmcblk0p22" ino=65516 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir SEPF_SECMOBILE_7.0_0010 audit_filtered
03-29 11:50:44.766  2612  2612 E audit   : type=1300 audit(1553827844.759:684): arch=40000028 syscall=322 per=800008 success=no exit=-13 a0=ffffff9c a1=a77a8000 a2=20000 a3=0 items=1 ppid=2605 ppcomm=debuggerd pid=29368 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 ses=4294967295 tty=(none) comm="debuggerd" exe="/system/bin/debuggerd" subj=u:r:debuggerd:s0 key=(null) audit_filtered
03-29 11:50:44.766  2612  2612 E audit   : type=1307 audit(1553827844.759:684):  cwd="/" audit_filtered
03-29 11:50:44.766  2612  2612 E audit   : type=1302 audit(1553827844.759:684): item=0 name="/data/user_de/0/com.google.android.gms/app_chimera/m/00000017/oat/arm/dl-AdsFdrDynamite.integ_30000006.odex" audit_filtered
03-29 11:50:44.766  2612  2612 E audit   : type=1327 audit(1553827844.759:684): proctitle="/system/bin/debuggerd" audit_filtered
03-29 11:50:44.766  2612  2612 E audit   : type=1320 audit(1553827844.759:684):  audit_filtered
03-29 11:50:44.780  2612  2612 E audit   : type=1400 audit(1553827844.774:685): avc:  denied  { search } for  pid=29368 comm="debuggerd" name="com.mulder.buspal" dev="mmcblk0p22" ino=285673 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir SEPF_SECMOBILE_7.0_0010 audit_filtered
03-29 11:50:44.780  2612  2612 E audit   : type=1300 audit(1553827844.774:685): arch=40000028 syscall=322 per=800008 success=no exit=-13 a0=ffffff9c a1=a75b61c0 a2=20000 a3=0 items=1 ppid=2605 ppcomm=debuggerd pid=29368 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 ses=4294967295 tty=(none) comm="debuggerd" exe="/system/bin/debuggerd" subj=u:r:debuggerd:s0 key=(null) audit_filtered
03-29 11:50:44.780  2612  2612 E audit   : type=1307 audit(1553827844.774:685):  cwd="/" audit_filtered
03-29 11:50:44.780  2612  2612 E audit   : type=1302 audit(1553827844.774:685): item=0 name="/data/data/com.mulder.buspal/app_flutter/vm_snapshot_instr" audit_filtered
03-29 11:50:44.780  2612  2612 E audit   : type=1327 audit(1553827844.774:685): proctitle="/system/bin/debuggerd" audit_filtered
03-29 11:50:44.780  2612  2612 E audit   : type=1320 audit(1553827844.774:685):  audit_filtered
@yuchuan08

This comment has been minimized.

Copy link

commented Apr 9, 2019

I'm wondering if this could be related to the rendering issues we're seeing when people use flutter_charts with flutter_svg somehow...

I have the same problem,but I have no solution。Now I change flutter version1.1.9(“flutter version force 1.1.9”),the problem is solved,you can try it。

@huagbo

This comment has been minimized.

Copy link

commented Apr 11, 2019

I have the same problem on(samsung S6,oppo R9s)

@magnus-lpa

This comment has been minimized.

Copy link

commented Apr 15, 2019

Same here, crashing with

E/DartVM: ../../third_party/dart/runtime/vm/zone.cc: 50: error: Out of memory.

on lots of different devices, mainly Samsung ones. Only happens on release builds, so I had to enable debuggable="true" in order to get logs. Here's a typical error log when it crashes:

04-15 13:28:02.134 1900-1943/com.example.myapp E/DartVM: ../../third_party/dart/runtime/vm/zone.cc: 50: error: Out of memory.
	
	
	--------- beginning of crash
04-15 13:28:02.134 1900-1943/com.example.myapp A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 1943 (1.ui)
04-15 13:28:02.154 2666-2666/? E/audit: type=1400 audit(1555327682.147:987): avc:  denied  { search } for  pid=1994 comm="debuggerd" name="com.example.myapp" dev="mmcblk0p22" ino=459234 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir SEPF_SECMOBILE_7.0_0010 audit_filtered
04-15 13:28:02.155 2666-2666/? E/audit: type=1300 audit(1555327682.147:987): arch=40000028 syscall=322 per=800008 success=no exit=-13 a0=ffffff9c a1=b0b73690 a2=20000 a3=0 items=1 ppid=2659 ppcomm=debuggerd pid=1994 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 ses=4294967295 tty=(none) comm="debuggerd" exe="/system/bin/debuggerd" subj=u:r:debuggerd:s0 key=(null) audit_filtered
	type=1307 audit(1555327682.147:987):  cwd="/" audit_filtered
	type=1302 audit(1555327682.147:987): item=0 name="/data/data/com.example.myapp/app_flutter/isolate_snapshot_instr" audit_filtered
	type=1327 audit(1555327682.147:987): proctitle="/system/bin/debuggerd" audit_filtered
	type=1320 audit(1555327682.147:987):  audit_filtered
04-15 13:28:02.173 2666-2666/? E/audit: type=1400 audit(1555327682.167:988): avc:  denied  { search } for  pid=1994 comm="debuggerd" name="com.example.myapp" dev="mmcblk0p22" ino=459234 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir SEPF_SECMOBILE_7.0_0010 audit_filtered
	type=1300 audit(1555327682.167:988): arch=40000028 syscall=322 per=800008 success=no exit=-13 a0=ffffff9c a1=b0b17780 a2=20000 a3=0 items=1 ppid=2659 ppcomm=debuggerd pid=1994 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 ses=4294967295 tty=(none) comm="debuggerd" exe="/system/bin/debuggerd" subj=u:r:debuggerd:s0 key=(null) audit_filtered
	type=1307 audit(1555327682.167:988):  cwd="/" audit_filtered
	type=1302 audit(1555327682.167:988): item=0 name="/data/data/com.example.myapp/app_flutter/vm_snapshot_instr" audit_filtered
	type=1327 audit(1555327682.167:988): proctitle="/system/bin/debuggerd" audit_filtered
	type=1320 audit(1555327682.167:988):  audit_filtered
04-15 13:28:02.253 1994-1994/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
	Build fingerprint: 'samsung/gts210ltexx/gts210lte:7.0/NRD90M/T815XXU2CRH1:user/release-keys'
	Revision: '6'
	ABI: 'arm'
04-15 13:28:02.254 1994-1994/? A/DEBUG: pid: 1900, tid: 1943, name: 1.ui  >>> com.example.myapp <<<
	signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
		r0 00000000  r1 00000797  r2 00000006  r3 00000008
		r4 85fad978  r5 00000006  r6 85fad920  r7 0000010c
		r8 7b40f94c  r9 85fabb50  sl 85fabf6c  fp 00000002
		ip 0000000c  sp 85fab188  lr ab3854b7  pc ab387d20  cpsr 600d0010
04-15 13:28:02.277 1994-1994/? A/DEBUG: backtrace:
		#00 pc 0004ad20  /system/lib/libc.so (tgkill+12)
		#01 pc 000484b3  /system/lib/libc.so (pthread_kill+34)
		#02 pc 0001dd89  /system/lib/libc.so (raise+10)
		#03 pc 00019511  /system/lib/libc.so (__libc_android_abort+34)
04-15 13:28:02.278 1994-1994/? A/DEBUG:     #04 pc 00017150  /system/lib/libc.so (abort+4)
		#05 pc 0012d22b  /data/app/com.example.myapp-1/lib/arm/libflutter.so (offset 0x111000)
		#06 pc 004a8829  /data/app/com.example.myapp-1/lib/arm/libflutter.so (offset 0x111000)
		#07 pc 0041e165  /data/app/com.example.myapp-1/lib/arm/libflutter.so (offset 0x111000)
		#08 pc 003fabeb  /data/app/com.example.myapp-1/lib/arm/libflutter.so (offset 0x111000)
		#09 pc 0035514d  /data/app/com.example.myapp-1/lib/arm/libflutter.so (offset 0x111000)
		#10 pc 00354ef7  /data/app/com.example.myapp-1/lib/arm/libflutter.so (offset 0x111000)
		#11 pc 000025e8  /data/data/com.example.myapp/app_flutter/vm_snapshot_instr

It happens in various places in our app, from converting dates using DateFormat to making HTTP requests or simply scrolling in a flutter_markdown widget or zooming in a flutter_map.

Only/mostly seems to happen on Android 7.0 and 7.1. Not sure if there is any correlation, but the one test device we have at our disposal where it crashes is considered an emulator by Flutter for some reason (when doing flutter devices we get SM T815 • xxxxxxxxxxxxxxxxxx • android-arm • Android 7.0 (API 24) (emulator)).

Downgrading to Flutter 1.2.0 (from 1.2.1) "solved" the problem.

@mulderpf

This comment has been minimized.

Copy link

commented Apr 15, 2019

This is causing great frustration and it appears that there are a number of issues raised caused by this. I specifically switched to stable as this is for my production app. I cannot go back to the previous stable version as I need a minimum version of Dart, so the only thing I can do now is to use a non-stable build, but not clear what issues this might cause.

@Hixie

This comment has been minimized.

Copy link
Contributor

commented Apr 15, 2019

If you can reproduce this reliably, please make a copy of your app, then try deleting code bit by bit until you end up having deleted everything you can delete while still reproducing the bug. If it's possible for you to then provide that as a zip file, it would dramatically help us figure out the cause.

@liyuqian

This comment has been minimized.

Copy link
Contributor

commented Apr 16, 2019

BTW, thanks to @jason-simmons and @sjindel-google, we've tested the code in #29007 (comment) using the Moto G4 and Nexus 5X in our lab but couldn't reproduce the problem. We'll try to buy some Galaxy S6 devices so further test it.

@mraleph

This comment has been minimized.

Copy link
Contributor

commented Apr 16, 2019

Based on timeline and stack trace from @loongliu provided on another bug and the fact that it only crashes in AOT modes, this is most likely caused by https://dart-review.googlesource.com/c/sdk/+/92403

********** Crash dump: **********
Build fingerprint: 'samsung/dreamqltezm/dreamqltecmcc:7.0/NRD90M/G9508ZMU2AQK8:user/release-keys'
#00 0x0004b4a0 /system/lib/libc.so (tgkill+12)
#01 0x00048ba3 /system/lib/libc.so (pthread_kill+34)
#02 0x0001e1b9 /system/lib/libc.so (raise+10)
#03 0x000197a5 /system/lib/libc.so (__libc_android_abort+34)
#04 0x00017540 /system/lib/libc.so (abort+4)
#05 0x0012d22b /data/app/com.package.example-1/lib/arm/libflutter.so (offset 0x111000)
                                                                      sk_out_of_memory(unsigned int)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/libcxx/include/memory:3496:5
#06 0x004a8829 /data/app/com.package.example-1/lib/arm/libflutter.so (offset 0x111000)
                                                                      dart::Assert::Fail(char const*, ...)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/platform/assert.cc:43:3
#07 0x0041e165 /data/app/com.package.example-1/lib/arm/libflutter.so (offset 0x111000)
                                                                      dart::Zone::AllocateExpand(int)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/vm/zone.cc:0:0
#08 0x003fabeb /data/app/com.package.example-1/lib/arm/libflutter.so (offset 0x111000)
                                                                      dart::Zone::AllocUnsafe(int)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/vm/zone.h:217:14
                                                                      int* dart::Zone::Alloc<int>(int)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/vm/zone.h:237:0
                                                                      dart::BacktrackStack::BacktrackStack(dart::Zone*)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/vm/regexp_interpreter.cc:131:0
                                                                      dart::IrregexpInterpreter::IrregexpResult dart::RawMatch<unsigned char>(unsigned char const*, dart::String const&, int*, int, unsigned int, dart::Zone*)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/vm/regexp_interpreter.cc:157:0
                                                                      dart::IrregexpInterpreter::Match(dart::TypedData const&, dart::String const&, int*, int, dart::Zone*)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/vm/regexp_interpreter.cc:582:0
                                                                      dart::ExecRaw(dart::RegExp const&, dart::String const&, int, bool, int*, int, dart::Zone*)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/vm/regexp_assembler_bytecode.cc:488:0
                                                                      dart::BytecodeRegExpMacroAssembler::Interpret(dart::RegExp const&, dart::String const&, dart::Smi const&, bool, dart::Zone*)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/vm/regexp_assembler_bytecode.cc:520:0
#09 0x0035514d /data/app/com.package.example-1/lib/arm/libflutter.so (offset 0x111000)
                                                                      dart::ExecuteMatch(dart::Zone*, dart::NativeArguments*, bool)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/lib/regexp.cc:86:10
#10 0x00355279 /data/app/com.package.example-1/lib/arm/libflutter.so (offset 0x111000)
                                                                      dart::DN_HelperRegExp_ExecuteMatchSticky(dart::Isolate*, dart::Thread*, dart::Zone*, dart::NativeArguments*)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/lib/regexp.cc:97:10
                                                                      dart::BootstrapNatives::DN_RegExp_ExecuteMatchSticky(_Dart_NativeArguments*)
                                                                      /b/rr/tmpmr462B/w/src/out/android_release/../../third_party/dart/runtime/lib/regexp.cc:95:0
#11 0x000025e8 /data/data/com.package.example/app_flutter/vm_snapshot_instr

Notice that reproduction from @pgulegin contains RegExp too.

I think we should consider less aggressive allocation strategy for backtracking stack, e.g. we could try growing it dynamically.

/cc @rmacnak-google

@rmacnak-google

This comment has been minimized.

Copy link
Contributor

commented Apr 16, 2019

The backtracing stack is only 256k, and there is only one (per isolate) at a time. If this is the first run of this particular regexp, the bytecode compilation will have used the same Zone that the backtracing stack is failing to be allocated into. My guess is regexp compilation requires more memory.

@mraleph

This comment has been minimized.

Copy link
Contributor

commented Apr 16, 2019

That might be the reason, however I also feel that we should be more careful and try to handle situation where we can't allocate large amount of memory more gracefully. I also wonder if there is some sort of fragmentation going on inside jemalloc? Some searching around reveals that in Android 7 jemalloc was configured to use chunk size of 256kib - which coincidedentally matches our backtracking stack size.

Maybe we should also consider dumping malloc information whenever malloc fails? e.g. via malloc_stats_print or malloc_info.

@Hixie

This comment has been minimized.

Copy link
Contributor

commented Apr 16, 2019

I was thinking about this earlier and one thing that surprised me was that we're crashing, as opposed to throwing an OutOfMemoryError in Dart. Is that not something the VM does?

@Hixie Hixie added this to the Scheduled customer work milestone Apr 16, 2019

@mraleph

This comment has been minimized.

Copy link
Contributor

commented Apr 17, 2019

@Hixie when Zone allocation fails internal VM state might be in the inconsistent state, so I don't think throwing OOM an arbitrary native memory allocation failure is an option. However I would think we should be more "user friendly" around certain allocations, like this one, and actually report an error instead of crashing.

@liyuqian

This comment has been minimized.

Copy link
Contributor

commented Apr 22, 2019

Could #28037 be related?

@jason-simmons

This comment has been minimized.

Copy link
Contributor

commented Apr 23, 2019

I obtained a Galaxy S6 and was able to reproduce a crash by typing in the text field in the memory_issue_flutter_1_2_1 app.

The stack trace is in the Dart regexp code:

third_party/dart/runtime/platform/assert.cc:43
third_party/dart/runtime/vm/zone.h:217 [Zone::AllocUnsafe]
third_party/dart/runtime/vm/regexp_assembler_bytecode.cc:495 [ExecRaw]
third_party/dart/runtime/lib/regexp.cc:102
third_party/dart/runtime/lib/regexp.cc:108

dart-bot pushed a commit to dart-lang/sdk that referenced this issue Apr 25, 2019

[vm, irregexp] Cache the backtracking stack on the isolate to avoid m…
…emory leaks in jemalloc.

Bug: flutter/flutter#29007
Change-Id: Ic08e6cdad087cb063350b0738a65f426e67864d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100500
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
@liyuqian

This comment has been minimized.

Copy link
Contributor

commented Apr 26, 2019

@jason-simmons : is this related to #31303 (and #31498) or not?

@jason-simmons

This comment has been minimized.

Copy link
Contributor

commented Apr 26, 2019

No - the Zone assertion and the Dart regex execution stack trace were not seen in those issues

@mraleph

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2019

@rmacnak-google's fix was rolled into Flutter.

To everybody experiencing the problem: please try master channel, the problem should now be fixed.

@mraleph mraleph closed this Apr 29, 2019

@mraleph

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2019

@Hixie @eseidel should Dart fix for this issue be cherry picked in Dart 2.3 in your opinion?

@Hixie

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2019

I wouldn't worry about cherry picking, but I would make sure it is tested so we don't regress it. Is this bug covered by any of our benchmarks or tests?

@loongliu

This comment has been minimized.

Copy link

commented Apr 30, 2019

Is there any quick fix like cherry-pick based on v1.2.1
Switch flutter version before application release is not acceptable.

dart-bot pushed a commit to dart-lang/sdk that referenced this issue Apr 30, 2019

[vm] Bypass malloc for large Zone allocations to avoid jemalloc leaks.
Revert 9a07ad8.

Bug: flutter/flutter#29007
Change-Id: I6a5f51f0c3a54d354ec5f8495677d46f94d8a1d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100568
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

aam added a commit to aam/engine that referenced this issue Apr 30, 2019

dart-bot pushed a commit to dart-lang/sdk that referenced this issue Apr 30, 2019

[vm] Bypass malloc for large Zone allocations to avoid jemalloc leaks.
Revert 9a07ad8.

Bug: flutter/flutter#29007
Change-Id: I6a5f51f0c3a54d354ec5f8495677d46f94d8a1d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100568
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

aam added a commit to flutter/engine that referenced this issue Apr 30, 2019

Roll to branched dart sdk with two more hotfixes for flutter 1.5.4. (#…
…8790)

* Roll to branched dart sdk with two more hotfixes for fluter 1.5.4.

Cherry-picks for flutter/flutter#29007 and VERSION file bump.

* Update license hash

Letty-Liang pushed a commit to Letty-Liang/dartsdk that referenced this issue May 14, 2019

[vm] Bypass malloc for large Zone allocations to avoid jemalloc leaks.
Revert 9a07ad88f494ca81030172c07b47d54a0f46f822.

Bug: flutter/flutter#29007
Change-Id: I6a5f51f0c3a54d354ec5f8495677d46f94d8a1d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100568
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.