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

NPE in internal.idn.IdnaMappingTable.findRangesOffset #8574

Open
ber4444 opened this issue Nov 13, 2024 · 5 comments
Open

NPE in internal.idn.IdnaMappingTable.findRangesOffset #8574

ber4444 opened this issue Nov 13, 2024 · 5 comments
Labels
bug Bug in existing code

Comments

@ber4444
Copy link

ber4444 commented Nov 13, 2024

       Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'char java.lang.String.charAt(int)' on a null object reference
       at okhttp3.internal.idn.IdnaMappingTable.findRangesOffset(IdnaMappingTable.java:242)
       at okhttp3.internal.idn.IdnaMappingTable.map(IdnaMappingTable.java:130)
       at okhttp3.internal._HostnamesCommonKt.idnToAscii(-HostnamesCommon.kt:322)
       at okhttp3.internal._HostnamesCommonKt.toCanonicalHost(-HostnamesCommon.kt:307)
       at okhttp3.HttpUrl$Builder.parse$okhttp(HttpUrl.java:1448)
       at okhttp3.HttpUrl$Companion.get(HttpUrl.java:1744)
       at okhttp3.HttpUrl$Companion.parse(HttpUrl.java:1754)
       at okhttp3.HttpUrl.parse(HttpUrl.java:34)
       at zipkin2.reporter.okhttp3.InternalOkHttpSender.newEndpoint(InternalOkHttpSender.java:61)
       at zipkin2.reporter.okhttp3.InternalOkHttpSender.newEndpoint(InternalOkHttpSender.java:36)

seeing the above in some Samsung devices in Crashlytics

we are using '5.0.0-alpha.14'... by the way, would love to see a new alpha, it's been 7 months already

@ber4444 ber4444 added the bug Bug in existing code label Nov 13, 2024
@ber4444
Copy link
Author

ber4444 commented Nov 13, 2024


tries to read an index from a String that obviously doesn't exist, easy fix would be to add a sanity test before getting the index

since ranges is String shouldn't this be ranges.codePointAt(entryIndex)?

@yschimke
Copy link
Collaborator

yschimke commented Nov 16, 2024

I don't think that's the right fix. It's hiding a bug in the logic, the VM/compiler, or the build corrupting the file. We can make this code tolerant of corruption, but it's hiding the root problem.

For that to be out of range, it must be one of

  1. Getting a bad position or limit from sections
  2. Some corruption of the data, either on disk or afterwards
  3. a logic (okhttp), compilation (agp) or runtime (oem) bug

Regarding why it's reading a char instead of a codepoint, the encoding is explained at the top of the file. But by this point we are really only looking the compare the last 7 bits of the target.

@yschimke
Copy link
Collaborator

I misread the error. It's even stranger than this.

ranges is created here

internal val IDNA_MAPPING_TABLE: IdnaMappingTable = IdnaMappingTable(
      sections =
          "\u0000\u0000
      ranges =
          "\u0000x--AP
      mappings =
          "\u0020̈\u0020
    )

So there isn't something we can fix. This is set and immutable from creation, before any methods are called.

@yschimke
Copy link
Collaborator

Can you provide more details about the Samsung devices seeing this error? Are they a particular version? A lot of distinct users? Are they jailbroken?

@swankjesse
Copy link
Collaborator

I wonder if packing data into a string is upsetting the runtime somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in existing code
Projects
None yet
Development

No branches or pull requests

3 participants