Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 529695 (equinoxOpenFileRelPathCrash) - --launcher.openFile with relative path crashes
Summary: --launcher.openFile with relative path crashes
Status: VERIFIED FIXED
Alias: equinoxOpenFileRelPathCrash
Product: Equinox
Classification: Eclipse Project
Component: Launcher (show other bugs)
Version: 4.8.0 Photon   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: Photon M5   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 439459 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-01-11 13:03 EST by Leo Ufimtsev CLA
Modified: 2019-04-02 10:22 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leo Ufimtsev CLA 2018-01-11 13:03:15 EST
The launcher crashes if we use a combination of "--launcher.openFile" and relative paths:

/eclipse --launcher.openFile /tmp/hi   # works.
/eclipse hi                            # works.
/eclipse --launcher.openFile /tmp/hi   # works.
/eclipse --launcher.openFile hi        # crashes (when pwd is /tmp)

Gdb gives us:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7750f71 in __strlen_avx2 () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7750f71 in __strlen_avx2 () from /lib64/libc.so.6
#1  0x00007ffff0903c4b in checkPath (path=0x7fffffffdd58 "./eclipse.ini", programDir=0x0, 
    reverseOrder=0) at ../eclipseCommon.c:532
#2  0x00007ffff08fc611 in parseArgs (pArgc=0x7fffffffd74c, argv=0x609140) at ../eclipse.c:897
#3  0x00007ffff08fb3d7 in run (argc=3, argv=0x609140, vmArgs=0x0) at ../eclipse.c:421
#4  0x000000000040163e in main (argc=17, argv=0x609140) at ../eclipseMain.c:217

Source code gives us this from eclipseCommon.c:532:
_TCHAR* checkPath( _TCHAR* path, _TCHAR* programDir, int reverseOrder ) {
...
    paths[0] = reverseOrder ? programDir : workingDir;
    paths[1] = reverseOrder ? workingDir : programDir;
    ..
    buffer = malloc((_tcslen(paths[0]) + _tcslen(paths[1]) + _tcslen(path) + 2) * sizeof(_TCHAR));   # One of the strlen crashes.
}

It seems that one of the strlen function that reads one of the paths segfaults. My best guess is that there's a missing null terminator in one of the strings or it expects a path but is given '--launcher.openFile' instead.

I need to debug and investigate what's happening here.
Comment 1 Leo Ufimtsev CLA 2018-01-11 18:36:54 EST
I can test the Gtk side. If I come up with a fix, will there be anyone to check the Win and Cocoa builds?
Comment 2 Eclipse Genie CLA 2018-01-19 14:28:23 EST
New Gerrit change created: https://git.eclipse.org/r/115725
Comment 3 Leo Ufimtsev CLA 2018-01-19 14:45:13 EST
As a note, I tested, this segFault occurs on Mac as well. (--launcher.openFile with relative paths, but not with abs paths).
Comment 4 Leo Ufimtsev CLA 2018-01-19 14:51:04 EST
Also crashes on Windows.
Comment 5 Alexander Kurtakov CLA 2018-01-19 14:55:37 EST
Sravan, this is worth rebuilding all archs are we ready to do so for win and mac too?
Comment 7 Leo Ufimtsev CLA 2018-01-29 16:19:47 EST
Verified on linux/win/cocoa.
Comment 8 Andrey Loskutov CLA 2019-04-02 10:22:45 EDT
*** Bug 439459 has been marked as a duplicate of this bug. ***