Skip to main content
QUICK REVIEW

[Paper Review] Path-Based Function Embedding and its Application to Specification Mining

Daniel DeFreez, Aditya Thakur|arXiv (Cornell University)|Feb 21, 2018
Software Engineering ResearchComputer Science22 references16 citations
TL;DR

This paper introduces func2vec, a neural network-based method that learns distributed function embeddings by generating sentences from random walks over a labeled pushdown system (ℓ-PDS) representation of code. The approach effectively groups function synonyms—semantically similar but syntactically dissimilar functions—into clusters, achieving 87% precision and 71% recall on a Linux kernel gold standard, and enables high-support error-handling specification mining across file systems and drivers.

ABSTRACT

Identifying the relationships among program elements is useful for program understanding, debugging, and analysis. One such relationship is synonymy. Function synonyms are functions that play a similar role in code, e.g. functions that perform initialization for different device drivers, or functions that implement different symmetric-key encryption schemes. Function synonyms are not necessarily semantically equivalent and can be syntactically dissimilar; consequently, approaches for identifying code clones or functional equivalence cannot be used to identify them. This paper presents func2vec, an algorithm that maps each function to a vector in a vector space such that function synonyms are grouped together. We compute the function embedding by training a neural network on sentences generated from random walks over an encoding of the program as a labeled pushdown system (l-PDS). We demonstrate that func2vec is effective at identifying function synonyms in the Linux kernel. Furthermore, we show how function synonyms enable mining error-handling specifications with high support in Linux file systems and drivers.

Motivation & Objective

  • To address the challenge of identifying function synonyms in low-level systems code like the Linux kernel, where naming conventions are unreliable and functions may be syntactically and semantically dissimilar.
  • To develop a scalable, unsupervised method for learning function embeddings that capture hierarchical program structure without prior knowledge of naming or semantic equivalence.
  • To improve the mining of error-handling specifications in Linux by leveraging function synonyms across multiple implementations to increase specification support.
  • To demonstrate that function embeddings can enhance specification mining in large-scale, low-level codebases where traditional approaches fail due to low occurrence frequency of error paths.

Proposed method

  • Represent the program as a labeled pushdown system (ℓ-PDS), where nodes represent program elements (functions, instructions, types, error codes) and edges are labeled with semantic types.
  • Generate random walks over the ℓ-PDS to produce sequences of labels, which are treated as sentences for neural network training.
  • Train a skip-gram model (inspired by word2vec) on these label sequences to learn dense vector representations (embeddings) of functions in a 300-dimensional space.
  • Use t-SNE to project the learned R³⁰⁰ embeddings into 2D for visualization and cluster analysis.
  • Apply the learned embeddings to identify function synonyms by measuring cosine similarity between function vectors.
  • Leverage identified function synonyms to unify error-handling patterns across different implementations, enabling cross-implementation specification mining with higher support.

Experimental results

Research questions

  • RQ1Can a neural network trained on random walks over a labeled pushdown system effectively group function synonyms in large-scale, low-level systems code like the Linux kernel?
  • RQ2How effective is func2vec at identifying function synonyms in terms of precision and recall compared to a manually curated gold standard?
  • RQ3Can function embeddings derived from func2vec improve the support and quality of mined error-handling specifications in Linux file systems and drivers?
  • RQ4To what extent can func2vec reduce false positives in specification mining by aggregating rare error-handling patterns across semantically similar functions?

Key findings

  • func2vec achieved 87% precision and 71% recall in identifying function synonyms on a manually curated gold standard of 683 Linux kernel functions grouped into 127 synonym classes.
  • The method successfully clusters function synonyms based on semantic role (e.g., probe, open, free) in the Linux kernel, as visualized via t-SNE projections.
  • By identifying function synonyms across multiple implementations, func2vec enables the mining of cross-implementation error-handling specifications with significantly higher support than possible with individual implementations.
  • The evaluation on 5 Linux file systems and 48 device drivers confirms that using func2vec results improves the quality and reliability of mined error-handling specifications.
  • func2vec is the first technique to apply neural network-based function embeddings to large-scale systems code such as the Linux kernel (2 million LOC), demonstrating scalability and effectiveness.
  • The approach outperforms traditional specification mining techniques that rely solely on normal execution paths or isolated error traces, especially for error-handling patterns that are rare or implementation-specific.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.