Hi Alex,
on my libraw port on android, I'm getting a SIGSEGV (signal 11 (SIGSEGV), code 2 (SEGV_ACCERR)) in the xtrans_decode_block function when trying to call "libraw_unpack" on a raf file reported by an user (X-T20)(see link below). What I tried is to check at which point exactly it crashes (it's a little tricky under android), and found out that it fails somewhere in the last loop (logged the state at line 712, the last output before it fails is:
xtrans_decode_block 22 15 512 (22 = g_even_pos, 15 = g_odd_pos, 512 = line_width)
What's strange is that I couldn't reproduce the crash: When trying to use the provided windows binaries, the file is getting identified correctly. RawDigger also opens the file perfectly. Can you point me into any direction what I'm may doing wrong or need to adjust so the segment fault gets fixed?
I'm using a copy of the current git repository.
Link to raf file: https://www.dropbox.com/s/5qgn5arqyaphu37/DSCF3128.RAF?dl=0
Best Regards
Torsten
Run the file through valgrind
Run the file through valgrind (under FreeBSD), do not see any fuji-decoder problems (buffer overrun, etc), so no idea.
BTW, what exact version do you use (in my working version line 712 is { bracket after while operator)?
-- Alex Tutubalin @LibRaw LLC
Hi Alex,
Hi Alex,
yes, it's the line, I put it behind the bracket:
This is the output I see:
I'm also a little irritated. I basically changed nothing and used the latest git (just from today). The only thing I changed for Android is to manually implement the "swab" function, but the implementation I use should be the same as the original from c. I could also see no calls on this function when the xtrans decoding is going on.
Regards
Torsten
Is there any way to get exact
Is there any way to get exact code point that fails with exception? maybe coredump or so?
-- Alex Tutubalin @LibRaw LLC
Hi Alex,
Hi Alex,
My experience is very mixed with debugging c code on Android. However I’ll try to find a way to generate a dump or something similar to find out where it fails and will report back later.
Thanks
Torsten
Hi Alex,
Hi Alex,
so after quite a lot of coffee, I found some kind of translation method to translate the stacktrace to real code lines. Here's the result:
For me it seems like the access of the grads array via the gradient variable runs further than the array, but I'm not sure. What do you think? Does any output of the variables may help?
Just a note: The value of the gradient variable before it fails is 2272 which seems way higher than all others (they are around 250). Maybe there's something going wrong here?
Thanks
Torsten
Both 2272 and 250 are too
Both 2272 and 250 are too high values for gradient variable b/c table size is only 41.
gradient is calculated by:
q_table contains values from -4 to +4, so maximum gradient value is 40.
Could you please try to dump q_table values? And, also, values used to calc gradient: Rb - Rf, Rc - Rb
-- Alex Tutubalin @LibRaw LLC
Hi,
Hi,
here are some dumps:
// Edit: The really strange thing is that the Ra... Rg values change each time I run it and the crash finally ocurse. For instance, now I get
before it will crash. Seems there is something really going wrong with the values?
For some other pretty strange reason it almost seems like something is running parallel, because I can't see the full var dump of the q_table in onces. But this could also be a transfering issue of the log in android since the buffer speed is somewhat limited? I don't have openmp enabled.
it looks like I know the
it looks like I know the answer:
q_table is defined as:
char *q_table; /* quantization table */
So, signed char, from -127 to 128.
It is initialized with ..-4...+4 values at lines 110-130.
Is there any chance that your char type is by default unsigned char?
-- Alex Tutubalin @LibRaw LLC
Amazing, yes you are
Amazing, yes you are completely right, that's the reason it was always failing. In gcc, I added
LOCAL_CFLAGS += -fsigned-char
to the make file and it works perfectly and decodes like a charm! As I read, the default of a char is not really defined in c and depends on the architecture, so this error makes perfectly sens. But may there would be a way to explicitly init is as a signed char directly in code so that these things will not happen to others?
Thanks again!
Yes, default char type
Yes, default char type (signed/unsigned) is undefined (although it is signed in all our test/production environments).
We'll change char definition to signed char (or, maybe, to int8_t, will see)
Thank you for reporting the bug.
-- Alex Tutubalin @LibRaw LLC