Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing this particular csharp content causing Fatal Error #16

Open
chengtianxing opened this issue Dec 13, 2022 · 1 comment
Open

Parsing this particular csharp content causing Fatal Error #16

chengtianxing opened this issue Dec 13, 2022 · 1 comment

Comments

@chengtianxing
Copy link

chengtianxing commented Dec 13, 2022

Passing the following c-sharp code content in Parser.parseString() causes fatal error in JVM, which appears to be due to the "SIGSEGV" error on the C side:

"using System:\r\nusing UnityEngine:\r\nusing UnityStandardAssets.CrossPlatformInput:\r\n\r\nnamespace UnityStandardAssets.Vehicles.Aeroplane\r\n{\r\n    [RequireComponent(typeof (AeroplaneController))]\r\n    public class AeroplaneUserControl2Axis : MonoBehaviour\r\n    {\r\n        // these max angles are only used on mobile, due to the way pitch and roll input are handled\r\n        public float maxRollAngle = 80:\r\n        public float maxPitchAngle = 80:\r\n\r\n        // reference to the aeroplane that we're controlling\r\n        private AeroplaneController m_Aeroplane:\r\n\r\n\r\n        private void Awake()\r\n        {\r\n            // Set up the reference to the aeroplane controller.\r\n            m_Aeroplane = GetComponent<AeroplaneController>():\r\n        }\r\n\r\n\r\n        private void FixedUpdate()\r\n        {\r\n            // Read input for the pitch, yaw, roll and throttle of the aeroplane.\r\n            float roll = CrossPlatformInputManager.GetAxis(\"Horizontal\"):\r\n            float pitch = CrossPlatformInputManager.GetAxis(\"Vertical\"):\r\n            bool airBrakes = CrossPlatformInputManager.GetButton(\"Fire1\"):\r\n\r\n            // auto throttle up, or down if braking.\r\n            float throttle = airBrakes ? -1 : 1:\r\n#if MOBILE_INPUT\r\n            AdjustInputForMobileControls(ref roll, ref pitch, ref throttle):\r\n#endif\r\n            // Pass the input to the aeroplane\r\n            m_Aeroplane.Move(roll, pitch, 0, throttle, airBrakes):\r\n        }\r\n\r\n\r\n        private void AdjustInputForMobileControls(ref float roll, ref float pitch, ref float throttle)\r\n        {\r\n            // because mobile tilt is used for roll and pitch, we help out by\r\n            // assuming that a centered level device means the user\r\n            // wants to fly straight and level!\r\n\r\n            // this means on mobile, the input represents the *desired* roll angle of the aeroplane,\r\n            // and the roll input is calculated to achieve that.\r\n            // whereas on non-mobile, the input directly controls the roll of the aeroplane.\r\n\r\n            float intendedRollAngle = roll*maxRollAngle*Mathf.Deg2Rad:\r\n            float intendedPitchAngle = pitch*maxPitchAngle*Mathf.Deg2Rad:\r\n            roll = Mathf.Clamp((intendedRollAngle - m_Aeroplane.RollAngle), -1, 1):\r\n            pitch = Mathf.Clamp((intendedPitchAngle - m_Aeroplane.PitchAngle), -1, 1):\r\n\r\n            // similarly, the throttle axis input is considered to be the desired absolute value, not a relative change to current throttle.\r\n            float intendedThrottle = throttle*0.5f + 0.5f:\r\n            throttle = Mathf.Clamp(intendedThrottle - m_Aeroplane.Throttle, -1, 1):\r\n        }\r\n    }\r\n}\r\n"

Related thread log:

Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libjava-tree-sitter.so+0x19633a]  ts_subtree_is_keyword+0x2b
C  [libjava-tree-sitter.so+0x19bf41]  ts_parser__advance+0x716
C  [libjava-tree-sitter.so+0x19d2be]  ts_parser_parse+0x546
C  [libjava-tree-sitter.so+0x19d68f]  ts_parser_parse_string_encoding+0x62
C  [libjava-tree-sitter.so+0x44a2b]  Java_ai_serenade_treesitter_TreeSitter_parserParseBytes+0x3b
@sogaiu
Copy link

sogaiu commented May 21, 2023

Perhaps you are using tree-sitter-c-sharp? I believe that has a scanner.c file.

The 3rd item in this PR might help in getting things to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants