-
Notifications
You must be signed in to change notification settings - Fork 100
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
Cookies file randomly reset #235
Comments
I think you should provide more information what to do to run into your issue. The information you provide here are not enough to know when and after which time the cookie file is reset.
|
Sorry I realize this is not enough information to debug this issue. I am having a lot of trouble isolating the moment when it happens since I usually don't notice until much later (since session cookies on existing instances of vimb remain logged in, and new windows on other pages do not show any obvious signs until I try to do something related to a logged-in service). At the moment I'm hoping that someone can just confirm that it's not just me, so I can figure out if it is specific to my environment.
I'm trying to figure this out, so far I can't isolate the exact conditions.
They appear to be reset when I open a new window, although as noted above I can't be sure since I only notice when I open a new window.
All cookies. It seems the file itself is just written over. |
I'm having the same problem here. It seems to happen randomly when page is loading. It happened once just now. When I refresh this page (I didn't test other pages), all my cookies disappears. I tried to restore the cookies from backup and refresh again, and the cookies are reset almost every time. However, if I closed all browser windows and do that again, the cookies are still there. When the cookies are reset, the cookies file grows a lot in 0.5s, and then become empty. This may be a hint to find the bug. |
@yyt16384 Sorry for the late response. Is it right that the cookies file is reset on you system with only instance/window of vimb running? This would make it easier to reproduce and to test. May be the issue is something related to the filesystem. I've ext4 for the config directory where the cookies files resists and never seen the cookies file to be reset. |
@yyt16384 Maybe you can use strace to check when the cookies files is reset. I've not teste, but somethings like this should work |
@yyt16384 really happy to hear that I'm not the only one dealing with this bug! Hopefully together we can pinpoint the cause. @fanglingsu I'll give that a shot and see. I can't seem to find any common factor, it happens on both of my workstations (very similar) although less on one than the other, but for no obvious reason. |
Hmm trying to test this with trace on and finding now it's not happening anymore. I just did a full system upgrade so maybe it was something system-related. @yyt16384 are you still having this issue? What's your system like? I'm using i3 window manager on arch linux, latest kernel etc. |
@fanglingsu Looking at the trace log, I do notice a lot of |
Never mind spoke too soon, it happened again. I have the trace but hard to pick out anything, @fanglingsu what should I be looking for? |
@shioyama My approach would be to look for write operations to the cookie file are attempt to get a lok on it. But I'm not as experienced in reading such traces, so I'd scroll to the trace an look for some strance parts in it. |
I'm not familiar with file locks, but if I'm reading
I haven't tested it, but I did a experiment and it seemed to work after fixing these things. |
@yyt16384 Thank you for you investigation according to the man page you are right. The fcntl should get a pointer to the struct, but why does the compiler not mention this issue? And the |
I have made a pull request about this.
|
@fanglingsu @yyt16384 Really happy to see this fix, but unfortunately although the problem seems to happen less often, I'm still seeing it happen with the latest version of vimb. I'll try tracing it down. |
@shioyama I'm also seeing it happen here. I don't have time to work on it now, but I think it would be to useful to add some logging to If you can build a custom libsoup, you can also try to add logging to |
@yyt16384 thanks glad we seem to be seeing the same behaviour. I'll see what I can do, my c is a bit rusty but eager to get this fixed so I'll give it a shot. @fanglingsu sorry can we re-open this? |
@shioyama If the issue still exists it's always a good choice to reopen the issue. Sorry that I can't really help here. I can't reproduce the issue neither on my arch linux nor on the ubuntu system of my wife. So I was glad that Yutao Yuan spent some time of the nice and important patch, that made me think it's now fixed with it. |
@fanglingsu no worries! I didn't mean to sound like I was complaining. I really appreciate what you've done creating vimb and for how responsive you are to issues. This is a nasty problem because it's so hard (for me at least) to reproduce reliably... I wonder if some particular pages/actions/environments trigger it more often. I usually have 10-20 vimb windows open at once logged into different services, but still can't isolate any that are more likely to trigger it. |
Looking at the manpage for The change from
Since this return value is being ignored, it would seem to me that vimb in this case would just go ahead and write to the file anyway and this could cause the issues we've seen. Just a guess, I'll try testing it out and see if it's the cause of the problems here. |
No dice. I put a debugger message to check if the return value was |
@fanglingsu I'm reading through the |
So I'm testing now with sqlite for cookies and it seems to be working fine, and only required changing one line. I'm not 100% sure yet that it fixes the problem but at the very least if the problem re-occurs, I will know that it has nothing to do with |
@shioyama Thank you for your investigation.
First I like to use files because ist a little easier to process it wit external tools. But now it's required to get the external download working. This would spawn a downloader that might know your current cookie information to use you authenticated session. As I know, does the curl and wget not support sqlite as cookie storage, so it's required for this to have the cookie file. |
I think |
@yyt16384 yes existing timeout functionality does not work exactly as-is with the sqlite cookies file. However I don't want my cookies to expire anyway so it doesn't really matter. I've tested with sqlite now for a few hours and I don't see the issue here happening at all, so I'm going to stick with this setup since it works for my needs. @fanglingsu I also don't see any issue with downloading even where cookies would be required, not sure why but just happy everything seems to work. So overall I think if we really can't nail down the source of this bug I'd suggest having an option to use sqlite3 cookies. Also this could possibly have the added benefit of sharing cookies with firefox which uses the same format (although I have not tested that one). |
The cookie file is only needed for the external download
Because of the issue with the external download, it would not really make sense to use sqlite. OK, we could allow to use it and inform that this would not work with curl or wget (other tools might also be able to use the sqlite). The sharing of cookies with firefox is no argument for me and I don't advice to share cookies betwenn different browsers. Most of the serious webapplications check the session against some browser specific data like user-agent String. If you open a session with one browser and try to pick it up with another one, the webapplication would interprete this as an session hijacking attempt and clear the session. But your investigation helped to strip down the issue to the file storage of the cookies or to the locking. Could you also try to remove the |
Fair enough, I just was hoping this might help someone.
Right sorry, I was just throwing that idea out there but you're right it doesn't make much sense.
Sure I can try that. The problem with this bug is that it's hard to reproduce reliably so I need to actually spend at least an hour or two in regular use to get it to happen, which means in the end losing time with cookies getting reset. But I do want to fix this problem and I think we're getting close so I'll give it a shot and report back. |
Note that the expire-time stuff was added to pick up sessions in case you open a page into a new window, that is a new instance of vimb and does not share any memory or cookie information except of the cookies that are written to the cookies file. So if the webserver attemps to set a cokie without lifetime this would normally saved in memory and could not be picked up by another browser instance or the external download. So, in case such an session cookie is set, we force libsoup to write it into the file. |
Ok I've done a bit of investigating. I tried removing the I'm a bit at a loss at what could be left, unless the issue is that locking is necessary but is not being performed correctly, which would be tricky to debug... |
Hm, we could try an attempt without the cookiejar.c and use |
@fanglingsu ok I'll give that a shot. |
Ok this seems to be an issue with soup cookiejar text cookies in general, I'm still seeing the issue with @fanglingsu's suggestion above. @yyt16384 could you try the same thing just to sanity check this? Nobody else seems to be encountering it except for us. |
Well, locking is required here as libsoup does no locking itself with text cookies storage. I just looked into the source code of surf, and the only real difference is that we use
One possible solution would be to change it to |
Thanks @yyt16384 that sounds like we have an explanation for this now. Maybe fixing compilation on freebsd would be easier than debugging locking issues... |
@yyt16384 You are right the only reason I switched to fcntl was a build error on FreeBSD. I don't have a FreeBSD system to test this, but according to FreeBSD flock man page flock should be available there too. So I think we should give the |
I'll try to provide a branch to test this using |
So, I've reverted to use |
Good news, I could reproduce the issue with github account.
During the load of the windows the cookies file was temporary empty. With the new branch the cookies file was kept like expected. But maybe we have to spent more time to check if it happens again. |
@fanglingsu great to hear! I'll test with the flock branch asap and get back to you. Funny thing I also noticed that when the file was cleared, the entry at the top mostly ended up being github. Maybe something about github is more likely to trigger it... |
I've been running with the fork on my home setup for the last week without a single case of cleared cookies, so I think we can safely assume that using |
OK, I'll merge the branch into master. |
The fix-file-locking branch is now merged into master. |
Thanks! |
Changes: The new vimb 2.11 is now released. With some new features and important bug fixes. I thank following people for providing ideas and patches: - Benjamin Petrenko - Chris Salzberg - Dmitrij D. Czarkoff - Jiri Marsicek - Leonardo Taccari - PLR - Yutao Yuan Added * Added hint-number-same-length option * VERBOSE flag to Makefile to toggle verbose make on * `<Esc>` removes selections in normal mode * Support for multiple configuration profiles. New parameter `-p` or `--profile` * Adds support for contenteditable attribute as input mode trigger [#237](fanglingsu/vimb#237) * Added `^` as normal mode alias of `0` [#236](fanglingsu/vimb#236) * Added :source command to source a config file * Added path completion for :save command too * Added closed-max-items option to allow to store more than one closed page Changed * Set only required CFLAGS * Replaced `-Wpedantic` with `-pedantic` CFLAGS for older gcc versions * Check for focused editable element as soon as possible * Do not blur the focused element after alt-tabbing * Show typed text as last completion entry to easily change it [#253](fanglingsu/vimb#253) Fixed * Fixed [#224](fanglingsu/vimb#224): Wrong URL and titles shown in case one or more pages could not be loaded. * Fixed Makefile install target using -D * Fixed [#232](fanglingsu/vimb#232): Fixed misplaced hint labels on some sites * Fixed [#235](fanglingsu/vimb#235): Randomly reset cookie file * Fixed none POSIX `echo -n` call
still happens to me on vimb 3.1.0, 2 different computers running archlinux |
I can't pinpoint the trigger, but in my setup the cookies file seems to get randomly reset, such that I lose all my cookies and have to re-login to all sites if I open a new window (existing windows retain their session cookies and continue to work).
This was discussed in #154 but I have fixed the issues related to the values of
cookie-expire-time
andcookie-timeout
, and this does not seem to be related AFAICT. I've reproduced the issue on two separate laptops (both running arch linux, both running vimb 2.10 (although slightly different commits)).For now I'd just be happy to hear if anybody else has encountered the same issue, otherwise it is possibly due to my particular setup (both laptops have the same dotfiles, packages, etc. so almost identical). Any other clues to help debug this would be appreciated, I'm at a loss for how to figure out what's going on.
The text was updated successfully, but these errors were encountered: