Re: Relatively deterministic panic with sendfile(2) when running tests in the sxlock code

2018-10-15 Thread Enji Cooper (yaneurabeya)

> On Oct 15, 2018, at 6:10 AM, Gleb Smirnoff  wrote:
> 
>  Enji,
> 
> can you please check that with this patch all your tests pass?

Hi Gleb!
It almost compiled. I just needed to dereference the `so` pointer:

$ git diff /usr/src/sys/kern/kern_sendfile.c
diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c
index 438069aa721..50404ce5745 100644
--- a/sys/kern/kern_sendfile.c
+++ b/sys/kern/kern_sendfile.c
@@ -526,6 +526,8 @@ sendfile_getsock(struct thread *td, int s, struct file 
**sock_fp,
*so = (*sock_fp)->f_data;
if ((*so)->so_type != SOCK_STREAM)
return (EINVAL);
+   if (SOLISTENING(*so))
+   return (ENOTCONN);
return (0);
 }


After I applied that and rebuilt the kernel, it doesn’t panic anymore 
(and it fails with the correct errno).
Thank you so very much :)!
-Enji


signature.asc
Description: Message signed with OpenPGP


Re: Relatively deterministic panic with sendfile(2) when running tests in the sxlock code

2018-10-15 Thread Gleb Smirnoff
  Enji,

can you please check that with this patch all your tests pass?

-- 
Gleb Smirnoff
Index: sys/kern/kern_sendfile.c
===
--- sys/kern/kern_sendfile.c	(revision 339098)
+++ sys/kern/kern_sendfile.c	(working copy)
@@ -526,6 +526,8 @@ sendfile_getsock(struct thread *td, int s, struct
 	*so = (*sock_fp)->f_data;
 	if ((*so)->so_type != SOCK_STREAM)
 		return (EINVAL);
+	if (SOLISTENING(so))
+		return (ENOTCONN);
 	return (0);
 }
 
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


Re: Relatively deterministic panic with sendfile(2) when running tests in the sxlock code

2018-10-15 Thread Gleb Smirnoff
On Sun, Oct 14, 2018 at 10:17:28PM -0700, Enji Cooper (yaneurabeya) wrote:
E> Oh yipes. I guess passing in a server socket (a bound and listening socket) 
instead of a client socket (connect’ed to a server socket) for `s` will result 
in a crash?

Oh, thanks enough info. Thanks! Isn't related to sendfile but definitely
is related to my other changes. Will fix.

-- 
Gleb Smirnoff
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"


Re: Relatively deterministic panic with sendfile(2) when running tests in the sxlock code

2018-10-14 Thread Enji Cooper (yaneurabeya)

> On Oct 14, 2018, at 10:17 PM, Enji Cooper (yaneurabeya) 
>  wrote:

...

> Oh yipes. I guess passing in a server socket (a bound and listening socket) 
> instead of a client socket (connect’ed to a server socket) for `s` will 
> result in a crash?
> 
> From 
> https://github.com/ngie-eign/freebsd/blob/95b96470a3a0270c36c4e7fb5eedc150fe124fac/lib/libc/tests/sys/sendfile_test.c#L479
>  
> :
> ATF_TC_BODY(s_negative_not_connected_socket, tc)
> {
>   int client_sock, error, fd, port;
> 
>   port = XXX_TEST_PORT_BASE + __LINE__;
>   client_sock = setup_tcp_server(XXX_TEST_DOMAIN, port);
> 
>   fd = open(SOURCE_FILE, O_CREAT|O_RDWR);
>   ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno));
> 
>   error = sendfile(fd, client_sock, 0, 0, NULL, NULL, SF_FLAGS(0, 0));
>   ATF_REQUIRE_ERRNO(ENOTCONN, error == -1);
> 
>   (void)close(fd);
>   (void)close(client_sock);
> }
> Let me see if I can track this down..

Can’t repro this on 11.2-RELEASE. Trying 11.2-STABLE.
Thanks!
-Enji



signature.asc
Description: Message signed with OpenPGP


Re: Relatively deterministic panic with sendfile(2) when running tests in the sxlock code

2018-10-14 Thread Enji Cooper (yaneurabeya)

> On Oct 14, 2018, at 10:12 PM, Enji Cooper (yaneurabeya) 
>  wrote:
> 
>> On Oct 14, 2018, at 9:45 PM, Enji Cooper (yaneurabeya) 
>> mailto:yaneurab...@gmail.com>> wrote:
>> 
>> 
>> 
>>> On Oct 14, 2018, at 7:25 PM, Gleb Smirnoff >> > wrote:
>>> 
>>>  Hi Enji,
>>> 
>>> On Sun, Oct 14, 2018 at 06:51:42PM -0700, Enji Cooper (yaneurabeya) wrote:
>>> E> Hi,
>>> E>  I’m seeing a semi-deterministic panic on 12.0-ALPHA9 related to 
>>> sendfile(2) when running sendfile_test on the host: 
>>> https://pastebin.com/raw/6Y7xg0ki ; it 
>>> looks like it’s crashing in the sxlock code when calling sblock on a 
>>> sockbuf. Are there any commands in gdb you would like me to run to display 
>>> lock state?
>>> E>  Repro:
>>> E>
>>> E> mkdir /path/to/git/checkout
>>> E> cd /path/to/git/checkout
>>> E> git clone https://github.com/ngie-eign/freebsd/tree/sendfile_tests 
>>>  .
>>> E> git checkout sendfile_tests
>>> E> (cd lib/libc/tests/sys/; make obj; make; sudo make install)
>>> E> kyua test -k /usr/tests/lib/libc/sys/Kyuafile sendfile_test
>>> 
>>> I'd like to reproduce it myself, but looks like URL is
>>> wrong:
>>> 
>>> glebius@erla:/usr/src:|>git clone 
>>> https://github.com/ngie-eign/freebsd/tree/sendfile_tests 
>>> 
>>> Клонирование в «sendfile_tests»…
>>> fatal: repository 
>>> 'https://github.com/ngie-eign/freebsd/tree/sendfile_tests/ 
>>> ' not found
>> 
>> Mea culpa. It should be:
>> 
>> $ git clone https://github.com/ngie-eign/freebsd.git 
>>  .
>> 
>> Another note is that I’m running GENERIC-NODEBUG, not GENERIC-DEBUG.
>> 
>> I suspect that it’s crashing on :hdtr_negative_bad_pointers or : 
>> s_negative_not_descriptor, because the other items don’t seem terribly 
>> plausible.
>> 
>> The test case (source) can be found here: 
>> https://github.com/ngie-eign/freebsd/blob/95b96470a3a0270c36c4e7fb5eedc150fe124fac/lib/libc/tests/sys/sendfile_test.c
>>  
>> 
> Aha! It was actually :s_negative_not_connected_socket.
> 
> Updated repro: use `kyua test -k /usr/tests/lib/libc/sys/Kyuafile 
> sendfile_test:s_negative_not_connected_socket` instead of the other kyua call 
> I provided.

Oh yipes. I guess passing in a server socket (a bound and listening socket) 
instead of a client socket (connect’ed to a server socket) for `s` will result 
in a crash?

From 
https://github.com/ngie-eign/freebsd/blob/95b96470a3a0270c36c4e7fb5eedc150fe124fac/lib/libc/tests/sys/sendfile_test.c#L479
 
:
ATF_TC_BODY(s_negative_not_connected_socket, tc)
{
int client_sock, error, fd, port;

port = XXX_TEST_PORT_BASE + __LINE__;
client_sock = setup_tcp_server(XXX_TEST_DOMAIN, port);

fd = open(SOURCE_FILE, O_CREAT|O_RDWR);
ATF_REQUIRE_MSG(fd != -1, "open failed: %s", strerror(errno));

error = sendfile(fd, client_sock, 0, 0, NULL, NULL, SF_FLAGS(0, 0));
ATF_REQUIRE_ERRNO(ENOTCONN, error == -1);

(void)close(fd);
(void)close(client_sock);
}
Let me see if I can track this down..

Thanks!
-Enji


signature.asc
Description: Message signed with OpenPGP


Re: Relatively deterministic panic with sendfile(2) when running tests in the sxlock code

2018-10-14 Thread Enji Cooper (yaneurabeya)


> On Oct 14, 2018, at 9:45 PM, Enji Cooper (yaneurabeya) 
>  wrote:
> 
> 
> 
>> On Oct 14, 2018, at 7:25 PM, Gleb Smirnoff > > wrote:
>> 
>>  Hi Enji,
>> 
>> On Sun, Oct 14, 2018 at 06:51:42PM -0700, Enji Cooper (yaneurabeya) wrote:
>> E> Hi,
>> E>   I’m seeing a semi-deterministic panic on 12.0-ALPHA9 related to 
>> sendfile(2) when running sendfile_test on the host: 
>> https://pastebin.com/raw/6Y7xg0ki ; it 
>> looks like it’s crashing in the sxlock code when calling sblock on a 
>> sockbuf. Are there any commands in gdb you would like me to run to display 
>> lock state?
>> E>   Repro:
>> E>
>> E> mkdir /path/to/git/checkout
>> E> cd /path/to/git/checkout
>> E> git clone https://github.com/ngie-eign/freebsd/tree/sendfile_tests 
>>  .
>> E> git checkout sendfile_tests
>> E> (cd lib/libc/tests/sys/; make obj; make; sudo make install)
>> E> kyua test -k /usr/tests/lib/libc/sys/Kyuafile sendfile_test
>> 
>> I'd like to reproduce it myself, but looks like URL is
>> wrong:
>> 
>> glebius@erla:/usr/src:|>git clone 
>> https://github.com/ngie-eign/freebsd/tree/sendfile_tests 
>> 
>> Клонирование в «sendfile_tests»…
>> fatal: repository 'https://github.com/ngie-eign/freebsd/tree/sendfile_tests/ 
>> ' not found
> 
> Mea culpa. It should be:
> 
> $ git clone https://github.com/ngie-eign/freebsd.git 
>  .
> 
> Another note is that I’m running GENERIC-NODEBUG, not GENERIC-DEBUG.
> 
> I suspect that it’s crashing on :hdtr_negative_bad_pointers or : 
> s_negative_not_descriptor, because the other items don’t seem terribly 
> plausible.
> 
> The test case (source) can be found here: 
> https://github.com/ngie-eign/freebsd/blob/95b96470a3a0270c36c4e7fb5eedc150fe124fac/lib/libc/tests/sys/sendfile_test.c
>  
> 
Aha! It was actually :s_negative_not_connected_socket.

