Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #305 (closed defect: fixed)

Opened 2 years ago

Last modified 1 year ago

system/normpath example fails on darwin

Reported by: Carlos Assigned to: sean
Priority: normal Milestone: 0.97 RC 1
Component: Tango Version:
Keywords: Cc:

Description

gdb session:

(gdb) r
Starting program: /Users/carlos/Development/d/tango/trunk/example/system/normpath 
Reading symbols for shared libraries . done

Program received signal SIGABRT, Aborted.
0x9004796c in kill ()
(gdb) bt
#0  0x9004796c in kill ()
#1  0x9012dc14 in abort ()
#2  0x00014be8 in _D3gcx3Gcx8bigAllocMFkZPv () at lifetime.d:79
#3  0x00015718 in _D3gcx2GC12mallocNoSyncMFkkZPv () at lifetime.d:79
#4  0x000110b0 in gc_malloc () at lifetime.d:79
#5  0x0000efe8 in _d_newarrayT (ti=@0x2c2cc, length=2413834471) at lifetime.d:175
#6  0x0000e2c4 in _d_arraycatnT (ti=@0x2c4dc, n=2) at lifetime.d:825
#7  0x00009f04 in _D5tango4util8PathUtil9normalizeFAabZAa10removeDotsMFAaiZAa (path={length = 12, ptr = 0x407f80 "/foo/../john"}, start=5) at /Users/carlos/Development/d/tango/trunk/tango/util/PathUtil.d:151
#8  0x000090f4 in _D5tango4util8PathUtil9normalizeFAabZAa (path={length = 12, ptr = 0x1b5f4 "/foo/../john"}, normSlash=true) at /Users/carlos/Development/d/tango/trunk/tango/util/PathUtil.d:176
#9  0x00002284 in _Dmain () at system/normpath.d:16
#10 0x0000b214 in _d_run_main (argc=1, argv=0xbffffb1c, main_func=0x2234 <_Dmain>) at dgccmain2.d:143
#11 0x00001a8c in _start (argc=1, argv=0xbffffb1c, envp=0xbffffb24) at /SourceCache/Csu/Csu-58/crt.c:272
#12 0x00001934 in start () at /Users/carlos/Development/d/tango/trunk/tango/stdc/stdint.d:14

Change History

03/03/07 17:12:45 changed by kris

  • owner changed from kris to sean.
  • milestone set to 0.96 Beta 2.

03/04/07 11:04:07 changed by Carlos

It doesn't crash anymore, but doesn't work either:

$ system/normpath
/Users/carlos/Development/d/tango/trunk/tango/util/PathUtil.d(75): Assertion failure

03/13/07 17:49:06 changed by larsivi

Carlos, could you please test this again? And if the result is the same - paste the output after adding Stdout(path)(" - ")(start).newline; in front of the assert on line 75. Thx :)

03/14/07 21:22:07 changed by kris

  • milestone changed from 0.96 Beta 2 to 0.97 RC 1.

waiting for confirmation from Carlos; hopefully fixed now, or early next week

03/14/07 21:39:26 changed by sean

After some investigation, I think this one is actually not fixed yet. GDC recognizes its built-in vararg symbols (va_start and one other one) by their fully qualified names. Which as, as you might guess, std.stdarg.va_start, and std.c.stdarg.va_start. There is a file named something like d_builtins2.cc in the compiler that handles this. Either we'll have to do something like how we handle std.intrinsic or perhaps we can persuade davef to either move these declarations to gcc.builtins or to add Tango-awareness here. I'd even submit a patch if he'd accept it.

03/15/07 23:30:34 changed by Carlos

Sorry I haven't replied. I don't know how to track tickets.

Anyway, this depends on #306, so waiting on that one first.

03/15/07 23:32:14 changed by Carlos

I meant #316.

03/16/07 07:20:46 changed by larsivi

I thought you would get mail to your dsource registered mail address for all tickets you been involved with. If this is not the case, you can try to add your email in the CC field.

03/16/07 09:51:35 changed by Carlos

  • cc set to Carlos.

03/16/07 09:52:01 changed by Carlos

Let's see if that works...

04/04/07 08:40:20 changed by Carlos

Now waiting for #327.

04/04/07 17:31:10 changed by larsivi

geezusfreeek tested:

15:41:03::~/Desktop/tango/example/system% ./normpath 
/john
john
foo
foo/john
foo/john
foo/bar
foo/bar/doe
foo/bar
bar
foo/john
../../foo/john
../../../foo/bar
** Should now throw exception as the following path is invalid for normalization.
zsh: 16152 abort      ./normpath

Looking good, except that a real message should be printed at the end.

04/04/07 17:32:07 changed by larsivi

geezusfreeek's gdb output, same program:

15:41:08::~/Desktop/tango/example/system% gdb normpath 
GNU gdb 6.3.50-20050815 (Apple version gdb-573) (Fri Oct 20 15:54:33 GMT 2006)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin"...Reading symbols for shared libraries ... done

(gdb) r
Starting program: /Users/jake/Desktop/tango/example/system/normpath 
Reading symbols for shared libraries . done
/john
john
foo
foo/john
foo/john
foo/bar
foo/bar/doe
foo/bar
bar
foo/john
../../foo/john
../../../foo/bar
** Should now throw exception as the following path is invalid for normalization.

