You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gluten.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2026/06/30 10:53:40 UTC

[I] JniLibLoader.toRealPath() mis-resolves relative symlinks and loops forever on cycles [gluten]

LuciferYang opened a new issue, #12401:
URL: https://github.com/apache/gluten/issues/12401

   ### Describe the bug
   
   `JniLibLoader.toRealPath()` hand-rolls a symlink-resolution loop:
   
   ```java
   while (Files.isSymbolicLink(Paths.get(realPath))) {
     realPath = Files.readSymbolicLink(Paths.get(realPath)).toString();
   }
   ```
   
   `Files.readSymbolicLink` returns the target as stored, which is typically a relative path for versioned native libraries (`libfoo.so -> libfoo.so.1 -> libfoo.so.1.2.3`). The next iteration feeds that relative target back into `Paths.get(realPath)`, which resolves it against the process working directory — not against the link's own parent. That yields a non-existent path or, worse, a path that happens to exist somewhere unrelated, and `System.load(...)` then loads the wrong library or fails.
   
   The same loop also has no cycle guard: a symlink cycle (`a -> b -> a`) makes it spin forever.
   
   Discovered while reviewing the L1 foundation utilities in `gluten-core` (same area as #12392).
   
   ### Expected behavior
   
   Resolution should follow each link relative to its own parent, and a cycle should fail fast.
   
   The cleanest path is to delegate to the JDK's `Path#toRealPath`, which canonicalises the full chain (relative or absolute), normalises `.`/`..`, and raises `FileSystemLoopException` on cycles — no hand-rolled loop and no magic guard counter needed.
   
   Patch and tests are ready; will send a PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [I] JniLibLoader.toRealPath() mis-resolves relative symlinks and loops forever on cycles [gluten]

Posted by "jackylee-ch (via GitHub)" <gi...@apache.org>.
jackylee-ch closed issue #12401: JniLibLoader.toRealPath() mis-resolves relative symlinks and loops forever on cycles
URL: https://github.com/apache/gluten/issues/12401


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org