Fraunhofer-AISEC / cpg

A library to extract Code Property Graphs from C/C++, Java, Go, Python, Ruby and every other language through LLVM-IR.
https://fraunhofer-aisec.github.io/cpg/
Apache License 2.0
265 stars 61 forks source link

Exception: Numeric value out of range of long #234

Open peckto opened 3 years ago

peckto commented 3 years ago

When loading the https://github.com/mfontanini/libtins C++ library with cpg-vis-neo4j I get an java.lang.IllegalArgumentException when loading the graph into neo4j:

$ ./build/install/cpg-vis-neo4j/bin/cpg-vis-neo4j ~/Downloads/libtins
[...]
Sep. 03, 2020 9:14:35 VORM. org.neo4j.driver.internal.logging.JULogger info
INFORMATION: Direct driver instance 1936502650 created for server address localhost:7687
Exception in thread "main" java.lang.IllegalArgumentException: Numeric value (10958011617037158669) out of range of long (-9223372036854775808 - 9223372036854775807)
 at [Source: UNKNOWN; line: -1, column: -1]
        at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3750)
        at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:3678)
        at org.neo4j.ogm.driver.ParameterConversion$DefaultParameterConversion.convertParameters(ParameterConversion.java:51)
        at org.neo4j.ogm.drivers.bolt.request.BoltRequest.executeRequest(BoltRequest.java:175)
        at org.neo4j.ogm.drivers.bolt.request.BoltRequest.execute(BoltRequest.java:103)
        at org.neo4j.ogm.session.request.RequestExecutor.executeStatements(RequestExecutor.java:131)
        at org.neo4j.ogm.session.request.RequestExecutor.lambda$executeSave$2(RequestExecutor.java:87)
        at org.neo4j.ogm.session.Neo4jSession.lambda$doInTransaction$1(Neo4jSession.java:558)
        at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:590)
        at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:557)
        at org.neo4j.ogm.session.request.RequestExecutor.executeSave(RequestExecutor.java:80)
        at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:90)
        at org.neo4j.ogm.session.Neo4jSession.save(Neo4jSession.java:485)
        at de.fraunhofer.aisec.cpg.ptn4j.Application.pushNodes(Application.kt:109)
        at de.fraunhofer.aisec.cpg.ptn4j.Application.pushToNeo4j(Application.kt:46)
        at de.fraunhofer.aisec.cpg.ptn4j.Application.main(Application.kt:169)
Caused by: com.fasterxml.jackson.core.JsonParseException: Numeric value (10958011617037158669) out of range of long (-9223372036854775808 - 9223372036854775807)
 at [Source: UNKNOWN; line: -1, column: -1]
        at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1804)
        at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:693)
        at com.fasterxml.jackson.core.base.ParserMinimalBase.reportOverflowLong(ParserMinimalBase.java:554)
        at com.fasterxml.jackson.databind.util.TokenBuffer$Parser._convertNumberToLong(TokenBuffer.java:1683)
        at com.fasterxml.jackson.databind.util.TokenBuffer$Parser.getLongValue(TokenBuffer.java:1591)
        at com.fasterxml.jackson.databind.deser.std.StdDeserializer._coerceIntegral(StdDeserializer.java:735)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.deserialize(UntypedObjectDeserializer.java:676)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.mapObject(UntypedObjectDeserializer.java:895)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.deserialize(UntypedObjectDeserializer.java:654)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.mapObject(UntypedObjectDeserializer.java:880)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.deserialize(UntypedObjectDeserializer.java:654)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.mapArray(UntypedObjectDeserializer.java:811)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.deserialize(UntypedObjectDeserializer.java:668)
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:527)
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:364)
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:29)
        at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3745)
        ... 15 more

Afterwards the program seems to hang and I cannot see any further progress.

I use the following TranslationConfiguration:

val translationConfiguration = TranslationConfiguration.builder()
            .sourceLocations(*files)
            .topLevel(topLevel!!)
            .defaultPasses()
            .loadIncludes(true)
            .debugParser(true)
            .build()
oxisto commented 3 years ago

Interesting, may be a problem with the OGM wrapper. Our literal values "scale" up to BigInteger, but maybe nobody told the OGM wrapper to use a big integer and it assumes a long

Masrepus commented 3 years ago

It looks like neo4j OGM only supports signed longs. We could create a converter for big integers that stores the values either as a string or splits them into high and low parts

oxisto commented 3 years ago

Moved to the main cpg repo, as we need to create the OGM converter here, similar to the LocationConverter.