Updated repro: use `kyua test -k /usr/tests/lib/libc/sys/Kyuafile 
sendfile_test:s_negative_not_connected_socket` instead of the other kyua call I 
provided.

Thanks!
-Enji


signature.asc
Description: Message signed with OpenPGP


Re: Relatively deterministic panic with sendfile(2) when running tests in the sxlock code

2018-10-14 Thread Enji Cooper (yaneurabeya)


> On Oct 14, 2018, at 7:25 PM, Gleb Smirnoff  wrote:
> 
>  Hi Enji,
> 
> On Sun, Oct 14, 2018 at 06:51:42PM -0700, Enji Cooper (yaneurabeya) wrote:
> E> Hi,
> E>I’m seeing a semi-deterministic panic on 12.0-ALPHA9 related to 
> sendfile(2) when running sendfile_test on the host: 
> https://pastebin.com/raw/6Y7xg0ki; it looks like it’s crashing in the sxlock 
> code when calling sblock on a sockbuf. Are there any commands in gdb you 
> would like me to run to display lock state?
> E>Repro:
> E>
> E> mkdir /path/to/git/checkout
> E> cd /path/to/git/checkout
> E> git clone https://github.com/ngie-eign/freebsd/tree/sendfile_tests .
> E> git checkout sendfile_tests
> E> (cd lib/libc/tests/sys/; make obj; make; sudo make install)
> E> kyua test -k /usr/tests/lib/libc/sys/Kyuafile sendfile_test
> 
> I'd like to reproduce it myself, but looks like URL is
> wrong:
> 
> glebius@erla:/usr/src:|>git clone 
> https://github.com/ngie-eign/freebsd/tree/sendfile_tests
> Клонирование в «sendfile_tests»…
> fatal: repository 'https://github.com/ngie-eign/freebsd/tree/sendfile_tests/' 
> not found

Mea culpa. It should be:

$ git clone https://github.com/ngie-eign/freebsd.git 
 .

Another note is that I’m running GENERIC-NODEBUG, not GENERIC-DEBUG.

I suspect that it’s crashing on :hdtr_negative_bad_pointers or : 
s_negative_not_descriptor, because the other items don’t seem terribly 
plausible.

The test case (source) can be found here: 
https://github.com/ngie-eign/freebsd/blob/95b96470a3a0270c36c4e7fb5eedc150fe124fac/lib/libc/tests/sys/sendfile_test.c

Thanks!
-Enji


signature.asc
Description: Message signed with OpenPGP


Re: Relatively deterministic panic with sendfile(2) when running tests in the sxlock code

2018-10-14 Thread Gleb Smirnoff
  Hi Enji,

On Sun, Oct 14, 2018 at 06:51:42PM -0700, Enji Cooper (yaneurabeya) wrote:
E> Hi,
E>  I’m seeing a semi-deterministic panic on 12.0-ALPHA9 related to 
sendfile(2) when running sendfile_test on the host: 
https://pastebin.com/raw/6Y7xg0ki; it looks like it’s crashing in the sxlock 
code when calling sblock on a sockbuf. Are there any commands in gdb you would 
like me to run to display lock state?
E>  Repro:
E> 
E> mkdir /path/to/git/checkout
E> cd /path/to/git/checkout
E> git clone https://github.com/ngie-eign/freebsd/tree/sendfile_tests .
E> git checkout sendfile_tests
E> (cd lib/libc/tests/sys/; make obj; make; sudo make install)
E> kyua test -k /usr/tests/lib/libc/sys/Kyuafile sendfile_test

I'd like to reproduce it myself, but looks like URL is
wrong:

glebius@erla:/usr/src:|>git clone 
https://github.com/ngie-eign/freebsd/tree/sendfile_tests 
Клонирование в «sendfile_tests»…
fatal: repository 'https://github.com/ngie-eign/freebsd/tree/sendfile_tests/' 
not found


-- 
Gleb Smirnoff
___
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"