vivkin / gason

Lightweight and fast JSON parser for C++
MIT License
338 stars 51 forks source link

Assertion `(uint64_t)payload <= 0x00007FFFFFFFFFFFULL' failed #20

Closed Trigger-broom-289 closed 9 years ago

Trigger-broom-289 commented 9 years ago

Greetings,

I'm trying this gasoncpp on an Odroid-C1 and get the following error while parsing a json file:

root@heidenrod-obs:/Astro/obs-dev/gason# ./gasonpp canada.json gasonpp: /Astro/obs-dev/gason/src/gason.h:32: JsonValue::JsonValue(JsonTag, void*): Assertion `(uint64_t)payload <= 0x00007FFFFFFFFFFFULL' failed. root@heidenrod-obs:/Astro/obs-dev/gason#

Here's the full gdb bt:

root@heidenrod-obs:/Astro/obs-dev/gason# gdb --eval-command="set follow-fork-mode child" --args ./gasonpp canada.json GNU gdb (Ubuntu 7.9-1ubuntu1) 7.9 Copyright (C) 2015 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "arm-linux-gnueabihf". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./gasonpp...done. (gdb) run Starting program: /Astro/obs-dev/gason/gasonpp canada.json gasonpp: /Astro/obs-dev/gason/src/gason.h:32: JsonValue::JsonValue(JsonTag, void*): Assertion `(uint64_t)payload <= 0x00007FFFFFFFFFFFULL' failed.

Program received signal SIGABRT, Aborted. __libc_do_syscall () at ../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:47 47 ../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S: No such file or directory. (gdb) bt

0 __libc_do_syscall () at ../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:47

1 0xb6f0062e in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55

2 0xb6f01332 in __GI_abort () at abort.c:89

3 0xb6efb98a in __assert_fail_base (fmt=0x1 <error: Cannot access memory at address 0x1>,

assertion=0x12ea4 "(uint64_t)payload <= 0x00007", 'F' <repeats 11 times>, "ULL", 
assertion@entry=0x2 <error: Cannot access memory at address 0x2>, file=file@entry=0xb6ffa390 "", line=32, line@entry=3069997192, 
function=function@entry=0x13084 <JsonValue::JsonValue(JsonTag, void*)::__PRETTY_FUNCTION__> "JsonValue::JsonValue(JsonTag, void*)")
at assert.c:92

4 0xb6efba22 in __GI___assert_fail (assertion=0x2 <error: Cannot access memory at address 0x2>, file=0xb6ffa390 "", line=3069997192,

function=0x13084 <JsonValue::JsonValue(JsonTag, void*)::__PRETTY_FUNCTION__> "JsonValue::JsonValue(JsonTag, void*)") at assert.c:101

5 0x00011994 in JsonValue::JsonValue (this=0xbefff498, tag=JSON_STRING, payload=0xb671700b) at /Astro/obs-dev/gason/src/gason.h:32

6 0x00012474 in jsonParse (

s=0xb671700b "type\": \"FeatureCollection\",\r\n  \"features\": [\r\n{\r\n    \"type\": \"Feature\",\r\n\"properties\": { \"name\": \"Canada\" },\r\n\"geometry\": {\"type\":\"Polygon\",\"coordinates\":[[[-65.613616999999977,43.420273000000009],[-6"..., endptr=0xbefff64c, value=0xbefff668, 
allocator=...) at /Astro/obs-dev/gason/src/gason.cpp:175

7 0x000118d4 in main (argc=2, argv=0xbefff7e4) at /Astro/obs-dev/gason/src/pretty-print.cpp:183

(gdb)

Info about this little board: root@heidenrod-obs:/Astro/obs-dev/gason# uname -a Linux heidenrod-obs 3.10.66-49 #1 SMP PREEMPT Fri Jan 30 22:17:03 BRST 2015 armv7l armv7l armv7l GNU/Linux root@heidenrod-obs:/Astro/obs-dev/gason# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 15.04 Release: 15.04 Codename: vivid root@heidenrod-obs:/Astro/obs-dev/gason#

I was wondering if you could help me out there please?

ChrisJefferson commented 9 years ago

Investigated, there is a fix in pull request #21

123tolik commented 3 years ago

Assertion `((uintptr_t)payload <= 0x00007FFFFFFFFFFFULL)' failed

Using the gason.h library in my project, I saw one interesting nuance, the code compiles and works on x32 and x64 Ubuntu, Xubuntu systems, as well as on the FriendlyARM mini pc, made on the basis of Allwinner H3 SoC, but Allwinner H5 Quad Core Cortex A53 was falling ... In the process, it turned out that 47 bits of the address space was not enough for him, he adjusted it to 48 bits and it all worked

define JSON_VALUE_PAYLOAD_MASK 0x0000FFFFFFFFFFFFULL // 0x00007FFFFFFFFFFFULL

define JSON_VALUE_NAN_MASK 0x7FF0000000000000ULL //0x7FF8000000000000ULL

define JSON_VALUE_TAG_MASK 0xF

define JSON_VALUE_TAG_SHIFT 48 //47