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

TranslationException: translation context not available #1617

Closed
peckto opened this issue Jul 15, 2024 · 1 comment · Fixed by #1623
Closed

TranslationException: translation context not available #1617

peckto opened this issue Jul 15, 2024 · 1 comment · Fixed by #1623
Assignees
Labels
bug Something isn't working cxx Related to C/C++ language parsing

Comments

@peckto
Copy link
Collaborator

peckto commented Jul 15, 2024

Stack trace

java.util.concurrent.ExecutionException: de.fraunhofer.aisec.cpg.frontends.TranslationException: Could not create type: translation context not available
	at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
	at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
	at de.fraunhofer.aisec.cpg_vis_neo4j.Application.call(Application.kt:610)
	at de.fraunhofer.aisec.cpg_vis_neo4j.Application.call(Application.kt:88)
	at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
	at picocli.CommandLine.access$1500(CommandLine.java:148)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
	at picocli.CommandLine.execute(CommandLine.java:2170)
	at de.fraunhofer.aisec.cpg_vis_neo4j.ApplicationKt.main(Application.kt:651)
Caused by: de.fraunhofer.aisec.cpg.frontends.TranslationException: Could not create type: translation context not available
	at de.fraunhofer.aisec.cpg.graph.TypeBuilderKt.objectType(TypeBuilder.kt:112)
	at de.fraunhofer.aisec.cpg.graph.TypeBuilderKt.objectType$default(TypeBuilder.kt:96)
	at de.fraunhofer.aisec.cpg.passes.CXXExtraPass.convertOperators(CXXExtraPass.kt:119)
	at de.fraunhofer.aisec.cpg.passes.CXXExtraPass.accept$lambda$0(CXXExtraPass.kt:61)
	at de.fraunhofer.aisec.cpg.helpers.SubgraphWalker$ScopedWalker.handleNode(SubgraphWalker.kt:400)
	at de.fraunhofer.aisec.cpg.helpers.SubgraphWalker$ScopedWalker.iterate$lambda$3$lambda$2(SubgraphWalker.kt:383)
	at de.fraunhofer.aisec.cpg.helpers.SubgraphWalker$IterativeGraphWalker.iterate(SubgraphWalker.kt:283)
	at de.fraunhofer.aisec.cpg.helpers.SubgraphWalker$ScopedWalker.iterate(SubgraphWalker.kt:387)
	at de.fraunhofer.aisec.cpg.passes.CXXExtraPass.accept(CXXExtraPass.kt:67)
	at de.fraunhofer.aisec.cpg.passes.CXXExtraPass.accept(CXXExtraPass.kt:47)
	at de.fraunhofer.aisec.cpg.passes.PassKt.executePass(Pass.kt:391)
	at de.fraunhofer.aisec.cpg.TranslationManager.analyzeNonAsync(TranslationManager.kt:102)
	at de.fraunhofer.aisec.cpg.TranslationManager.analyze$lambda$0(TranslationManager.kt:70)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Unexpected behavior

The cpg crashes during CXXExtraPass.

Code of interest

//typedef unsigned char u_int8_t;

int foo(const u_int8_t *p)
{
	u_int8_t *valp;
	*valp = (u_int8_t)*p;
	return 0;
}

Extensions to the library, e.g. added or changed LanguageFrontends or Passes

None

Changes to the configuration

$ cpg-neo4j poc.c

Description

The Language Node does not have a ctx (null) but is expected by LanguageProvider.objectType.

Where does the Language Node come from?
Is it expected to have a context?

@peckto peckto added the cxx Related to C/C++ language parsing label Jul 15, 2024
@oxisto
Copy link
Member

oxisto commented Jul 15, 2024

It is magic and appears out of nowhere sometimes :D And yes it should have a context. I will have a look.

@oxisto oxisto added the bug Something isn't working label Jul 15, 2024
@oxisto oxisto self-assigned this Jul 15, 2024
oxisto added a commit that referenced this issue Jul 19, 2024
This is more a band-aid, than an actually "healing". The issue is that we often use the `language` to get a translation context in passes. But (sometimes) the language does not have it, since it is created using `registerLanguage` even before a translation context exists.

In an attempted fix, I am now using the translation context of a different node, but we should really think about how to deal with that in the future.

Fixes #1617
oxisto added a commit that referenced this issue Jul 22, 2024
This is more a band-aid, than an actually "healing". The issue is that we often use the `language` to get a translation context in passes. But (sometimes) the language does not have it, since it is created using `registerLanguage` even before a translation context exists.

In an attempted fix, I am now using the translation context of a different node, but we should really think about how to deal with that in the future.

Fixes #1617
oxisto added a commit that referenced this issue Jul 22, 2024
Fixed crash in CXXExtraPass::convertOperators

This is more a band-aid, than an actually "healing". The issue is that we often use the `language` to get a translation context in passes. But (sometimes) the language does not have it, since it is created using `registerLanguage` even before a translation context exists.

In an attempted fix, I am now using the translation context of a different node, but we should really think about how to deal with that in the future.

Fixes #1617
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cxx Related to C/C++ language parsing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants