JaciBrunning / Pathfinder

Cross-Platform, Multi-Use Motion Profiling and Trajectory Generation
MIT License
255 stars 78 forks source link

Java crashing with free pointer error (FRC) #7

Closed gbear605 closed 7 years ago

gbear605 commented 7 years ago

When I try to include it in my robot code, it crashes with

➔ Launching «'/usr/local/frc/JRE/bin/java' '-Djava.library.path=/usr/local/frc/lib/' '-jar' '/home/lvuser/FRCUserProgram.jar'»
********** Robot program starting **********
Platform: /Linux/arm/
*** Error in `/usr/local/frc/JRE/bin/java': free(): invalid pointer: 0xb4746200 ***

It just repeats the same error over and over.

It doesn't do this when something from Pathfinder isn't imported by our code, even when Pathfinder is still uploaded to the robot.

JaciBrunning commented 7 years ago

Pathfinder doesn't run any methods statically, can I see your code that is causing this issue?

gbear605 commented 7 years ago

https://github.com/Nashoba-Robotics/2017TestBot is the code that is crashing. Eclipse is not noticing any errors.

The relevant code is in https://github.com/Nashoba-Robotics/2017TestBot/blob/master/src/edu/nr/lib/motionprofiling/TwoDimensionalMotionProfilerPathfinder.java and https://github.com/Nashoba-Robotics/2017TestBot/blob/master/src/edu/nr/robotics/subsystems/Drive.java.

To clarify, the code crashes immediately when the robot starts, even if driver station isn't connected. If we change Drive to not use TwoDimensionalMotionProfilerPathfinder, even if it still imports it, the code doesn't crash.

gbear605 commented 7 years ago

Just checking in, are you working on this, or should I just go with a different motion profiling technique?

JaciBrunning commented 7 years ago

@gbear605 apologies. As far as I'm aware, the problem is with how you're allocating the Waypoints here. You need to pass at least 2 waypoints for Pathfinder.generate to function

gbear605 commented 7 years ago

Ah, thank you for finding that. I was intending for it to be a "do nothing if activated" default. Clearly I should implement it differently! Thank you for making Pathfinder available for FIRST teams. On Thu, Jan 19, 2017 at 00:55 Jaci R notifications@github.com wrote:

@gbear605 https://github.com/gbear605 apologies. As far as I'm aware, the problem is with how you're allocating the Waypoints here https://github.com/Nashoba-Robotics/2017TestBot/blob/master/src/edu/nr/lib/motionprofiling/TwoDimensionalMotionProfilerPathfinder.java#L55. You need to pass at least 2 waypoints for Pathfinder.generate to function

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/JacisNonsense/Pathfinder/issues/7#issuecomment-273688762, or mute the thread https://github.com/notifications/unsubscribe-auth/AAqKHDxICYp0hohUw2k_EgdtUQVDvQCsks5rTvrKgaJpZM4Ljxiv .

gbear605 commented 7 years ago

It still isn't working.

Stdout says:

#   ➔ Launching «'/usr/local/frc/JRE/bin/java' '-Djava.library.path=/usr/local/frc/lib/' '-jar' '/home/lvuser/FRCUserProgram.jar'»
********** Robot program starting **********
Platform: /Linux/arm/
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0xadf07254, pid=2209, tid=3063632992
#
# JRE version: Java(TM) SE Embedded Runtime Environment (8.0_06-b23) (build 1.8.0_06-b23)
# Java VM: Java HotSpot(TM) Embedded Client VM (25.6-b23 mixed mode linux-arm )
# Problematic frame:
# C  [pathfinderJNI7410382123334940911.so+0x6254]  pf_trajectory_fromSecondOrderFilter+0x88
#
# Core dump written. Default location: //core or core.2209 (max size 2048 kB). To ensure a full core dump, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /tmp/hs_err_pid2209.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#

It then immediately relaunches.

The referenced log file is https://gist.github.com/gbear605/a6c80324dfbef2f580fa824b8ea3f291

gbear605 commented 7 years ago

And yes, I did try ulimit -c unlimited, but it didn't change anything, including the message saying to try it.

JaciBrunning commented 7 years ago

I suspect the issue is still with the trajectory. Check TrajectoryInfo.length between the two pathfinder calls. If it's 0 or less, there's the issue

gbear605 commented 7 years ago

I resolved the issue, it turns out that I thought Trajectory.Config wanted milliseconds for dt, but it actually wants seconds, and when dt was that large (5), it crashed. When I changed it to 0.005, it worked correctly. Thanks for the help.

JaciBrunning commented 7 years ago

Ahh, rightio. That's interesting, I'll keep a tab on as to why that's happening