Program received signal SIGABRT, Aborted.
0x900482ec in kill ()
(gdb) bt
#0  0x900482ec in kill ()
#1  0x9012e7d4 in abort ()
#2  0x0000b928 in _D5tango4util8PathUtil9normalizeFAabZAa10removeDotsMFAaiZAa ()
#3  0x0000b184 in _D5tango4util8PathUtil9normalizeFAabZAa ()
#4  0x00004480 in _Dmain ()
#5  0x0000d374 in _D9dgccmain211_d_run_mainUiPPaPUAAaZiZi3runMFZv () at dgccmain2.d:145
#6  0x0000d67c in _d_run_main (argc=1, argv=0xbffff914, main_func=0xa0004170 <_current_pid>) at dgccmain2.d:185
#7  0x00002a0c in _start ()
#8  0x00002710 in start ()
(gdb) q
The program is running.  Exit anyway? (y or n) y

04/05/07 18:44:04 changed by Carlos

  • cc deleted.

Same here.
(BTW, CC didn't work)

04/05/07 20:04:57 changed by kris

this is currently awaiting a small fix in dmain2, from Sean

04/06/07 11:23:30 changed by sean

I don't suppose there's a way to step through removeDots to see exactly what is happening?

04/06/07 11:40:54 changed by Carlos

Here it is:

(gdb) break system/normpath.d:30
Breakpoint 1 at 0x2bc0: file system/normpath.d, line 30.
(gdb) r
Starting program: /Users/carlos/Development/d/tango/trunk/example/system/normpath 
Reading symbols for shared libraries . done
/john
john
foo
foo/john
foo/john
foo/bar
foo/bar/doe
foo/bar
bar
foo/john
../../foo/john
../../../foo/bar
** Should now throw exception as the following path is invalid for normalization.

Breakpoint 1, _Dmain () at system/normpath.d:30
30          Stdout(normalize ( "/../../../foo/bar")).newline;
(gdb) break _D5tango4util8PathUtil9normalizeFAabZAa10removeDotsMFAaiZAa
Breakpoint 2 at 0x9624: file /Users/carlos/Development/d/tango/trunk/tango/util/PathUtil.d, line 106.
(gdb) c
Continuing.

Breakpoint 2, _D5tango4util8PathUtil9normalizeFAabZAa10removeDotsMFAaiZAa (path={length = 17, ptr = 0x417e20 "/../../../foo/bar"}, start=1) at /Users/carlos/Development/d/tango/trunk/tango/util/PathUtil.d:106
106         char[] removeDots(char[] path, int start) {
(gdb) n
107             assert (start < path.length);
(gdb) 
108             assert (path[start] == '.');
(gdb) 
109             if (start + 1 == path.length) {
(gdb) 
113             else if (path[start+1] == FileConst.PathSeparatorChar) {
(gdb) 
123             else if (path[start..start+2] == "..") {
(gdb) 
132                 if (start == 1) { // absolute
(gdb) 
133                     throw new Exception("PathUtil :: Invalid absolute path, root separator can not be followed by ..");
(gdb) 

Program received signal SIGABRT, Aborted.
0x900482ec in kill ()

04/06/07 14:12:49 changed by sean

It's a shot in the dark, but perhaps there is a bug with GDC throwing exceptions out of nested functions. You could try moving removeDots out of normalize and see if that changes anything.

04/06/07 14:57:45 changed by Carlos

No change, Sean:

(gdb) break system/normpath.d:30
Breakpoint 1 at 0x2b00: file system/normpath.d, line 30.
(gdb) r
Starting program: /Users/carlos/Development/d/tango/trunk/example/system/normpath 
Reading symbols for shared libraries . done
/john
john
foo
foo/john
foo/john
foo/bar
foo/bar/doe
foo/bar
bar
foo/john
../../foo/john
../../../foo/bar
** Should now throw exception as the following path is invalid for normalization.

Breakpoint 1, _Dmain () at system/normpath.d:30
30          Stdout(normalize ( "/../../../foo/bar")).newline;
(gdb) break _D5tango4util8PathUtil10removeDotsFAaiZAa
Breakpoint 2 at 0x97bc: file /Users/carlos/Development/d/tango/trunk/tango/util/PathUtil.d, line 55.
(gdb) c
Continuing.

Breakpoint 2, _D5tango4util8PathUtil10removeDotsFAaiZAa (path={length = 17, ptr = 0x417e20 "/../../../foo/bar"}, start=1) at /Users/carlos/Development/d/tango/trunk/tango/util/PathUtil.d:55
55              assert (start < path.length);
(gdb) n
56              assert (path[start] == '.');
(gdb) 
57              if (start + 1 == path.length) {
(gdb) 
61              else if (path[start+1] == FileConst.PathSeparatorChar) {
(gdb) 
71              else if (path[start..start+2] == "..") {
(gdb) 
80                  if (start == 1) { // absolute
(gdb) 
81                      throw new Exception("PathUtil :: Invalid absolute path, root separator can not be followed by ..");
(gdb) 

Program received signal SIGABRT, Aborted.
0x900482ec in kill ()

04/13/07 16:50:36 changed by sean

  • status changed from new to closed.
  • resolution set to fixed.

I think this one was fixed by some changes Gregor made the other day. If this is still a problem, please reopen.

04/13/07 20:27:38 changed by Carlos

That's correct. It now prints the following, which I think is the expected output:

** Should now throw exception as the following path is invalid for normalization.
object.Exception: PathUtil :: Invalid absolute path, root separator can not be followed by ..