4NXCI
4NXCI copied to clipboard
Segfault on armv7l
#0 memcpy () at ../sysdeps/arm/memcpy.S:111
No locals.
#1 0x76ed02b0 in __mempcpy_inline (__n=1008, __src=<optimized out>, __dest=0x0) at ../string/string.h:650
No locals.
#2 __GI__IO_file_xsgetn (fp=0x5d4e8, data=<optimized out>, n=1147132224) at fileops.c:1400
want = 1147132224
have = 1008
count = <optimized out>
s = 0x0
#3 0x76ec3de8 in __GI__IO_fread (buf=0x0, size=1, count=1147132224, fp=0x5d4e8) at iofread.c:38
---Type <return> to continue, or q <return> to quit---
_IO_acquire_lock_file = 0x5d4e8
bytes_requested = 1147132224
bytes_read = <optimized out>
#4 0x00014a3c in nca_section_fread ()
No symbol table info available.
#5 0x00015080 in nca_exefs_npdm_process ()
No symbol table info available.
#6 0x000168c8 in nca_gamecard_process ()
No symbol table info available.
#7 0x000173f8 in cnmt_gamecard_process ()
No symbol table info available.
#8 0x00011420 in main ()
No symbol table info available.
I'm building in debug to provide better info
please compile with -ggdb
Program received signal SIGSEGV, Segmentation fault.
memcpy () at ../sysdeps/arm/memcpy.S:111
111 ../sysdeps/arm/memcpy.S: No such file or directory.
#0 memcpy () at ../sysdeps/arm/memcpy.S:111
No locals.
#1 0x76ed02b0 in __mempcpy_inline (__n=1008, __src=<optimized out>, __dest=0x0) at ../string/string.h:650
No locals.
#2 __GI__IO_file_xsgetn (fp=0x624e8, data=<optimized out>, n=1147132224) at fileops.c:1400
want = 1147132224
have = 1008
count = <optimized out>
s = 0x0
#3 0x76ec3de8 in __GI__IO_fread (buf=0x0, size=1, count=1147132224, fp=0x624e8) at iofread.c:38
_IO_acquire_lock_file = 0x624e8
bytes_requested = 1147132224
bytes_read = <optimized out>
#4 0x00015da4 in nca_section_fread (ctx=0x7eff3bf0, buffer=0x0, count=1147132224) at nca.c:113
read = 0
block_buf = "\000\000\000\000\244!\377~\020\200\000\000\000\000\000"
#5 0x0001647c in nca_exefs_npdm_process (ctx=0x7eff3b78) at nca.c:204
ofs = 0
pfs0_file_entry_table = 0x0
magic = 0
i = 0
pfs0_header = {magic = 1087064250, num_files = 1658409912, string_table_size = 125888041, reserved = 840765846}
npdm_header = {magic = 0, _0x4 = 0, _0x8 = 0, mmu_flags = 0 '\000', _0xD = 0 '\000', main_thread_prio = 0 '\000', default_cpuid = 0 '\000', _0x10 = 0, process_category = 0,
main_stack_size = 0, title_name = '\000' <repeats 79 times>, aci0_offset = 0, aci0_size = 0, acid_offset = 0, acid_size = 0}
pfs0_start_offset = 32768
file_entry_table_offset = 32784
file_entry_table_size = 1147132224
meta_offset = 0
acid_offset = 0
raw_data_offset = 0
file_raw_data_offset = 0
block_start_offset = 0
block_hash_table_offset = 0
#6 0x00017b34 in nca_gamecard_process (ctx=0x7eff3b78, filepath=0x7eff3374, index=0, cnmt_xml_ctx=0x53600 <application_cnmt_xml>, cnmt_ctx=0x52db0 <application_cnmt>,
nsp_ctx=0x525a0 <application_nsp>) at nca.c:506
please type lscpu in terminal and give me the result of "Byte Order"
Little Endian
I'll test it
do you have this problem on all games or just a specific one?
Sorry I replied by mail but for some reason it didn't show up. I'm had problems on many games of various sizes. I kept an eye on the available memory but it wasn't even swapping
I tried multiple xcis on raspberry pi 3 model b, never got any error Although it's arm8 but It's the only arm hardware I have right now So I have no idea about this issue
if I'm the only one having this, maybe we can close. If I'll need to run it again on the rpi I'll have a look again
I close this but don't lock feel free to comment whenever you found something about it
having issues on my raspberry pi 2 too. armv7l using raspbian (debian 9.6 - 4.14.79-v7+ #1159 ) build with gcc version 6.3.0 20170516 (Raspbian 6.3.0-18+rpi1+deb9u1) while processing metadata. might take a closer look too and let you know if i find someting..
well guys, i took a closer look on this and in my case it seems to be a problem with malloc()
in nca_exefs_npdm_process()
which can't allocate enough memory.
first i tried gdb debugging and it seems that malloc returns a null-pointer so i took a malloc_wrap function which checks if it returns a pointer and printing either the size of the allocated memory or yelling bout failing and wrapped the mentioned malloc in nca.c
in my case it tried to allocate 2303621248 bytes (about 2.14 GiB) but fails doing so.
in detail the backtrace in my case goes like this
main --> cnmt_gamecard_process --> nca_gamecard_process --> nca_exefs_npdm_process (everything fine yet)
then in nca.c:202
pfs0_file_entry_t *pfs0_file_entry_table = (pfs0_file_entry_t *)malloc_wrap(file_entry_table_size);
yields Failed to allocated 2303621248 bytes where 2303621248 is the file_entry_table_size..
i dont know how to work around this large file_entry_table though.. maybe it can be split up or something but thats just a problem with low memory i think... maybe you can consider optimizing it in this direction but it really seems to be a problem with the machine configuration. (mem and swap)
Something is going wrong before malloc file_entry_table_size is always less than 1kb!!!
In that case i might take another closer look at nca_exefs_npdm_process
.
fyi it seems hactool has the same problem with romfs of the main nca of my xci file. but only on the arm machine. on my x86_64 machines everything works fine. maybe its some sort of problem with some lib like glibc on arm? btw the number of files hactool mentions is exactly the same we (i) get in 4nxci. even though the segfault in hactool might be of another nature its suspicious enough that its also failing at some point and states that sector 0 is corrupted but on my pc everything works as expected 😕