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

'queuePendingMember' causes NPE #68

Closed
fxshlein opened this issue Oct 19, 2023 · 2 comments · Fixed by #105
Closed

'queuePendingMember' causes NPE #68

fxshlein opened this issue Oct 19, 2023 · 2 comments · Fixed by #105
Labels
bug Something isn't working

Comments

@fxshlein
Copy link

There is this bit of code here, which constructs FieldEntry and MethodEntry objects with the source name set to null:

if (isField) {
member = new FieldEntry(currentClass, null, desc);
} else {
member = new MethodEntry(currentClass, null, desc);
}

I think this always causes a null pointer exception, because the parent constructor uses it to construct a key:

this.key = new MemberKey(srcName, srcDesc);

And the constructor of the key in turn calls .hashCode() on the name without checking for null:

if (desc == null) {
hash = name.hashCode();
} else {
hash = name.hashCode() * 257 + desc.hashCode();
}

I suppose, since a key without the name being present probably makes little sense, it would make sense to lazily compute the key as soon as the entry is no longer pending?

Stack trace of the exception:

Caused by: java.lang.NullPointerException: Cannot invoke "String.hashCode()" because "name" is null
	at net.fabricmc.mappingio.tree.MemoryMappingTree$MemberKey.<init>(MemoryMappingTree.java:1683)
	at net.fabricmc.mappingio.tree.MemoryMappingTree$MemberEntry.<init>(MemoryMappingTree.java:1122)
	at net.fabricmc.mappingio.tree.MemoryMappingTree$MethodEntry.<init>(MemoryMappingTree.java:1217)
	at net.fabricmc.mappingio.tree.MemoryMappingTree.queuePendingMember(MemoryMappingTree.java:482)
	at net.fabricmc.mappingio.tree.MemoryMappingTree.visitMethod(MemoryMappingTree.java:459)
	at net.fabricmc.mappingio.adapter.ForwardingMappingVisitor.visitMethod(ForwardingMappingVisitor.java:77)
	at net.fabricmc.mappingio.format.tiny.Tiny2FileReader.readClass(Tiny2FileReader.java:149)
	at net.fabricmc.mappingio.format.tiny.Tiny2FileReader.read(Tiny2FileReader.java:116)
	at net.fabricmc.mappingio.format.tiny.Tiny2FileReader.read(Tiny2FileReader.java:55)
	at net.fabricmc.mappingio.MappingReader.read(MappingReader.java:186)
@NebelNidas
Copy link
Collaborator

It's not a particularly urgent issue, since the use case this was designed to cover wasn't supported previously either and would've crashed anyway.

@fxshlein
Copy link
Author

Yeah I thought as much haha, just wanted to mentioned it. I ran into it because I was trying to hook up mappings wrongly, which "triggered" this feature, after I did it right it worked perfectly.

@modmuss50 modmuss50 added the bug Something isn't working label Dec 7, 2023
NebelNidas added a commit that referenced this issue Sep 9, 2024
- Fix #68
- Make the pending member queue fully functional (both for missing source names and descriptors)
- Extend pending queue to cover classes as well
- Enable incoming data to have inverted namespaces
- Delay descriptor computation until `visitEnd`, so all potentially referenced classes are available
- Fix `MemoryMappingTree#reset` to actually reset all its internal state related to the current visitation pass
- Add protection against external data modification while visitation pass is in progress
- Clarify API contracts regarding returned collections' mutability in Tree-API
- Make Tree-API getters return only unmodifiable collections where possible
- Fix mapping merging via tree-API not overwriting existing entries' data
- Fully implement arg and var merging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants