[
https://issues.apache.org/jira/browse/SVN-4907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17584827#comment-17584827
]
Nathan.qian edited comment on SVN-4907 at 8/25/22 12:42 PM:
------------------------------------------------------------
Show the demo code as svntest.c; if the line "const char *path = "/error
path";" path is nonexistent, the memory will leak; but if the path is a
existing path, the memory is ok, no memory leak .
Here is the shell show the memory is leak;
[root@0-New ~]# ps aux | grep svntest
root 41008 1.8 0.0 232324 11520 pts/1 S+ 20:35 0:00 ./svntest
root 44081 0.0 0.0 114956 988 pts/2 S+ 20:36 0:00 grep
--color=auto svntest
[root@0-New ~]# ps aux | grep svntest
root 41008 1.8 0.0 236260 13368 pts/1 S+ 20:35 0:00 ./svntest
root 44573 0.0 0.0 114956 988 pts/2 S+ 20:36 0:00 grep
--color=auto svntest
[root@0-New ~]# ps aux | grep svntest
root 41008 1.7 0.0 236800 13632 pts/1 S+ 20:35 0:00 ./svntest
root 44939 0.0 0.0 114956 984 pts/2 S+ 20:36 0:00 grep
--color=auto svntest
[[email protected]]
was (Author: nathan.qian):
Show the demo code as svntest.c; if the line "const char *path = "/error
path";" path is nonexistent, the memory will leak; but if the path is a
existing path, the memory is ok, no memory leak .
Here is the shell show the memory is leak;
[root@0-New ~]# ps aux | grep svntest
root 41008 1.8 0.0 232324 11520 pts/1 S+ 20:35 0:00 ./svntest
root 44081 0.0 0.0 114956 988 pts/2 S+ 20:36 0:00 grep
--color=auto svntest
[root@0-New ~]# ps aux | grep svntest
root 41008 1.8 0.0 236260 13368 pts/1 S+ 20:35 0:00 ./svntest
root 44573 0.0 0.0 114956 988 pts/2 S+ 20:36 0:00 grep
--color=auto svntest
[root@0-New ~]# ps aux | grep svntest
root 41008 1.7 0.0 236800 13632 pts/1 S+ 20:35 0:00 ./svntest
root 44939 0.0 0.0 114956 984 pts/2 S+ 20:36 0:00 grep
--color=auto svntest
[root@HIK-SVN-0-140-New ~]#
> svn_fs_node_id causes memory leak...
> ------------------------------------
>
> Key: SVN-4907
> URL: https://issues.apache.org/jira/browse/SVN-4907
> Project: Subversion
> Issue Type: Bug
> Components: svnlook
> Affects Versions: 1.10.x
> Reporter: Nathan.qian
> Priority: Critical
> Attachments: svntest.c
>
>
> We used svnlook to transform a dynamic library for some of our interface
> operations. We found that memory leaks would occur when svn_fs_node_id (with
> apr_pool_t and svn_pool_destroy(pool)) was called frequently;
> The code looks shown below, we call svn_fs_node_id with apr_pool_t , and
> after the call , we use svn_pool_destroy(pool) clear memory. But there is a
> bug : if we use *{color:#ff0000}a nonexistent path call
> subcommand_show_revison, the memory will leak{color}* ; but if
> {color:#ff0000}*a existing path, the memory is ok, no memory leak*{color} .
>
> int init_svncmcenter(apr_pool_t *pool,char *out_str,const char
> *repos_path,const char *path,const char **path_relative,const char
> *rev,struct svnlook_opt_state *opt_state,svn_fs_root_t **root,const
> svn_fs_id_t **id,svnlook_ctxt_t * *c,int with_lastexist )
> {
> ......
> ......
> if ((svn_fs_node_id(id, *root, *path_relative, pool)) != SVN_NO_ERROR ||
> !(*id))
>
> {
> {color:#FF0000}*//memory leak happens here*{color}
> printf("path (%s) error. Warning: svn_fs_node_id may cause memory
> leaks.\n", path); sprintf(out_str,"212 path error"); return 212;
> }
> return 200;
> }
> int subcommand_show_revison(const char *repos_path,const char *path,const
> char *rev,char *out_str,int b_filesize,int with_changed_date,int with_author)
> {
> apr_pool_t *pool =
> apr_allocator_owner_get(svn_pool_create_allocator(FALSE));
> ......
> ......
> if (init_svncmcenter(pool,out_str, repos_path,
> path,&path_relative,rev,&opt_state,&root,&id,&c,1) != 200)
> {
> {color:#ff0000} *svn_pool_destroy(pool);*{color}
> return -1;
> }
> ......
> ......
> svn_pool_destroy(pool);
> return 0;
> }
--
This message was sent by Atlassian Jira
(v8.20.10#820010)