question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected OOME while loading publicsuffixes.gz

See original GitHub issue

We’re seeing some strange OutOfMemoryExceptions coming from OkHttp 3.9, namely from PublicSuffixDatabase trying to read in publicsuffixes.gz. Rarely but consistently, we’ve seen OOM crashes where, according to the stacktraces, it appears the resource being read in is impossibly large (500 MB+) or the total bytes reported by the created BufferedSource is crazy large too (1.5 GB+).

I don’t have a test or reproduction scenario, as we are only seeing this in production in the crash reports we receive. While there have been instances of crashes from various OS versions and device manufacturers, the vast majority (disproportional from our typical usage distribution) comes from Samsung phones running M.

A couple of sample stacktraces can be found below:

Caused by java.lang.OutOfMemoryError: Failed to allocate a 1768847725 byte allocation with 7394266 free bytes and 490MB until OOM
       at okhttp3.internal.publicsuffix.PublicSuffixDatabase.readTheList(Twttr:319)
       at okhttp3.internal.publicsuffix.PublicSuffixDatabase.readTheListUninterruptibly(Twttr:289)
       at okhttp3.internal.publicsuffix.PublicSuffixDatabase.findMatchingRule(Twttr:110)
       at okhttp3.internal.publicsuffix.PublicSuffixDatabase.getEffectiveTldPlusOne(Twttr:83)
       at okhttp3.Cookie.parse(Twttr:311)
       at okhttp3.Cookie.parse(Twttr:219)
       at okhttp3.Cookie.parseAll(Twttr:445)
       at okhttp3.internal.http.HttpHeaders.receiveHeaders(Twttr:201)
       at okhttp3.internal.http.BridgeInterceptor.intercept(Twttr:95)
       at okhttp3.internal.http.RealInterceptorChain.proceed(Twttr:147)
       at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(Twttr:125)
       at okhttp3.internal.http.RealInterceptorChain.proceed(Twttr:147)
       at okhttp3.internal.http.RealInterceptorChain.proceed(Twttr:121)
       at okhttp3.RealCall.getResponseWithInterceptorChain(Twttr:200)
       at okhttp3.RealCall.execute(Twttr:77)
Caused by java.lang.OutOfMemoryError: Failed to allocate a 535394406 byte allocation with 8388608 free bytes and 239MB until OOM
       at java.io.ByteArrayOutputStream.expand(ByteArrayOutputStream.java:91)
       at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:201)
       at libcore.io.Streams.readFullyNoClose(Streams.java:109)
       at libcore.io.Streams.readFully(Streams.java:95)
       at java.util.jar.JarFile.readMetaEntries(JarFile.java:337)
       at java.util.jar.JarFile.(JarFile.java)
       at libcore.net.url.JarURLConnectionImpl.openJarFile(JarURLConnectionImpl.java:136)
       at libcore.net.url.JarURLConnectionImpl.findJarFile(JarURLConnectionImpl.java:113)
       at libcore.net.url.JarURLConnectionImpl.connect(JarURLConnectionImpl.java:82)
       at libcore.net.url.JarURLConnectionImpl.getInputStream(JarURLConnectionImpl.java:215)
       at java.net.URL.openStream(URL.java:470)
       at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:444)
       at java.lang.Class.getResourceAsStream(Class.java:1175)
       at okhttp3.internal.publicsuffix.PublicSuffixDatabase.readTheList(Twttr:309)
       at okhttp3.internal.publicsuffix.PublicSuffixDatabase.readTheListUninterruptibly(Twttr:289)
       at okhttp3.internal.publicsuffix.PublicSuffixDatabase.findMatchingRule(Twttr:110)
       at okhttp3.internal.publicsuffix.PublicSuffixDatabase.getEffectiveTldPlusOne(Twttr:83)
       at okhttp3.Cookie.parse(Twttr:311)
       at okhttp3.Cookie.parse(Twttr:219)
       at okhttp3.Cookie.parseAll(Twttr:445)
       at okhttp3.internal.http.HttpHeaders.receiveHeaders(Twttr:201)
       at okhttp3.internal.http.BridgeInterceptor.intercept(Twttr:95)
       at okhttp3.internal.http.RealInterceptorChain.proceed(Twttr:147)
       at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(Twttr:125)
       at okhttp3.internal.http.RealInterceptorChain.proceed(Twttr:147)
       at okhttp3.internal.http.RealInterceptorChain.proceed(Twttr:121)
       at okhttp3.RealCall.getResponseWithInterceptorChain(Twttr:200)
       at okhttp3.RealCall.execute(Twttr:77)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JakeWhartoncommented, Nov 4, 2017

Yes. We could switch it to generate a classfile or source file.

On Sat, Nov 4, 2017, 3:25 PM Yuri Schimke notifications@github.com wrote:

Is it better to encode as a field in a class or similar then? Or just live with it?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/square/okhttp/issues/3658#issuecomment-341934123, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEc6hiGYidNPSs1nhaB7rvs3RAnfTks5szORSgaJpZM4P_l7X .

1reaction
yschimkecommented, Nov 1, 2017

Maybe something we should consider avoiding anyway

http://blog.nimbledroid.com/2016/04/06/slow-ClassLoader.getResourceAsStream.html https://github.com/JakeWharton/ThreeTenABP http://blog.danlew.net/2013/08/20/joda_time_s_memory_issue_in_android/

@JakeWharton

Similar to the problems with using Joda-Time on Android, the threetenbp uses a JAR resource for loading timezone information. This is an extremely inefficient mechanism on Android.

This library places the timezone information as a standard Android asset and provides a custom loader for parsing it efficiently.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Crash analysis: Unable to load publicsuffixes.gz resource from ...
The root cause of the crash is that the publicsuffixes.gz file in okhttp is missing from the APK, ... There is only one...
Read more >
xcb: fix issue with dialogs hidden by other windows (Id2c57585)
xcb: fix issue with dialogs hidden by other windows This was a regression from Qt4, due to not setting the window group leader...
Read more >
Analysis Report Imprint Church_apkpure.com.apk
Source: android, String found in binary or memory: ... publicsuffixes.gz, gzip compressed data, from FAT filesystem (MS-DOS, OS/2, NT), 34000.
Read more >
ECS fields | Winlogbeat Reference [8.5] | Elastic
Then it should be duplicated to .ip or .domain , depending on which one it is. ... Typically connections traversing load balancers, firewalls,...
Read more >
PhoneCloneDownloader.apk - Hybrid Analysis
At least one TLS version is required. Ansi based on Hybrid Analysis ... Name: okhttp3/internal/publicsuffix/publicsuffixes.gz. Ansi based on Dropped File ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found