Segmentation fault when printing a float #350

Open
z3ntu opened this Issue Jun 3, 2017 · 2 comments

Comments

Projects
None yet
3 participants

z3ntu commented Jun 3, 2017

EDIT: This issue seems to be present in a bunch of tests. This issue was written only with test_input in mind! (I was debugging that one and found the issue)

Printing a float, like printf("float: %f\n", 1.0); in the function on_new_event results in a Segmentation fault. Doing the same in the main function, everything works as expected.

Showcase: z3ntu/libhybris@ea24333
Output of that:

root@localhost:~/libhybris/hybris/tests# ./test_input 
This will work:
float: 1.000000
<note: pressed the touchscreen there>
This won't work:
Segmentation fault

gdb backtrace - mirror of the paste is here

This problem causes the test_input test to crash: https://github.com/libhybris/libhybris/blob/master/hybris/tests/test_input.c#L51-L54 .

Casting the two variables into an integer and printing them works around the issue. Sample patch: z3ntu/libhybris@5773400

@z3ntu z3ntu changed the title from test_input: Segmentation fault when printing a float to Segmentation fault when printing a float Jun 3, 2017

Contributor

Tofee commented Oct 6, 2017

This looks like a softfp/hardfp issue. When I look at my N5 binaries, I have:

  • test_sensors which is built with hardfp
  • sensors.qcom which is built with softfp

This leads to the floats being actually integers in the structure, but the compiler doesn't know that and uses them directly as floats.

Contributor

krnlyng commented Oct 6, 2017

@Tofee This is not the issue here, libhybris uses the softfp calling convention when issuing calls to softfp libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment